00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MYGUI_LIST_BOX_H__
00024 #define __MYGUI_LIST_BOX_H__
00025
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_ListCtrl.h"
00028
00029 namespace MyGUI
00030 {
00031
00032 class MYGUI_EXPORT ListBox :
00033 public ListCtrl
00034 {
00035 MYGUI_RTTI_DERIVED( ListBox );
00036
00037 public:
00038 ListBox();
00039
00040
00041
00042
00044 size_t getItemCount() { return mItemsInfo.size(); }
00045
00047 void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
00048
00050 void addItem(const UString& _name, Any _data = Any::Null) { insertItemAt(ITEM_NONE, _name, _data); }
00051
00053 void removeItemAt(size_t _index);
00054
00056 void removeAllItems();
00057
00059 void swapItemsAt(size_t _index1, size_t _index2);
00060
00062 size_t findItemIndexWith(const UString& _name);
00063
00064
00065
00066
00067
00069 size_t getIndexSelected() { return Base::getIndexSelected(); }
00070
00072 void setIndexSelected(size_t _index) { Base::setIndexSelected(_index); }
00073
00075 void clearIndexSelected() { Base::clearIndexSelected(); }
00076
00077
00078
00079
00080
00082 void setItemDataAt(size_t _index, Any _data) { Base::setItemDataAt(_index, _data); }
00083
00085 void clearItemDataAt(size_t _index) { Base::clearItemDataAt(_index); }
00086
00088 template <typename ValueType>
00089 ValueType * getItemDataAt(size_t _index, bool _throw = true)
00090 {
00091 return Base::getItemDataAt<ValueType>(_index, _throw);
00092 }
00093
00094
00095
00096
00097
00099 void setItemNameAt(size_t _index, const UString& _name);
00100
00102 const UString& getItemNameAt(size_t _index);
00103
00104
00105
00106
00107
00109 void beginToItemAt(size_t _index);
00110
00112 void beginToItemFirst() { if (getItemCount()) beginToItemAt(0); }
00113
00115 void beginToItemLast() { if (getItemCount()) beginToItemAt(getItemCount() - 1); }
00116
00118 void beginToItemSelected() { if (getIndexSelected() != ITEM_NONE) beginToItemAt(getIndexSelected()); }
00119
00120
00121
00122 virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, WidgetPtr _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
00123
00124 protected:
00125 virtual ~ListBox();
00126
00127 void baseChangeWidgetSkin(ResourceSkin* _info);
00128
00129 private:
00130 void initialiseWidgetSkin(ResourceSkin* _info);
00131 void shutdownWidgetSkin();
00132
00133 void notifyCreateWidgetItem(MyGUI::ListCtrlPtr _sender, MyGUI::WidgetPtr _item);
00134 void notifyDrawItem(MyGUI::ListCtrlPtr _sender, MyGUI::WidgetPtr _item, const MyGUI::IBDrawItemInfo& _info, MyGUI::IntCoord& _coord);
00135
00136 private:
00137 std::string mSkinLine;
00138 int mHeightLine;
00139
00140 typedef std::vector<UString> VectorUTFString;
00141 VectorUTFString mItemsInfo;
00142
00143 };
00144
00145 }
00146
00147 #endif // __MYGUI_LIST_BOX_H__