00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _CEGUIItemListBase_h_
00031 #define _CEGUIItemListBase_h_
00032
00033 #include "CEGUIBase.h"
00034 #include "CEGUIWindow.h"
00035 #include "elements/CEGUIItemListBaseProperties.h"
00036 #include "elements/CEGUIItemEntry.h"
00037
00038 #include <vector>
00039
00040
00041 #if defined(_MSC_VER)
00042 # pragma warning(push)
00043 # pragma warning(disable : 4251)
00044 #endif
00045
00046
00047
00048 namespace CEGUI
00049 {
00050
00055 class CEGUIEXPORT ItemListBaseWindowRenderer : public WindowRenderer
00056 {
00057 public:
00062 ItemListBaseWindowRenderer(const String& name);
00063
00073 virtual Rect getItemRenderArea(void) const = 0;
00074 };
00075
00080 class CEGUIEXPORT ItemListBase : public Window
00081 {
00082 public:
00083 static const String EventNamespace;
00084
00089 enum SortMode
00090 {
00091 Ascending,
00092 Descending,
00093 UserSort
00094 };
00095
00097 typedef bool (*SortCallback)(const ItemEntry* a, const ItemEntry* b);
00098
00099
00100
00101
00102
00103 static const String EventListContentsChanged;
00104 static const String EventSortEnabledChanged;
00105 static const String EventSortModeChanged;
00106
00107
00108
00109
00117 size_t getItemCount(void) const {return d_listItems.size();}
00118
00119
00132 ItemEntry* getItemFromIndex(size_t index) const;
00133
00134
00147 size_t getItemIndex(const ItemEntry* item) const;
00148
00149
00167 ItemEntry* findItemWithText(const String& text, const ItemEntry* start_item);
00168
00169
00177 bool isItemInList(const ItemEntry* item) const;
00178
00179
00187 bool isAutoResizeEnabled() const {return d_autoResize;}
00188
00189
00194 bool isSortEnabled(void) const {return d_sortEnabled;}
00195
00196
00201 SortMode getSortMode(void) const {return d_sortMode;}
00202
00203
00208 SortCallback getSortCallback(void) const {return d_sortCallback;}
00209
00210
00211
00212
00223 virtual void initialiseComponents(void);
00224
00225
00232 void resetList(void);
00233
00234
00246 void addItem(ItemEntry* item);
00247
00248
00266 void insertItem(ItemEntry* item, const ItemEntry* position);
00267
00268
00280 void removeItem(ItemEntry* item);
00281
00282
00298 void handleUpdatedItemData(bool resort=false);
00299
00300
00311 void setAutoResizeEnabled(bool setting);
00312
00313
00323 virtual void sizeToContent(void) {sizeToContent_impl();}
00324
00325
00331 virtual void endInitialisation(void);
00332
00333
00344 virtual void performChildWindowLayout(void);
00345
00346
00356 Rect getItemRenderArea(void) const;
00357
00366 Window* getContentPane(void) const {return d_pane;}
00367
00373 virtual void notifyItemClicked(ItemEntry* li) {}
00374
00380 virtual void notifyItemSelectState(ItemEntry* li, bool state) {}
00381
00386 void setSortEnabled(bool setting);
00387
00394 void setSortMode(SortMode mode);
00395
00403 void setSortCallback(SortCallback cb);
00404
00416 void sortList(bool relayout=true);
00417
00418
00419
00420
00425 ItemListBase(const String& type, const String& name);
00426
00427
00432 virtual ~ItemListBase(void);
00433
00434
00435 protected:
00436
00437
00438
00448 virtual void sizeToContent_impl(void);
00449
00450
00458 virtual Size getContentSize() const = 0;
00459
00460
00470
00471
00472
00480 virtual void layoutItemWidgets() = 0;
00481
00482
00483
00484
00485
00497 bool resetList_impl(void);
00498
00509 virtual bool testClassName_impl(const String& class_name) const
00510 {
00511 if (class_name=="ItemListBase") return true;
00512 return Window::testClassName_impl(class_name);
00513 }
00514
00515
00516 virtual bool validateWindowRenderer(const String& name) const
00517 {
00518 return (name == EventNamespace);
00519 }
00520
00525 SortCallback getRealSortCallback(void) const;
00526
00527
00528
00529
00534 virtual void onListContentsChanged(WindowEventArgs& e);
00535
00540 virtual void onSortEnabledChanged(WindowEventArgs& e);
00541
00546 virtual void onSortModeChanged(WindowEventArgs& e);
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558 typedef std::vector<ItemEntry*> ItemEntryList;
00559 ItemEntryList d_listItems;
00560
00562 bool d_autoResize;
00563
00565 Window* d_pane;
00566
00568 bool d_sortEnabled;
00570 SortMode d_sortMode;
00572 SortCallback d_sortCallback;
00574 bool d_resort;
00575
00576 private:
00577
00578
00579
00580 static ItemListBaseProperties::AutoResizeEnabled d_autoResizeEnabledProperty;
00581 static ItemListBaseProperties::SortEnabled d_sortEnabledProperty;
00582 static ItemListBaseProperties::SortMode d_sortModeProperty;
00583
00584
00585
00586
00587 void addItemListBaseProperties(void);
00588
00589
00594 virtual void addChild_impl(Window* wnd);
00595
00601 bool handle_PaneChildRemoved(const EventArgs& e);
00602 };
00603
00604 }
00605
00606
00607 #if defined(_MSC_VER)
00608 # pragma warning(pop)
00609 #endif
00610
00611 #endif // end of guard _CEGUIItemListBase_h_