[haiku-commits] r39145 - haiku/trunk/src/preferences/locale

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 25 Oct 2010 19:33:06 +0200 (CEST)

Author: anevilyak
Date: 2010-10-25 19:33:06 +0200 (Mon, 25 Oct 2010)
New Revision: 39145
Changeset: http://dev.haiku-os.org/changeset/39145

Modified:
   haiku/trunk/src/preferences/locale/LanguageListView.cpp
   haiku/trunk/src/preferences/locale/LanguageListView.h
Log:
Override Update() so we can return an item width that includes our flag.



Modified: haiku/trunk/src/preferences/locale/LanguageListView.cpp
===================================================================
--- haiku/trunk/src/preferences/locale/LanguageListView.cpp     2010-10-25 
16:15:10 UTC (rev 39144)
+++ haiku/trunk/src/preferences/locale/LanguageListView.cpp     2010-10-25 
17:33:06 UTC (rev 39145)
@@ -30,6 +30,8 @@
 #define B_TRANSLATE_CONTEXT "LanguageListView"
 
 
+static const float kFlagWidth = 17.0;
+
 LanguageListItem::LanguageListItem(const char* text, const char* id,
        const char* code, const char* countryCode)
        :
@@ -104,10 +106,10 @@
        owner->DrawString(text.String());
 
        // Draw the icon
-       frame.left = frame.right - 17;
+       frame.left = frame.right - kFlagWidth;
        BRect iconFrame(frame);
-       iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 15,
-               iconFrame.top + 16);
+       iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 
kFlagWidth - 2,
+               iconFrame.top + kFlagWidth - 1);
 
        if (fIcon != NULL && fIcon->IsValid()) {
                owner->SetDrawingMode(B_OP_OVER);
@@ -118,6 +120,14 @@
 }
 
 
+void
+LanguageListItem::Update(BView* owner, const BFont* font)
+{
+       BStringItem::Update(owner, font);
+       SetWidth(Width() + kFlagWidth);
+}
+
+
 // #pragma mark -
 
 

Modified: haiku/trunk/src/preferences/locale/LanguageListView.h
===================================================================
--- haiku/trunk/src/preferences/locale/LanguageListView.h       2010-10-25 
16:15:10 UTC (rev 39144)
+++ haiku/trunk/src/preferences/locale/LanguageListView.h       2010-10-25 
17:33:06 UTC (rev 39145)
@@ -31,6 +31,8 @@
        virtual void                    DrawItem(BView* owner, BRect frame,
                                                                bool complete = 
false);
 
+       virtual void                    Update(BView* owner, const BFont* font);
+
 private:
                        BString                 fID;
                        BString                 fCode;


Other related posts:

  • » [haiku-commits] r39145 - haiku/trunk/src/preferences/locale - anevilyak