|
@@ -53,8 +53,9 @@ public:
|
|
~GuiListBoxCtrl();
|
|
~GuiListBoxCtrl();
|
|
DECLARE_CONOBJECT(GuiListBoxCtrl);
|
|
DECLARE_CONOBJECT(GuiListBoxCtrl);
|
|
|
|
|
|
- struct LBItem
|
|
|
|
|
|
+ class LBItem
|
|
{
|
|
{
|
|
|
|
+ public:
|
|
StringTableEntry itemText;
|
|
StringTableEntry itemText;
|
|
bool isSelected;
|
|
bool isSelected;
|
|
bool isActive;
|
|
bool isActive;
|
|
@@ -62,6 +63,27 @@ public:
|
|
void* itemData;
|
|
void* itemData;
|
|
ColorF color;
|
|
ColorF color;
|
|
bool hasColor;
|
|
bool hasColor;
|
|
|
|
+
|
|
|
|
+ static bool sIncreasing;
|
|
|
|
+
|
|
|
|
+ // Compare Functions
|
|
|
|
+ static bool compByID(const LBItem *a, const LBItem *b)
|
|
|
|
+ {
|
|
|
|
+ bool res = a->ID < b->ID;
|
|
|
|
+ return (sIncreasing ? res : !res);
|
|
|
|
+ }
|
|
|
|
+ static bool compByText(const LBItem *a, const LBItem *b)
|
|
|
|
+ {
|
|
|
|
+ char buf[512];
|
|
|
|
+ char bufB[512];
|
|
|
|
+
|
|
|
|
+ dSprintf(buf, 512, "%s", a->itemText);
|
|
|
|
+ dSprintf(bufB, 512, "%s", b->itemText);
|
|
|
|
+
|
|
|
|
+ S32 res = dStricmp(buf, bufB);
|
|
|
|
+ bool result = res <= 0;
|
|
|
|
+ return (sIncreasing ? result : !result);
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
VectorPtr<LBItem*> mItems;
|
|
VectorPtr<LBItem*> mItems;
|
|
@@ -71,6 +93,8 @@ public:
|
|
bool mFitParentWidth;
|
|
bool mFitParentWidth;
|
|
LBItem* mLastClickItem;
|
|
LBItem* mLastClickItem;
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
// Persistence
|
|
// Persistence
|
|
static void initPersistFields();
|
|
static void initPersistFields();
|
|
|
|
|
|
@@ -130,6 +154,11 @@ public:
|
|
// Mouse Events
|
|
// Mouse Events
|
|
virtual void onTouchDown( const GuiEvent &event );
|
|
virtual void onTouchDown( const GuiEvent &event );
|
|
virtual void onTouchDragged(const GuiEvent &event);
|
|
virtual void onTouchDragged(const GuiEvent &event);
|
|
|
|
+
|
|
|
|
+ // Sorting
|
|
|
|
+ virtual void sortByText(bool increasing = true);
|
|
|
|
+ virtual void sortByID(bool increasing = true);
|
|
|
|
+
|
|
protected:
|
|
protected:
|
|
GuiControl *caller;
|
|
GuiControl *caller;
|
|
};
|
|
};
|