MyGUI  3.0.1
MyGUI_ListBox.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 #ifndef __MYGUI_LIST_BOX_H__
24 #define __MYGUI_LIST_BOX_H__
25 
26 #include "MyGUI_Prerequest.h"
27 #include "MyGUI_ListCtrl.h"
28 
29 namespace MyGUI
30 {
31 
33  public ListCtrl
34  {
36 
37  public:
38  ListBox();
39 
40  //------------------------------------------------------------------------------//
41  // манипуляции айтемами
42 
44  size_t getItemCount() const { return mItemsInfo.size(); }
45 
47  void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
48 
50  void addItem(const UString& _name, Any _data = Any::Null) { insertItemAt(ITEM_NONE, _name, _data); }
51 
53  void removeItemAt(size_t _index);
54 
56  void removeAllItems();
57 
59  void swapItemsAt(size_t _index1, size_t _index2);
60 
62  size_t findItemIndexWith(const UString& _name);
63 
64 
65  //------------------------------------------------------------------------------//
66  // манипуляции выделениями
67 
69  size_t getIndexSelected() { return Base::getIndexSelected(); }
70 
72  void setIndexSelected(size_t _index) { Base::setIndexSelected(_index); }
73 
75  void clearIndexSelected() { Base::clearIndexSelected(); }
76 
77 
78  //------------------------------------------------------------------------------//
79  // манипуляции данными
80 
82  void setItemDataAt(size_t _index, Any _data) { Base::setItemDataAt(_index, _data); }
83 
85  void clearItemDataAt(size_t _index) { Base::clearItemDataAt(_index); }
86 
88  template <typename ValueType>
89  ValueType * getItemDataAt(size_t _index, bool _throw = true)
90  {
91  return Base::getItemDataAt<ValueType>(_index, _throw);
92  }
93 
94 
95  //------------------------------------------------------------------------------//
96  // манипуляции отображением
97 
99  void setItemNameAt(size_t _index, const UString& _name);
100 
102  const UString& getItemNameAt(size_t _index);
103 
104 
105  //------------------------------------------------------------------------------//
106  // манипуляции выдимостью
107 
109  void beginToItemAt(size_t _index);
110 
112  void beginToItemFirst() { if (getItemCount()) beginToItemAt(0); }
113 
115  void beginToItemLast() { if (getItemCount()) beginToItemAt(getItemCount() - 1); }
116 
118  void beginToItemSelected() { if (getIndexSelected() != ITEM_NONE) beginToItemAt(getIndexSelected()); }
119 
120 
121  /*internal:*/
122  virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
123 
124  protected:
125  virtual ~ListBox();
126 
127  void baseChangeWidgetSkin(ResourceSkin* _info);
128 
129  private:
130  void initialiseWidgetSkin(ResourceSkin* _info);
131  void shutdownWidgetSkin();
132 
133  void notifyCreateWidgetItem(MyGUI::ListCtrl* _sender, MyGUI::Widget* _item);
134  void notifyDrawItem(MyGUI::ListCtrl* _sender, MyGUI::Widget* _item, const MyGUI::IBDrawItemInfo& _info, MyGUI::IntCoord& _coord);
135 
136  private:
137  std::string mSkinLine;
138  int mHeightLine;
139 
140  typedef std::vector<UString> VectorUTFString;
141  VectorUTFString mItemsInfo;
142 
143  };
144 
145 } // namespace MyGUI
146 
147 #endif // __MYGUI_LIST_BOX_H__