[haiku-commits] haiku: hrev46532 - in src: preferences/time preferences/locale servers/app kits/interface

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 13 Dec 2013 08:22:02 +0100 (CET)

hrev46532 adds 8 changesets to branch 'master'
old head: b38580f902b032e2e98ce85a894d3255eaad3460
new head: dd0bdb49dc5d2fdb37f29dd687cd2a406fd34ab7
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=dd0bdb4+%5Eb38580f

----------------------------------------------------------------------------

e3be58f: BStringItem: Tiny style fix

8c6d549: BStringItem: Set the low color to the list view color
  
  instead of the low color, practically this should make little difference,
  just a cleanup.

3a2b6b9: Locale: Small cleanup of outline list view.
  
  * preserve high and low colors of view between draws
  * Use DefaultLabelSpacing() instead of using hard 4 pixel spacing

553211b: Time prefs: style fixes to ZoneView

5b013ea: Time prefs: rework time zone view
  
  * Add country flags back to the time zone view.
  * Use Appearance color constants.

7888f1d: Make destructor virtual

8f5d92f: EventDispatcher: Style fixes

dd0bdb4: Fix a bug retreiving tooltips
  
  Noticed this in Time prefs was displaying wrong time zone tool tip,
  dug deeper...
  
  hrev46290 introduced this bug because it passes fLastCursorPosition
  into the “be:view_where” parameter of the B_MOUSE_IDLE message.
  The problem is that fLastCursorPosition is in the screen’s coordinate
  system, not the view’s and BView expects “be:view_where” to be in the
  view’s coordinate system.
  
  So, to fix this I pass fLastCursorPosition in the “screen_where” parameter
  instead which I’ve instructed BView to interpret as the point in the screen’s
  coordinate system which is then dutifully converted back the the view’s
  coordinate system.
  
  I tried to follow the naming scheme of other code, not sure if screen_where
  should be namespaced with the be: predicate or not.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

9 files changed, 245 insertions(+), 142 deletions(-)
src/kits/interface/StringItem.cpp           |  17 +--
src/kits/interface/View.cpp                 |   8 +-
src/preferences/locale/LanguageListView.cpp |  23 ++--
src/preferences/time/TimeZoneListItem.cpp   | 158 +++++++++++++++---------
src/preferences/time/TimeZoneListItem.h     |  26 +++-
src/preferences/time/TimeZoneListView.h     |   2 +-
src/preferences/time/ZoneView.cpp           | 126 +++++++++++--------
src/servers/app/EventDispatcher.cpp         |  22 ++--
src/servers/app/EventDispatcher.h           |   5 +-

############################################################################

Commit:      e3be58f1441074af0ca77697386ffe4a11525905
URL:         http://cgit.haiku-os.org/haiku/commit/?id=e3be58f
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Nov 26 04:34:50 2013 UTC

BStringItem: Tiny style fix

----------------------------------------------------------------------------

diff --git a/src/kits/interface/StringItem.cpp 
b/src/kits/interface/StringItem.cpp
index e4ec0af..6902f82 100644
--- a/src/kits/interface/StringItem.cpp
+++ b/src/kits/interface/StringItem.cpp
@@ -130,7 +130,7 @@ BStringItem::Text() const
 void
 BStringItem::Update(BView *owner, const BFont *font)
 {
-       if (fText) {
+       if (fText != NULL) {
                SetWidth(font->StringWidth(fText)
                        + be_control_look->DefaultLabelSpacing());
        }

############################################################################

Commit:      8c6d549022e6da7ee267e3b4e5e230d446aef5ad
URL:         http://cgit.haiku-os.org/haiku/commit/?id=8c6d549
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Nov 26 04:37:38 2013 UTC

BStringItem: Set the low color to the list view color

instead of the low color, practically this should make little difference,
just a cleanup.

----------------------------------------------------------------------------

diff --git a/src/kits/interface/StringItem.cpp 
b/src/kits/interface/StringItem.cpp
index 6902f82..73fa7d8 100644
--- a/src/kits/interface/StringItem.cpp
+++ b/src/kits/interface/StringItem.cpp
@@ -77,14 +77,17 @@ BStringItem::DrawItem(BView *owner, BRect frame, bool 
complete)
        rgb_color lowColor = owner->LowColor();
 
        if (IsSelected() || complete) {
-               if (IsSelected()) {
-                       
owner->SetHighColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR));
-                       owner->SetLowColor(owner->HighColor());
-               } else
-                       owner->SetHighColor(lowColor);
+               rgb_color color;
+               if (IsSelected())
+                       color = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);
+               else
+                       color = owner->ViewColor();
 
+               owner->SetLowColor(color);
+               owner->SetHighColor(color);
                owner->FillRect(frame);
-       }
+       } else
+               owner->SetLowColor(owner->ViewColor());
 
        owner->MovePenTo(frame.left + be_control_look->DefaultLabelSpacing(),
                frame.top + fBaselineOffset);

############################################################################

Commit:      3a2b6b9d521e3829676c6e8c0c6e56bfc60dbb45
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3a2b6b9
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Nov 26 04:40:16 2013 UTC

