29 #ifndef _CEGUIItemListBase_h_
30 #define _CEGUIItemListBase_h_
33 #include "../Window.h"
34 #include "./ItemEntry.h"
40 # pragma warning(push)
41 # pragma warning(disable : 4251)
53 class CEGUIEXPORT ItemListBaseWindowRenderer :
public WindowRenderer
60 ItemListBaseWindowRenderer(
const String& name);
71 virtual Rectf getItemRenderArea(
void)
const = 0;
78 class CEGUIEXPORT ItemListBase :
public Window
81 static const String EventNamespace;
95 typedef bool (*SortCallback)(
const ItemEntry* a,
const ItemEntry* b);
106 static const String EventListContentsChanged;
112 static const String EventSortEnabledChanged;
118 static const String EventSortModeChanged;
130 size_t getItemCount(
void)
const {
return d_listItems.
size();}
145 ItemEntry* getItemFromIndex(
size_t index)
const;
160 size_t getItemIndex(
const ItemEntry* item)
const;
190 bool isItemInList(
const ItemEntry* item)
const;
200 bool isAutoResizeEnabled()
const {
return d_autoResize;}
207 bool isSortEnabled(
void)
const {
return d_sortEnabled;}
214 SortMode getSortMode(
void)
const {
return d_sortMode;}
221 SortCallback getSortCallback(
void)
const {
return d_sortCallback;}
236 virtual void initialiseComponents(
void);
245 void resetList(
void);
259 void addItem(ItemEntry* item);
281 void insertItem(ItemEntry* item,
const ItemEntry* position);
295 void removeItem(ItemEntry* item);
313 void handleUpdatedItemData(
bool resort=
false);
326 void setAutoResizeEnabled(
bool setting);
338 virtual void sizeToContent(
void) {sizeToContent_impl();}
346 virtual void endInitialisation(
void);
350 void performChildWindowLayout(
bool nonclient_sized_hint =
false,
351 bool client_sized_hint =
false);
363 Rectf getItemRenderArea(
void)
const;
373 Window* getContentPane(
void)
const {
return d_pane;}
380 virtual void notifyItemClicked(ItemEntry*) {}
387 virtual void notifyItemSelectState(ItemEntry*,
bool) {}
393 void setSortEnabled(
bool setting);
401 void setSortMode(SortMode mode);
410 void setSortCallback(SortCallback cb);
423 void sortList(
bool relayout=
true);
432 ItemListBase(
const String& type,
const String& name);
439 virtual ~ItemListBase(
void);
455 virtual void sizeToContent_impl(
void);
465 virtual Sizef getContentSize()
const = 0;
487 virtual void layoutItemWidgets() = 0;
504 bool resetList_impl(
void);
507 virtual bool validateWindowRenderer(
const WindowRenderer* renderer)
const;
513 SortCallback getRealSortCallback(
void)
const;
522 virtual void onListContentsChanged(WindowEventArgs& e);
528 virtual void onSortEnabledChanged(WindowEventArgs& e);
534 virtual void onSortModeChanged(WindowEventArgs& e);
539 virtual void onParentSized(ElementEventArgs& e);
553 virtual bool handle_PaneChildRemoved(
const EventArgs& e);
558 typedef std::vector<ItemEntry*
559 CEGUI_VECTOR_ALLOC(ItemEntry*)> ItemEntryList;
560 ItemEntryList d_listItems;
573 SortCallback d_sortCallback;
581 void addItemListBaseProperties(
void);
587 virtual void addChild_impl(
Element* element);
596 typedef return_type safe_method_return_type;
598 typedef String string_return_type;
600 static const String& getDataTypeName()
602 static String type(
"SortMode");
607 static return_type fromString(
const String& str)
609 if (str ==
"Ascending")
611 return ItemListBase::Ascending;
613 else if (str ==
"Descending")
615 return ItemListBase::Descending;
619 return ItemListBase::UserSort;
623 static string_return_type toString(pass_type val)
625 if (val == ItemListBase::UserSort)
629 else if (val == ItemListBase::Ascending)
633 else if (val == ItemListBase::Descending)
639 assert(
false &&
"Invalid sort mode");
649 #if defined(_MSC_VER)
650 # pragma warning(pop)
653 #endif // end of guard _CEGUIItemListBase_h_