From 29a98dd656ba3c3bcb3c9813b6d83166fe0e6620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Mon, 20 Dec 2010 22:00:04 +0000 Subject: [PATCH] Applied patch from Karvjorm, adapted by myself (#7004): Fills empty methods in BIconRule and uses BObjectList instead of BList. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39903 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/notifications/IconRule.cpp | 24 ++++++++++++---------- src/preferences/notifications/IconRule.h | 9 ++++++-- src/preferences/notifications/Jamfile | 2 ++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/preferences/notifications/IconRule.cpp b/src/preferences/notifications/IconRule.cpp index 75b2502cf7..89eaf08c32 100644 --- a/src/preferences/notifications/IconRule.cpp +++ b/src/preferences/notifications/IconRule.cpp @@ -12,10 +12,8 @@ #include #include #include -#include #include "IconRule.h" -#include "IconItem.h" const int32 kEdgeOffset = 8; const int32 kBorderOffset = 1; @@ -27,13 +25,11 @@ BIconRule::BIconRule(const char* name) BView(name, B_WILL_DRAW), fSelIndex(-1) { - fIcons = new BList(); } BIconRule::~BIconRule() { - delete fIcons; } @@ -115,7 +111,7 @@ BIconRule::Draw(BRect updateRect) BRect itemFrame(kEdgeOffset, kBorderOffset, -1, kBorderOffset + 64); for (int32 i = 0; i < count; i++) { - BIconItem* item = static_cast(fIcons->ItemAt(i)); + BIconItem* item = fIcons.ItemAt(i); float width = StringWidth(item->Label()) + StringWidth(" ") * 2; if (width < 64.0f) width = 64.0f; @@ -154,26 +150,32 @@ BIconRule::AddIcon(const char* label, const BBitmap* icon) item->Select(); fSelIndex = 0; } - (void)fIcons->AddItem(item); + fIcons.AddItem(item); } void BIconRule::RemoveIconAt(int32 index) { + int32 count = fIcons.CountItems(); + if (index < count && index >= (int32)0) + fIcons.RemoveItemAt((int32)index); } void BIconRule::RemoveAllIcons() { + int32 count = fIcons.CountItems(); + for (int32 i = 0; i < count; i++) + fIcons.RemoveItemAt(i); } int32 BIconRule::CountIcons() const { - return fIcons->CountItems(); + return fIcons.CountItems(); } @@ -184,11 +186,11 @@ BIconRule::SlideToIcon(int32 index) if ((index < 0) || (index > CountIcons() - 1)) return; - BIconItem* item = static_cast(fIcons->ItemAt(index)); + BIconItem* item = fIcons.ItemAt(index); if (item) { // Deselect previously selected item if (fSelIndex > -1) { - BIconItem* selItem = static_cast(fIcons->ItemAt(fSelIndex)); + BIconItem* selItem = fIcons.ItemAt(fSelIndex); selItem->Deselect(); } @@ -225,7 +227,7 @@ int32 BIconRule::IndexOf(BPoint point) { int32 low = 0; - int32 high = fIcons->CountItems() - 1; + int32 high = fIcons.CountItems() - 1; int32 mid = -1; float frameLeft = -1.0f; float frameRight = 1.0f; @@ -233,7 +235,7 @@ BIconRule::IndexOf(BPoint point) // Binary search the list while (high >= low) { mid = (low + high) / 2; - BIconItem* item = static_cast(fIcons->ItemAt(mid)); + BIconItem* item = fIcons.ItemAt(mid); frameLeft = item->Frame().left; frameRight = item->Frame().right; if (point.x < frameLeft) diff --git a/src/preferences/notifications/IconRule.h b/src/preferences/notifications/IconRule.h index 5939892240..acfc983cc5 100644 --- a/src/preferences/notifications/IconRule.h +++ b/src/preferences/notifications/IconRule.h @@ -6,10 +6,14 @@ #ifndef _ICON_RULE_H #define _ICON_RULE_H + #include +#include #include -class BList; +#include "IconItem.h" + + class BMessage; class BIconRule : public BView, public BInvoker { @@ -44,7 +48,8 @@ public: virtual BSize PreferredSize(); private: - BList* fIcons; + typedef BObjectList IconItems; + IconItems fIcons; int32 fSelIndex; BMessage* fMessage; }; diff --git a/src/preferences/notifications/Jamfile b/src/preferences/notifications/Jamfile index 48ad097c1f..43805cde33 100644 --- a/src/preferences/notifications/Jamfile +++ b/src/preferences/notifications/Jamfile @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src preferences notifications ; +UsePrivateHeaders shared ; + UsePrivateHeaders interface ; Application Notifications :