Locale: Small cleanup of outline list view.

* preserve high and low colors of view between draws
* Use DefaultLabelSpacing() instead of using hard 4 pixel spacing

----------------------------------------------------------------------------

diff --git a/src/preferences/locale/LanguageListView.cpp 
b/src/preferences/locale/LanguageListView.cpp
index f5ca850..0d80e6d 100644
--- a/src/preferences/locale/LanguageListView.cpp
+++ b/src/preferences/locale/LanguageListView.cpp
@@ -18,6 +18,7 @@
 
 #include <Bitmap.h>
 #include <Catalog.h>
+#include <ControlLook.h>
 #include <FormattingConventions.h>
 #include <GradientLinear.h>
 #include <LocaleRoster.h>
@@ -32,8 +33,6 @@
 #define B_TRANSLATION_CONTEXT "LanguageListView"
 
 
-static const float kLeftInset = 4;
-
 LanguageListItem::LanguageListItem(const char* text, const char* id,
        const char* languageCode)
        :
@@ -64,6 +63,9 @@ void
 LanguageListItem::DrawItemWithTextOffset(BView* owner, BRect frame,
        bool complete, float textOffset)
 {
+       rgb_color highColor = owner->HighColor();
+       rgb_color lowColor = owner->LowColor();
+
        if (IsSelected() || complete) {
                rgb_color color;
                if (IsSelected())
@@ -93,9 +95,13 @@ LanguageListItem::DrawItemWithTextOffset(BView* owner, BRect 
frame,
                        owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
        }
 
-       owner->MovePenTo(frame.left + kLeftInset + textOffset,
+       owner->MovePenTo(
+               frame.left + be_control_look->DefaultLabelSpacing() + 
textOffset,
                frame.top + BaselineOffset());
        owner->DrawString(text.String());
+
+       owner->SetHighColor(highColor);
+       owner->SetLowColor(lowColor);
 }
 
 
@@ -134,7 +140,7 @@ LanguageListItemWithFlag::Update(BView* owner, const BFont* 
font)
        LanguageListItem::Update(owner, font);
 
        float iconSize = Height();
-       SetWidth(Width() + iconSize + 4);
+       SetWidth(Width() + iconSize + be_control_look->DefaultLabelSpacing());
 
        if (fCountryCode.IsEmpty())
                return;
@@ -158,10 +164,13 @@ LanguageListItemWithFlag::DrawItem(BView* owner, BRect 
frame, bool complete)
        }
 
        float iconSize = fIcon->Bounds().Width();
-       DrawItemWithTextOffset(owner, frame, complete, iconSize + 4);
+       DrawItemWithTextOffset(owner, frame, complete,
+               iconSize + be_control_look->DefaultLabelSpacing());
 
-       BRect iconFrame(frame.left + kLeftInset, frame.top,
-               frame.left + kLeftInset + iconSize - 1, frame.top + iconSize - 
1);
+       BRect iconFrame(frame.left + be_control_look->DefaultLabelSpacing(),
+               frame.top,
+               frame.left + iconSize - 1 + 
be_control_look->DefaultLabelSpacing(),
+               frame.top + iconSize - 1);
        owner->SetDrawingMode(B_OP_OVER);
        owner->DrawBitmap(fIcon, iconFrame);
        owner->SetDrawingMode(B_OP_COPY);

############################################################################

Commit:      553211b49970e5de8cf5e569f578f3afb3deecf6
URL:         http://cgit.haiku-os.org/haiku/commit/?id=553211b
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Nov 26 07:07:21 2013 UTC

Time prefs: style fixes to ZoneView

----------------------------------------------------------------------------

diff --git a/src/preferences/time/ZoneView.cpp 
b/src/preferences/time/ZoneView.cpp
index 08f5332..2356bba 100644
--- a/src/preferences/time/ZoneView.cpp
+++ b/src/preferences/time/ZoneView.cpp
@@ -223,7 +223,8 @@ TimeZoneView::_InitView()
                BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
 
        fLocalTime = new BRadioButton("localTime",
-               B_TRANSLATE("Local time (Windows compatible)"), new 
BMessage(kRTCUpdate));
+               B_TRANSLATE("Local time (Windows compatible)"),
+                       new BMessage(kRTCUpdate));
        fGmtTime = new BRadioButton("greenwichMeanTime",
                B_TRANSLATE("GMT (UNIX compatible)"), new BMessage(kRTCUpdate));
 
@@ -267,11 +268,9 @@ TimeZoneView::_BuildZoneMenu()
        BLanguage language;
        BLocale::Default()->GetLanguage(&language);
 
