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
00268 void insertItem(ItemEntry* item, const ItemEntry* position);
00269
00270
00282 void removeItem(ItemEntry* item);
00283
00284
00300 void handleUpdatedItemData(bool resort=false);
00301
00302
00313 void setAutoResizeEnabled(bool setting);
00314
00315
00325 virtual void sizeToContent(void) {sizeToContent_impl();}
00326
00327
00333 virtual void endInitialisation(void);
00334
00335
00346 virtual void performChildWindowLayout(void);
00347
00348
00358 Rect getItemRenderArea(void) const;
00359
00368 Window* getContentPane(void) const {return d_pane;}
00369
00375 virtual void notifyItemClicked(ItemEntry* li) {}
00376
00382 virtual void notifyItemSelectState(ItemEntry* li, bool state) {}
00383
00388 void setSortEnabled(bool setting);
00389
00396 void setSortMode(SortMode mode);
00397
00405 void setSortCallback(SortCallback cb);
00406
00418 void sortList(bool relayout=true);
00419
00420
00421
00422
00427 ItemListBase(const String& type, const String& name);
00428
00429
00434 virtual ~ItemListBase(void);
00435
00436
00437 protected:
00438
00439
00440
00450 virtual void sizeToContent_impl(void);
00451
00452
00460 virtual Size getContentSize() const = 0;
00461
00462
00472
00473
00474
00482 virtual void layoutItemWidgets() = 0;
00483
00484
00485
00486
00487
00499 bool resetList_impl(void);
00500
00511 virtual bool testClassName_impl(const String& class_name) const
00512 {
00513 if (class_name=="ItemListBase") return true;
00514 return Window::testClassName_impl(class_name);
00515 }
00516
00517
00518 virtual bool validateWindowRenderer(const String& name) const
00519 {
00520 return (name == EventNamespace);
00521 }
00522
00527 SortCallback getRealSortCallback(void) const;
00528
00529
00530
00531
00536 virtual void onListContentsChanged(WindowEventArgs& e);
00537
00542 virtual void onSortEnabledChanged(WindowEventArgs& e);
00543
00548 virtual void onSortModeChanged(WindowEventArgs& e);
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560 typedef std::vector<ItemEntry*> ItemEntryList;
00561 ItemEntryList d_listItems;
00562
00564 bool d_autoResize;
00565
00567 Window* d_pane;
00568
00570 bool d_sortEnabled;
00572 SortMode d_sortMode;
00574 SortCallback d_sortCallback;
00576 bool d_resort;
00577
00578 private:
00579
00580
00581
00582 static ItemListBaseProperties::AutoResizeEnabled d_autoResizeEnabledProperty;
00583 static ItemListBaseProperties::SortEnabled d_sortEnabledProperty;
00584 static ItemListBaseProperties::SortMode d_sortModeProperty;
00585
00586
00587
00588
00589 void addItemListBaseProperties(void);
00590
00591
00596 virtual void addChild_impl(Window* wnd);
00597
00603 bool handle_PaneChildRemoved(const EventArgs& e);
00604 };
00605
00606 }
00607
00608
00609 #if defined(_MSC_VER)
00610 # pragma warning(pop)
00611 #endif
00612
00613 #endif // end of guard _CEGUIItemListBase_h_