MyGUI: MyGUI_MultiListBox.h Source File

MyGUI 3.2.2

MyGUI_MultiListBox.h
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #ifndef MYGUI_MULTI_LIST_BOX_H_
8 #define MYGUI_MULTI_LIST_BOX_H_
9
10 #include "MyGUI_Prerequest.h"
11 #include "MyGUI_Widget.h"
12 #include "MyGUI_ListBox.h"
13 #include "MyGUI_Any.h"
14 #include "MyGUI_BiIndexBase.h"
15 #include "MyGUI_EventPair.h"
16 #include "MyGUI_IItem.h"
17 #include "MyGUI_IItemContainer.h"
18 #include "MyGUI_ResizingPolicy.h"
19
20 namespace MyGUI
21 {
22
23 //OBSOLETE
24 typedef delegates::CMultiDelegate5<Widget*, size_t, const UString&, const UString&, bool&> EventHandle_WidgetIntUTFStringUTFStringBool;
25
26 typedef delegates::CDelegate5<MultiListBox*, size_t, const UString&, const UString&, bool&> EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef;
27 typedef delegates::CMultiDelegate2<MultiListBox*, size_t> EventHandle_MultiListPtrSizeT;
28
32 class MYGUI_EXPORT MultiListBox :
33 public Widget,
34 public BiIndexBase,
35 public IItemContainer,
36 public MemberObsolete<MultiListBox>
37 {
38 MYGUI_RTTI_DERIVED( MultiListBox )
39
40 public:
41 MultiListBox();
42
44 virtual void setPosition(const IntPoint& _value);
46 virtual void setSize(const IntSize& _value);
48 virtual void setCoord(const IntCoord& _value);
49
51 void setPosition(int _left, int _top);
53 void setSize(int _width, int _height);
55 void setCoord(int _left, int _top, int _width, int _height);
56
57 //------------------------------------------------------------------------------//
58 // Methods for work with columns (RU:методы для работы со столбцами)
59 //------------------------------------------------------------------------------//
60 // манипуляции айтемами
61
63 size_t getColumnCount() const;
64
71 void insertColumnAt(size_t _column, const UString& _name, int _width = 0, Any _data = Any::Null);
72
78 void addColumn(const UString& _name, int _width = 0, Any _data = Any::Null);
79
81 void removeColumnAt(size_t _column);
82
84 void removeAllColumns();
85
87 void swapColumnsAt(size_t _index1, size_t _index2);
88
89 //------------------------------------------------------------------------------//
90 // манипуляции отображением
91
96 void setColumnNameAt(size_t _column, const UString& _name);
97
102 void setColumnName(MultiListItem* _item, const UString& _name);
103
108 void setColumnWidthAt(size_t _column, int _width);
109
114 void setColumnWidth(MultiListItem* _item, int _width);
115
117 const UString& getColumnNameAt(size_t _column);
118
120 const UString& getColumnName(MultiListItem* _item);
121
123 int getColumnWidthAt(size_t _column);
124
126 void sortByColumn(size_t _column, bool _backward = false);
127
129 size_t getColumnIndex(MultiListItem* _item);
130
135 void setColumnResizingPolicy(MultiListItem* _item, ResizingPolicy _value);
140 void setColumnResizingPolicyAt(size_t _index, ResizingPolicy _value);
141
142 //------------------------------------------------------------------------------//
143 // манипуляции данными
144
146 void setColumnDataAt(size_t _index, Any _data);
147
149 void clearColumnDataAt(size_t _index);
150
152 template <typename ValueType>
153 ValueType* getColumnDataAt(size_t _index, bool _throw = true)
154 {
155 MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.size(), "MultiListBox::getItemDataAt");
156 return mVectorColumnInfo[_index].data.castType<ValueType>(_throw);
157 }
158
159 //------------------------------------------------------------------------------//
160 // Methods for work with lines (RU:методы для работы со строками)
166 //------------------------------------------------------------------------------//
167 // манипуляции айтемами
168
170 size_t getItemCount() const;
171
173 void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
174
176 void addItem(const UString& _name, Any _data = Any::Null);
177
179 void removeItemAt(size_t _index);
180
182 void removeAllItems();
183
185 void swapItemsAt(size_t _index1, size_t _index2);
186
187
188 //------------------------------------------------------------------------------//
189 // манипуляции отображением
190
192 void setItemNameAt(size_t _index, const UString& _name);
193
195 const UString& getItemNameAt(size_t _index);
196
197
198 //------------------------------------------------------------------------------//
199 // манипуляции выделениями
200
202 size_t getIndexSelected() const;
203
205 void setIndexSelected(size_t _index);
206
208 void clearIndexSelected();
209
210
211 //------------------------------------------------------------------------------//
212 // манипуляции данными
213
215 void setItemDataAt(size_t _index, Any _data);
216
218 void clearItemDataAt(size_t _index);
219
221 template <typename ValueType>
222 ValueType* getItemDataAt(size_t _index, bool _throw = true)
223 {
224 return getSubItemDataAt<ValueType>(0, _index, _throw);
225 }
226
227
228 //------------------------------------------------------------------------------//
229 // Methods for work with sub lines (RU:методы для работы со саб строками)
230 //------------------------------------------------------------------------------//
231 // манипуляции данными
232
238 void setSubItemNameAt(size_t _column, size_t _index, const UString& _name);
239
241 const UString& getSubItemNameAt(size_t _column, size_t _index);
242
244 size_t findSubItemWith(size_t _column, const UString& _name);
245
246 //------------------------------------------------------------------------------//
247 // манипуляции данными
248
250 void setSubItemDataAt(size_t _column, size_t _index, Any _data);
251
253 void clearSubItemDataAt(size_t _column, size_t _index);
254
256 template <typename ValueType>
257 ValueType* getSubItemDataAt(size_t _column, size_t _index, bool _throw = true)
258 {
259 MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.begin()->list->getItemCount(), "MultiListBox::getSubItemDataAt");
260
261 size_t index = BiIndexBase::convertToBack(_index);
262 return getSubItemAt(_column)->getItemDataAt<ValueType>(index, _throw);
263 }
264
265 /*events:*/
271 EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT> eventListSelectAccept;
272
278 EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT> eventListChangePosition;
279
288 EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef requestOperatorLess;
289
290 /*internal:*/
291 // IItemContainer impl
292 virtual size_t _getItemCount();
293 virtual void _addItem(const MyGUI::UString& _name);
294 virtual void _removeItemAt(size_t _index);
295 virtual Widget* _getItemAt(size_t _index);
296 virtual void _setItemNameAt(size_t _index, const UString& _name);
297 virtual const UString& _getItemNameAt(size_t _index);
298
299 protected:
300 virtual void initialiseOverride();
301 virtual void shutdownOverride();
302
303 virtual void onWidgetCreated(Widget* _widget);
304 virtual void onWidgetDestroy(Widget* _widget);
305
306 private:
307 void notifyListChangePosition(ListBox* _sender, size_t _position);
308 void notifyListChangeFocus(ListBox* _sender, size_t _position);
309 void notifyListChangeScrollPosition(ListBox* _sender, size_t _position);
310 void notifyButtonClick(Widget* _sender);
311 void notifyListSelectAccept(ListBox* _sender, size_t _position);
312
313 void updateColumns();
314 void redrawButtons();
315 void updateOnlyEmpty();
316
317 bool compare(ListBox* _list, size_t _left, size_t _right);
318 void sortList();
319 void flipList();
320
321 Widget* getSeparator(size_t _index);
322
323 void updateBackSelected(size_t _index);
324
325 struct ColumnInfo
326 {
327 MultiListItem* item;
328 ListBox* list;
329 Button* button;
330 int width;
331 int realWidth;
332 UString name;
333 Any data;
334 ResizingPolicy sizeType;
335 };
336
337 typedef std::vector<ColumnInfo> VectorColumnInfo;
338
339 void frameEntered(float _frame);
340 void frameAdvise(bool _advise);
341
342 ListBox* getSubItemAt(size_t _column);
343 int getButtonHeight() const;
344
345 void _wrapItem(MultiListItem* _item);
346 void _unwrapItem(MultiListItem* _item);
347 void _swapColumnsAt(size_t _index1, size_t _index2);
348
349 int getColumnWidth(size_t _index, int _freeSpace, size_t _countStars, size_t _lastIndexStar, int _starWidth) const;
350 bool getUpdateByResize();
351 int updateWidthColumns(size_t& _countStars, size_t& _lastIndexStar);
352
353 private:
354 int mHeightButton;
355 int mWidthBar;
356 std::string mSkinButton;
357 std::string mSkinList;
358 Widget* mWidgetEmpty;
359
360 VectorColumnInfo mVectorColumnInfo;
361
362 VectorWidgetPtr mSeparators;
363
364 size_t mLastMouseFocusIndex;
365
366 bool mSortUp;
367 size_t mSortColumnIndex;
368
369 int mWidthSeparator;
370 std::string mSkinSeparator;
371
372 size_t mItemSelected;
373
374 bool mFrameAdvise;
375 Widget* mClient;
376 Widget* mHeaderPlace;
377 };
378
379 } // namespace MyGUI
380
381 #endif // MYGUI_MULTI_LIST_BOX_H_
MyGUI::IItemContainer
Definition: MyGUI_IItemContainer.h:18
MyGUI::MultiListItem
MultiListItem properties. Skin childs. MultiListItem widget description should be here.
Definition: MyGUI_MultiListItem.h:21
MyGUI::ListBox
ListBox properties. Skin childs. ListBox widget description should be here.
Definition: MyGUI_ListBox.h:27
MyGUI::MultiListBox::eventListChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT > eventListChangePosition
Definition: MyGUI_MultiListBox.h:278
MyGUI_Widget.h
MyGUI_BiIndexBase.h
MyGUI_EventPair.h
MyGUI_ResizingPolicy.h
MyGUI_ListBox.h
MyGUI::MultiListBox::requestOperatorLess
EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef requestOperatorLess
Definition: MyGUI_MultiListBox.h:288
MYGUI_ASSERT_RANGE
#define MYGUI_ASSERT_RANGE(index, size, owner)
Definition: MyGUI_Diagnostic.h:54
MyGUI::MultiListBox
MultiListBox properties. Skin childs. MultiListBox widget description should be here.
Definition: MyGUI_MultiListBox.h:32
MyGUI::Widget
Widget properties. Skin childs. Widget widget description should be here.
Definition: MyGUI_Widget.h:29
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition: MyGUI_WidgetDefines.h:19
MyGUI::BiIndexBase::convertToBack
size_t convertToBack(size_t _index) const
Definition: MyGUI_BiIndexBase.cpp:109
MyGUI::MultiListBox::getColumnDataAt
ValueType * getColumnDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition: MyGUI_MultiListBox.h:153
MyGUI_IItemContainer.h
MyGUI::types::TPoint< int >
MyGUI::Any
Definition: MyGUI_Any.h:63
MyGUI::Button
Button properties. Skin childs. Button widget description should be here.
Definition: MyGUI_Button.h:19
MyGUI::EventPair< EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT >
MyGUI::EventHandle_WidgetIntUTFStringUTFStringBool
delegates::CMultiDelegate5< Widget *, size_t, const UString &, const UString &, bool & > EventHandle_WidgetIntUTFStringUTFStringBool
Definition: MyGUI_MultiListBox.h:24
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition: MyGUI_UString.h:168
MyGUI::MultiListBox::getSubItemDataAt
ValueType * getSubItemDataAt(size_t _column, size_t _index, bool _throw=true)
Get item data from specified position.
Definition: MyGUI_MultiListBox.h:257
MyGUI::EventHandle_MultiListPtrSizeT
delegates::CMultiDelegate2< MultiListBox *, size_t > EventHandle_MultiListPtrSizeT
Definition: MyGUI_MultiListBox.h:27
MyGUI_Prerequest.h
MyGUI::ResizingPolicy
Definition: MyGUI_ResizingPolicy.h:15
MyGUI::EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef
delegates::CDelegate5< MultiListBox *, size_t, const UString &, const UString &, bool & > EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef
Definition: MyGUI_MultiListBox.h:26
MyGUI::MultiListBox::eventListSelectAccept
EventPair< EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT > eventListSelectAccept
Definition: MyGUI_MultiListBox.h:271
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:65
MyGUI::MemberObsolete
Definition: MyGUI_DeprecatedTypes.h:13
MyGUI::types::TSize< int >
MyGUI_IItem.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103
MyGUI::BiIndexBase
Definition: MyGUI_BiIndexBase.h:15
MyGUI::types::TCoord< int >
MyGUI::MultiListBox::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition: MyGUI_MultiListBox.h:222
MyGUI::Any::Null
static AnyEmpty Null
Definition: MyGUI_Any.h:67
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI_Any.h