-       /*
-        * Group timezones by regions, but filter out unwanted (duplicate) 
regions
-        * and add an additional region with generic GMT-offset timezones at 
the end
-        */
-       typedef std::map<BString, TimeZoneListItem*, TimeZoneItemLess> 
ZoneItemMap;
+       // Group timezones by regions, but filter out unwanted (duplicate) 
regions
+       // and add an additional region with generic GMT-offset timezones at 
the end
+       typedef std::map<BString, TimeZoneListItem*, TimeZoneItemLess> 
ZoneItemMap;
        ZoneItemMap zoneItemMap;
        const char* kOtherRegion = B_TRANSLATE_MARK("<Other>");
        const char* kSupportedRegions[] = {
@@ -283,9 +282,10 @@ TimeZoneView::_BuildZoneMenu()
                kOtherRegion,
                NULL
        };
+
        // Since the zone-map contains translated country-names (we get those 
from
        // ICU), we need to use translated region names in the zone-map, too:
-       typedef std::map<BString, BString> TranslatedRegionMap;
+       typedef std::map<BString, BString> TranslatedRegionMap;
        TranslatedRegionMap regionMap;
        for (const char** region = kSupportedRegions; *region != NULL; 
++region) {
                BString translatedRegion = B_TRANSLATE_NOCOLLECT(*region);
@@ -303,15 +303,15 @@ TimeZoneView::_BuildZoneMenu()
 
        typedef std::map<BString, std::vector<const char*> > ZonesByCountyMap;
        ZonesByCountyMap zonesByCountryMap;
-       const char *zoneID;
-       BString countryCode;
+       const char* zoneID;
+       BString timeZoneCode;
        for (int tz = 0; zoneList.FindString("timeZone", tz, &zoneID) == B_OK
-                       && zoneList.FindString("region", tz, &countryCode) == 
B_OK; tz++) {
+                       && zoneList.FindString("region", tz, &timeZoneCode) == 
B_OK; tz++) {
                // From the global ("001") timezones, we only accept the 
generic GMT
                // timezones, as all the other world-zones are duplicates of 
others.
-               if (countryCode == "001" && strncmp(zoneID, "Etc/GMT", 7) != 0)
+               if (timeZoneCode == "001" && strncmp(zoneID, "Etc/GMT", 7) != 0)
                        continue;
-               zonesByCountryMap[countryCode].push_back(zoneID);
+               zonesByCountryMap[timeZoneCode].push_back(zoneID);
        }
 
        ZonesByCountyMap::const_iterator countryIter = 
zonesByCountryMap.begin();
@@ -336,16 +336,15 @@ TimeZoneView::_BuildZoneMenu()
                                continue;
 
                        BString fullCountryID = regionIter->second;
-                       bool countryIsRegion
-                               = countryName == regionIter->second || region 
== kOtherRegion;
+                       bool countryIsRegion = countryName == regionIter->second
+                               || region == kOtherRegion;
                        if (!countryIsRegion)
                                fullCountryID << "/" << countryName;
 
                        BTimeZone* timeZone = new BTimeZone(zoneID, &language);
                        BString tzName;
                        BString fullZoneID = fullCountryID;
-                       if (zoneCountInCountry > 1)
-                       {
+                       if (zoneCountInCountry > 1) {
                                // we can't use the country name as timezone 
name, since there
                                // are more than one timezones in this country 
- fetch the
                                // localized name of the timezone and use that
@@ -394,6 +393,7 @@ TimeZoneView::_BuildZoneMenu()
                                fCurrentZoneItem = zoneItem;
                                if (countryItem != NULL)
                                        countryItem->SetExpanded(true);
+
                                ZoneItemMap::iterator regionItemIter
                                        = zoneItemMap.find(regionIter->second);
                                if (regionItemIter != zoneItemMap.end())
@@ -408,13 +408,12 @@ TimeZoneView::_BuildZoneMenu()
        bool lastWasCountryItem = false;
        TimeZoneListItem* currentCountryItem = NULL;
        for (zoneIter = zoneItemMap.begin(); zoneIter != zoneItemMap.end();
-               ++zoneIter) {
+                       ++zoneIter) {
                if (zoneIter->second->OutlineLevel() == 2 && 
lastWasCountryItem) {
-                       /* Some countries (e.g. Spain and Chile) have their 
timezones
-                        * spread across different regions. As a result, there 
might still
-                        * be country items with only one timezone below them. 
We manually
-                        * filter those country items here.
-                        */
+                       // Some countries (e.g. Spain and Chile) have their 
timezones
+                       // spread across different regions. As a result, there 
might still
+                       // be country items with only one timezone below them. 
We manually
+                       // filter those country items here.
                        ZoneItemMap::iterator next = zoneIter;
                        ++next;
                        if (next != zoneItemMap.end()
@@ -469,7 +468,7 @@ TimeZoneView::_UpdatePreview()
        TimeZoneListItem* item
                = selection < 0
                        ? NULL
-                       : (TimeZoneListItem*)fZoneList->ItemAt(selection);
+                       : 
static_cast<TimeZoneListItem*>(fZoneList->ItemAt(selection));
 
        if (item == NULL || !item->HasTimeZone()) {
                fPreview->SetText("");

############################################################################

Commit:      5b013eab68a65aa83891cba81c681cdcf034533d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=5b013ea
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Nov 26 10:10:48 2013 UTC

Time prefs: rework time zone view

* Add country flags back to the time zone view.
* Use Appearance color constants.

----------------------------------------------------------------------------

diff --git a/src/preferences/time/TimeZoneListItem.cpp 
b/src/preferences/time/TimeZoneListItem.cpp
index a7058f8..4bcd7fd 100644
--- a/src/preferences/time/TimeZoneListItem.cpp
+++ b/src/preferences/time/TimeZoneListItem.cpp
@@ -1,13 +1,14 @@
 /*
- * Copyright 2010, Haiku Inc. All rights reserved.
+ * Copyright 2010-2013 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Adrien Destugues <pulkomandy@xxxxxxxxxxxxxxxxx>
- *             Stephan Aßmus <superstippi@xxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             Adrien Destugues, pulkomandy@xxxxxxxxxxxxxxxxx
  *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
- *             Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
-*/
+ *             John Scipione, jscipione@xxxxxxxxx
+ *             Oliver Tappe, zooey@xxxxxxxxxxxxxxx
+ */
 
 
 #include "TimeZoneListItem.h"
@@ -16,6 +17,7 @@
 
 #include <Bitmap.h>
 #include <Country.h>
+#include <ControlLook.h>
 #include <String.h>
 #include <TimeZone.h>
 #include <Window.h>
@@ -28,90 +30,85 @@ TimeZoneListItem::TimeZoneListItem(const char* text, 
BCountry* country,
        BTimeZone* timeZone)
        :
        BStringItem(text, 0, false),
-       fIcon(NULL),
-       fTimeZone(timeZone)
+       fCountry(country),
+       fTimeZone(timeZone),
+       fIcon(NULL)
 {
-       if (country != NULL) {
-               fIcon = new(std::nothrow) BBitmap(BRect(0, 0, 15, 15), 
B_RGBA32);
-               if (fIcon != NULL && country->GetIcon(fIcon) != B_OK) {
-                       delete fIcon;
-                       fIcon = NULL;
-               }
-       }
 }
 
 
 TimeZoneListItem::~TimeZoneListItem()
 {
-       delete fIcon;
+       delete fCountry;
        delete fTimeZone;
+       delete fIcon;
 }
 
 
 void
 TimeZoneListItem::DrawItem(BView* owner, BRect frame, bool complete)
 {
-       rgb_color kHighlight = {140, 140, 140, 0};
-       rgb_color kBlack = {0, 0, 0, 0};
-
-       if (IsSelected() || complete) {
-               rgb_color color;
-               if (IsSelected())
-                       color = kHighlight;
-               else
-                       color = owner->ViewColor();
-               owner->SetHighColor(color);
-               owner->SetLowColor(color);
-               owner->FillRect(frame);
-               owner->SetHighColor(kBlack);
-       } else
-               owner->SetLowColor(owner->ViewColor());
-
-       // Draw the text
-       BString text = Text();
-
-       BFont font = be_plain_font;
-       font_height     finfo;
-       font.GetHeight(&finfo);
-       owner->SetFont(&font);
-       // TODO: the position is unnecessarily complicated, and not correct 
either
-       owner->MovePenTo(frame.left + 8, frame.top
-               + (frame.Height() - (finfo.ascent + finfo.descent + 
finfo.leading)) / 2
-               + (finfo.ascent + finfo.descent) - 1);
-       owner->DrawString(text.String());
-
-       // Draw the icon
-       frame.left = frame.right - 16;
-       BRect iconFrame(frame);
-       iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 15,
-               iconFrame.top + 16);
-
        if (fIcon != NULL && fIcon->IsValid()) {
+               float iconSize = fIcon->Bounds().Width();
+               _DrawItemWithTextOffset(owner, frame, complete,
+                       iconSize + be_control_look->DefaultLabelSpacing());
+
+               BRect iconFrame(frame.left + 
be_control_look->DefaultLabelSpacing(),
+                       frame.top,
+                       frame.left + iconSize - 1 + 
be_control_look->DefaultLabelSpacing(),
+                       frame.top + iconSize - 1);
                owner->SetDrawingMode(B_OP_OVER);
                owner->DrawBitmap(fIcon, iconFrame);
                owner->SetDrawingMode(B_OP_COPY);
+       } else
+               _DrawItemWithTextOffset(owner, frame, complete, 0);
+}
+
+
+void
+TimeZoneListItem::Update(BView* owner, const BFont* font)
+{
+       float oldIconSize = Height();
+       BStringItem::Update(owner, font);
+       if (!HasCountry())
+               return;
+
+       float iconSize = Height();
+       if (iconSize == oldIconSize && fIcon != NULL)
+               return;
+
+       SetWidth(Width() + iconSize + be_control_look->DefaultLabelSpacing());
+
+       delete fIcon;
+       fIcon = new(std::nothrow) BBitmap(BRect(0, 0, iconSize - 1, iconSize - 
1),
+               B_RGBA32);
+       if (fIcon != NULL && fCountry->GetIcon(fIcon) != B_OK) {
+               delete fIcon;
+               fIcon = NULL;
        }
 }
 
 
-bool
-TimeZoneListItem::HasTimeZone() const
+void
+TimeZoneListItem::SetCountry(BCountry* country)
 {
-       return fTimeZone != NULL;
+       delete fCountry;
+       fCountry = country;
 }
 
 
-const BTimeZone&
-TimeZoneListItem::TimeZone() const
+void
+TimeZoneListItem::SetTimeZone(BTimeZone* timeZone)
 {
-       return *fTimeZone;
+       delete fTimeZone;
+       fTimeZone = timeZone;
 }
 
 
 const BString&
 TimeZoneListItem::ID() const
 {
-       if (fTimeZone == NULL)
+       if (!HasTimeZone())
                return skDefaultString;
 
        return fTimeZone->ID();
@@ -121,7 +118,7 @@ TimeZoneListItem::ID() const
 const BString&
 TimeZoneListItem::Name() const
 {
-       if (fTimeZone == NULL)
+       if (!HasTimeZone())
                return skDefaultString;
 
        return fTimeZone->Name();
@@ -131,8 +128,51 @@ TimeZoneListItem::Name() const
 int
 TimeZoneListItem::OffsetFromGMT() const
 {
-       if (fTimeZone == NULL)
+       if (!HasTimeZone())
                return 0;
 
        return fTimeZone->OffsetFromGMT();
 }
+
+
+void
+TimeZoneListItem::_DrawItemWithTextOffset(BView* owner, BRect frame,
+       bool complete, float textOffset)
+{
+       rgb_color highColor = owner->HighColor();
+       rgb_color lowColor = owner->LowColor();
+
+       if (IsSelected() || complete) {
+               rgb_color color;
+               if (IsSelected())
+                       color = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);
+               else
+                       color = owner->ViewColor();
+
+               owner->SetHighColor(color);
+               owner->SetLowColor(color);
+               owner->FillRect(frame);
+       } else
+               owner->SetLowColor(owner->ViewColor());
+
+       if (!IsEnabled()) {
+               rgb_color textColor = ui_color(B_LIST_ITEM_TEXT_COLOR);
+               if (textColor.red + textColor.green + textColor.blue > 128 * 3)
+                       owner->SetHighColor(tint_color(textColor, 
B_DARKEN_2_TINT));
+               else
+                       owner->SetHighColor(tint_color(textColor, 
B_LIGHTEN_2_TINT));
+       } else {
+               if (IsSelected())
+                       
owner->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
+               else
+                       owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
+       }
+
+       owner->MovePenTo(
+               frame.left + be_control_look->DefaultLabelSpacing() + 
textOffset,
+               frame.top + BaselineOffset());
+       owner->DrawString(Text());
+
+       owner->SetHighColor(highColor);
+       owner->SetLowColor(lowColor);
+}
diff --git a/src/preferences/time/TimeZoneListItem.h 
b/src/preferences/time/TimeZoneListItem.h
index 1071d9d..81a553f 100644
--- a/src/preferences/time/TimeZoneListItem.h
+++ b/src/preferences/time/TimeZoneListItem.h
@@ -21,20 +21,36 @@ class TimeZoneListItem : public BStringItem {
 public:
                                                                
TimeZoneListItem(const char* text,
                                                                        
BCountry* country, BTimeZone* timeZone);
-                                                               
~TimeZoneListItem();
+       virtual                                         ~TimeZoneListItem();
 
-                       void                            DrawItem(BView* owner, 
BRect frame,
+       virtual void                            DrawItem(BView* owner, BRect 
frame,
                                                                        bool 
complete = false);
 
-                       bool                            HasTimeZone() const;
-                       const BTimeZone&        TimeZone() const;
+       virtual void                            Update(BView* owner, const 
BFont* font);
+
+                       bool                            HasCountry() const
+                                                                       { 
return fCountry != NULL; };
+                       const BCountry&         Country() const { return 
*fCountry; };
+                       void                            SetCountry(BCountry* 
country);
+
+                       bool                            HasTimeZone() const
+                                                                       { 
return fTimeZone != NULL; };
+                       const BTimeZone&        TimeZoneListItem::TimeZone() 
const
+                                                                       { 
return *fTimeZone; };
+                       void                            SetTimeZone(BTimeZone* 
timeZone);
+
                        const BString&          ID() const;
                        const BString&          Name() const;
                        int                                     OffsetFromGMT() 
const;
 
 private:
-                       BBitmap*                        fIcon;
+                       void                            
_DrawItemWithTextOffset(BView* owner,
+                                                                       BRect 
frame, bool complete,
+                                                                       float 
textOffset);
+
+                       BCountry*                       fCountry;
                        BTimeZone*                      fTimeZone;
+                       BBitmap*                        fIcon;
 };
 
 
diff --git a/src/preferences/time/ZoneView.cpp 
b/src/preferences/time/ZoneView.cpp
index 2356bba..8d3e441 100644
--- a/src/preferences/time/ZoneView.cpp
+++ b/src/preferences/time/ZoneView.cpp
@@ -1,14 +1,15 @@
 /*
- * Copyright 2004-2012, Haiku, Inc. All Rights Reserved.
+ * Copyright 2004-2013 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Mike Berg <mike@xxxxxxxxxxx>
- *             Julun <host.haiku@xxxxxx>
- *             Philippe Saint-Pierre <stpere@xxxxxxxxx>
- *             Adrien Destugues <pulkomandy@xxxxxxxxxxxxxxxxx>
- *             Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
- *             Hamish Morrison <hamish@xxxxxxxxxxx>
+ *             Mike Berg, mike@xxxxxxxxxxx
+ *             Adrien Destugues, pulkomandy@xxxxxxxxxxxxxxxxx
+ *             Julun, host.haiku@xxxxxx
+ *             Hamish Morrison, hamish@xxxxxxxxxxx
+ *             Philippe Saint-Pierre, stpere@xxxxxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
+ *             Oliver Tappe, zooey@xxxxxxxxxxxxxxx
  */
 
 
@@ -316,15 +317,19 @@ TimeZoneView::_BuildZoneMenu()
 
        ZonesByCountyMap::const_iterator countryIter = 
zonesByCountryMap.begin();
        for (; countryIter != zonesByCountryMap.end(); ++countryIter) {
-               BCountry country(countryIter->first.String());
-               BString countryName;
-               country.GetName(countryName);
+               const char* countryCode = countryIter->first.String();
+               if (countryCode == NULL)
+                       continue;
 
                size_t zoneCountInCountry = countryIter->second.size();
                for (size_t tz = 0; tz < zoneCountInCountry; tz++) {
                        BString zoneID(countryIter->second[tz]);
-                       int32 slashPos = zoneID.FindFirst('/');
+                       BTimeZone* timeZone
+                               = new(std::nothrow) BTimeZone(zoneID, 
&language);
+                       if (timeZone == NULL)
+                               continue;
 
+                       int32 slashPos = zoneID.FindFirst('/');
                        BString region(zoneID, slashPos);
                        if (region == "Etc")
                                region = kOtherRegion;
@@ -336,29 +341,35 @@ TimeZoneView::_BuildZoneMenu()
                                continue;
 
                        BString fullCountryID = regionIter->second;
+                       BCountry* country = new(std::nothrow) 
BCountry(countryCode);
+                       if (country == NULL)
+                               continue;
+
+                       BString countryName;
+                       country->GetName(countryName);
+                       bool hasUsedCountry = false;
                        bool countryIsRegion = countryName == regionIter->second
                                || region == kOtherRegion;
                        if (!countryIsRegion)
                                fullCountryID << "/" << countryName;
 
-                       BTimeZone* timeZone = new BTimeZone(zoneID, &language);
-                       BString tzName;
+                       BString timeZoneName;
                        BString fullZoneID = fullCountryID;
                        if (zoneCountInCountry > 1) {
                                // we can't use the country name as timezone 
name, since there
                                // are more than one timezones in this country 
- fetch the
                                // localized name of the timezone and use that
-                               tzName = timeZone->Name();
-                               int32 openParenthesisPos = 
tzName.FindFirst('(');
+                               timeZoneName = timeZone->Name();
+                               int32 openParenthesisPos = 
timeZoneName.FindFirst('(');
                                if (openParenthesisPos >= 0) {
-                                       tzName.Remove(0, openParenthesisPos + 
1);
-                                       int32 closeParenthesisPos = 
tzName.FindLast(')');
+                                       timeZoneName.Remove(0, 
openParenthesisPos + 1);
+                                       int32 closeParenthesisPos = 
timeZoneName.FindLast(')');
                                        if (closeParenthesisPos >= 0)
-                                               
tzName.Truncate(closeParenthesisPos);
+                                               
timeZoneName.Truncate(closeParenthesisPos);
                                }
-                               fullZoneID << "/" << tzName;
+                               fullZoneID << "/" << timeZoneName;
                        } else {
-                               tzName = countryName;
+                               timeZoneName = countryName;
                                fullZoneID << "/" << zoneID;
                        }
 
@@ -375,17 +386,22 @@ TimeZoneView::_BuildZoneMenu()
                                ZoneItemMap::iterator countryIter
                                        = zoneItemMap.find(fullCountryID);
                                if (countryIter == zoneItemMap.end()) {
-                                       countryItem = new 
TimeZoneListItem(countryName, NULL, NULL);
+                                       countryItem = new 
TimeZoneListItem(countryName.String(),
+                                               country, NULL);
                                        countryItem->SetOutlineLevel(1);
                                        zoneItemMap[fullCountryID] = 
countryItem;
+                                       hasUsedCountry = true;
                                } else
                                        countryItem = countryIter->second;
 
-                               zoneItem = new TimeZoneListItem(tzName, NULL, 
timeZone);
+                               zoneItem = new 
TimeZoneListItem(timeZoneName.String(),
+                                       NULL, timeZone);
                                zoneItem->SetOutlineLevel(countryIsRegion ? 1 : 
2);
                        } else {
-                               zoneItem = new TimeZoneListItem(tzName, NULL, 
timeZone);
+                               zoneItem = new 
TimeZoneListItem(timeZoneName.String(),
+                                       country, timeZone);
                                zoneItem->SetOutlineLevel(1);
+                               hasUsedCountry = true;
                        }
                        zoneItemMap[fullZoneID] = zoneItem;
 
@@ -399,6 +415,9 @@ TimeZoneView::_BuildZoneMenu()
                                if (regionItemIter != zoneItemMap.end())
                                        
regionItemIter->second->SetExpanded(true);
                        }
+
+                       if (!hasUsedCountry)
+                               delete country;
                }
        }
 
@@ -406,7 +425,7 @@ TimeZoneView::_BuildZoneMenu()
 
        ZoneItemMap::iterator zoneIter;
        bool lastWasCountryItem = false;
-       TimeZoneListItem* currentCountryItem = NULL;
+       TimeZoneListItem* currentItem = NULL;
        for (zoneIter = zoneItemMap.begin(); zoneIter != zoneItemMap.end();
                        ++zoneIter) {
                if (zoneIter->second->OutlineLevel() == 2 && 
lastWasCountryItem) {
@@ -418,17 +437,23 @@ TimeZoneView::_BuildZoneMenu()
                        ++next;
                        if (next != zoneItemMap.end()
                                && next->second->OutlineLevel() != 2) {
-                               fZoneList->RemoveItem(currentCountryItem);
-                               
zoneIter->second->SetText(currentCountryItem->Text());
+                               fZoneList->RemoveItem(currentItem);
+                               zoneIter->second->SetText(currentItem->Text());
+                               
zoneIter->second->SetCountry(currentItem->HasCountry()
+                                       ? new(std::nothrow) 
BCountry(currentItem->Country())
+                                       : NULL);
+                               
zoneIter->second->SetTimeZone(currentItem->HasTimeZone()
+                                       ? new(std::nothrow) 
BTimeZone(currentItem->TimeZone())
+                                       : NULL);
                                zoneIter->second->SetOutlineLevel(1);
-                               delete currentCountryItem;
+                               delete currentItem;
                        }
                }
 
                fZoneList->AddItem(zoneIter->second);
                if (zoneIter->second->OutlineLevel() == 1) {
                        lastWasCountryItem = true;
-                       currentCountryItem = zoneIter->second;
+                       currentItem = zoneIter->second;
                } else
                        lastWasCountryItem = false;
        }

############################################################################

Commit:      7888f1d6eac44d6cb265a13ff2561ef19dc4eb2f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7888f1d
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Dec 13 03:00:51 2013 UTC

Make destructor virtual

----------------------------------------------------------------------------

diff --git a/src/preferences/time/TimeZoneListView.h 
b/src/preferences/time/TimeZoneListView.h
index 7814e84..87c529d 100644
--- a/src/preferences/time/TimeZoneListView.h
+++ b/src/preferences/time/TimeZoneListView.h
@@ -15,7 +15,7 @@
 class TimeZoneListView : public BOutlineListView {
 public:
                                                                
TimeZoneListView(void);
-                                                               
~TimeZoneListView();
+       virtual                                         ~TimeZoneListView();
 
 protected:
        virtual bool                            GetToolTipAt(BPoint point, 
BToolTip** _tip);

############################################################################

Commit:      8f5d92f98d963afd3dcc85609b62189ddaf196a8
URL:         http://cgit.haiku-os.org/haiku/commit/?id=8f5d92f
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Dec 13 06:32:38 2013 UTC

EventDispatcher: Style fixes

----------------------------------------------------------------------------

diff --git a/src/servers/app/EventDispatcher.cpp 
b/src/servers/app/EventDispatcher.cpp
index 9492101..58bfc43 100644
--- a/src/servers/app/EventDispatcher.cpp
+++ b/src/servers/app/EventDispatcher.cpp
@@ -132,8 +132,10 @@ EventTarget::_RemoveTemporaryListener(event_listener* 
listener, int32 index)
        }
 
        if (listener->temporary_event_mask != 0) {
-               ETRACE(("events: clear temp. listener: token %ld, eventMask = 
%ld, options = %ld\n",
-                       listener->token, listener->temporary_event_mask, 
listener->temporary_options));
+               ETRACE(("events: clear temp. listener: token %ld, eventMask = 
%ld, "
+                               "options = %ld\n",
+                       listener->token, listener->temporary_event_mask,
+                       listener->temporary_options));
 
                listener->temporary_event_mask = 0;
                listener->temporary_options = 0;
@@ -230,7 +232,8 @@ EventFilter::RemoveTarget(EventTarget* target)
 
 
 EventDispatcher::EventDispatcher()
-       : BLocker("event dispatcher"),
+       :
+       BLocker("event dispatcher"),
        fStream(NULL),
        fThread(-1),
        fCursorThread(-1),
@@ -390,7 +393,8 @@ EventDispatcher::_AddListener(EventTarget& target, int32 
token,
        if (eventMask == 0)
                return false;
 
-       ETRACE(("events: add listener: token %ld, eventMask = %ld, options = 
%ld, %s\n",
+       ETRACE(("events: add listener: token %ld, eventMask = %ld, options = 
%ld,"
+                       "%s\n",
                token, eventMask, options, temporary ? "temporary" : 
"permanent"));
 
        // we need a new target
@@ -905,8 +909,10 @@ EventDispatcher::_EventLoop()
                                ETRACE(("key event, focus = %p\n", fFocus));
 
                                if (fKeyboardFilter != NULL
-                                       && fKeyboardFilter->Filter(event, 
&fFocus) == B_SKIP_MESSAGE)
+                                       && fKeyboardFilter->Filter(event, 
&fFocus)
+                                               == B_SKIP_MESSAGE) {
                                        break;
+                               }
 
                                keyboardEvent = true;
 
@@ -1007,12 +1013,12 @@ EventDispatcher::_CursorLoop()
        const bigtime_t toolTipDelay = BToolTipManager::Manager()->ShowDelay(); 
        bool mouseIdleSent = true;
        status_t status = B_OK;
-       
+
        while (status != B_ERROR) {
                const bigtime_t timeout = mouseIdleSent ?
                        B_INFINITE_TIMEOUT : toolTipDelay;
                status = fStream->GetNextCursorPosition(where, timeout);
-               
+
                if (status == B_OK) {
                        mouseIdleSent = false;
                        BAutolock _(fCursorLock);
diff --git a/src/servers/app/EventDispatcher.h 
b/src/servers/app/EventDispatcher.h
index 656234d..aff524b 100644
--- a/src/servers/app/EventDispatcher.h
+++ b/src/servers/app/EventDispatcher.h
@@ -106,8 +106,9 @@ class EventDispatcher : public BLocker {
                bool _SendMessage(BMessenger& messenger, BMessage* message,
                                float importance);
 
-               bool _AddTokens(BMessage* message, EventTarget* target, uint32 
eventMask,
-                               BMessage* nextMouseMoved = NULL, int32* 
_viewToken = NULL);
+               bool _AddTokens(BMessage* message, EventTarget* target,
+                               uint32 eventMask, BMessage* nextMouseMoved = 
NULL,
+                               int32* _viewToken = NULL);
                void _RemoveTokens(BMessage* message);
                void _SetFeedFocus(BMessage* message);
                void _UnsetFeedFocus(BMessage* message);

############################################################################

Revision:    hrev46532
Commit:      dd0bdb49dc5d2fdb37f29dd687cd2a406fd34ab7
URL:         http://cgit.haiku-os.org/haiku/commit/?id=dd0bdb4
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Dec 13 07:21:10 2013 UTC

Fix a bug retreiving tooltips

Noticed this in Time prefs was displaying wrong time zone tool tip,
dug deeper...

hrev46290 introduced this bug because it passes fLastCursorPosition
into the “be:view_where” parameter of the B_MOUSE_IDLE message.
The problem is that fLastCursorPosition is in the screen’s coordinate
system, not the view’s and BView expects “be:view_where” to be in the
view’s coordinate system.

So, to fix this I pass fLastCursorPosition in the “screen_where” parameter
instead which I’ve instructed BView to interpret as the point in the screen’s
coordinate system which is then dutifully converted back the the view’s
coordinate system.

I tried to follow the naming scheme of other code, not sure if screen_where
should be namespaced with the be: predicate or not.

----------------------------------------------------------------------------

diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp
index 16200bd..dd7ea8c 100644
--- a/src/kits/interface/View.cpp
+++ b/src/kits/interface/View.cpp
@@ -4324,8 +4324,12 @@ BView::MessageReceived(BMessage* message)
                        case B_MOUSE_IDLE:
                        {
                                BPoint where;
-                               if (message->FindPoint("be:view_where", &where) 
!= B_OK)
-                                       break;
+                               if (message->FindPoint("be:view_where", &where) 
!= B_OK) {
+                                       if (message->FindPoint("screen_where", 
&where) != B_OK)
+                                               break;
+                                       else
+                                               ConvertFromScreen(&where);
+                               }
 
                                BToolTip* tip;
                                if (GetToolTipAt(where, &tip))
diff --git a/src/servers/app/EventDispatcher.cpp 
b/src/servers/app/EventDispatcher.cpp
index 58bfc43..b45f3c9 100644
--- a/src/servers/app/EventDispatcher.cpp
+++ b/src/servers/app/EventDispatcher.cpp
@@ -1028,7 +1028,7 @@ EventDispatcher::_CursorLoop()
                } else if (status == B_TIMED_OUT) {
                        mouseIdleSent = true;
                        BMessage* mouseIdle = new BMessage(B_MOUSE_IDLE);
-                       mouseIdle->AddPoint("be:view_where", 
fLastCursorPosition);
+                       mouseIdle->AddPoint("screen_where", 
fLastCursorPosition);
                        fStream->InsertEvent(mouseIdle);
                }
        }


Other related posts:

  • » [haiku-commits] haiku: hrev46532 - in src: preferences/time preferences/locale servers/app kits/interface - jscipione