MyGUI
3.0.1
|
00001 00007 /* 00008 This file is part of MyGUI. 00009 00010 MyGUI is free software: you can redistribute it and/or modify 00011 it under the terms of the GNU Lesser General Public License as published by 00012 the Free Software Foundation, either version 3 of the License, or 00013 (at your option) any later version. 00014 00015 MyGUI is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public License 00021 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 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() const { 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 /*internal:*/ 00122 virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _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::ListCtrl* _sender, MyGUI::Widget* _item); 00134 void notifyDrawItem(MyGUI::ListCtrl* _sender, MyGUI::Widget* _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 } // namespace MyGUI 00146 00147 #endif // __MYGUI_LIST_BOX_H__