Override Update() so we can return an item width that includes our flag.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39145 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2010-10-25 17:33:06 +00:00
parent 31a81a2b93
commit 04e916ccb5
2 changed files with 15 additions and 3 deletions
+13 -3
View File
@@ -30,6 +30,8 @@
#define B_TRANSLATE_CONTEXT "LanguageListView" #define B_TRANSLATE_CONTEXT "LanguageListView"
static const float kFlagWidth = 17.0;
LanguageListItem::LanguageListItem(const char* text, const char* id, LanguageListItem::LanguageListItem(const char* text, const char* id,
const char* code, const char* countryCode) const char* code, const char* countryCode)
: :
@@ -104,10 +106,10 @@ LanguageListItem::DrawItem(BView* owner, BRect frame, bool complete)
owner->DrawString(text.String()); owner->DrawString(text.String());
// Draw the icon // Draw the icon
frame.left = frame.right - 17; frame.left = frame.right - kFlagWidth;
BRect iconFrame(frame); BRect iconFrame(frame);
iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 15, iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + kFlagWidth - 2,
iconFrame.top + 16); iconFrame.top + kFlagWidth - 1);
if (fIcon != NULL && fIcon->IsValid()) { if (fIcon != NULL && fIcon->IsValid()) {
owner->SetDrawingMode(B_OP_OVER); owner->SetDrawingMode(B_OP_OVER);
@@ -118,6 +120,14 @@ LanguageListItem::DrawItem(BView* owner, BRect frame, bool complete)
} }
void
LanguageListItem::Update(BView* owner, const BFont* font)
{
BStringItem::Update(owner, font);
SetWidth(Width() + kFlagWidth);
}
// #pragma mark - // #pragma mark -
@@ -31,6 +31,8 @@ public:
virtual void DrawItem(BView* owner, BRect frame, virtual void DrawItem(BView* owner, BRect frame,
bool complete = false); bool complete = false);
virtual void Update(BView* owner, const BFont* font);
private: private:
BString fID; BString fID;
BString fCode; BString fCode;