MyGUI: MyGUI_MultiListBox.h Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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
20namespace 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::CDelegate5<MultiListBox*, size_t, size_t, size_t, bool&> EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef;
28 typedef delegates::CMultiDelegate2<MultiListBox*, size_t> EventHandle_MultiListPtrSizeT;
29 typedef delegates::CMultiDelegate2<MultiListBox*, const IBNotifyItemData&> EventHandle_MultiListPtrCIBNotifyCellDataRef;
30
34 class MYGUI_EXPORT MultiListBox :
35 public Widget,
36 public BiIndexBase,
37 public IItemContainer,
38 public MemberObsolete<MultiListBox>
39 {
40 MYGUI_RTTI_DERIVED( MultiListBox )
41
42 public:
43 MultiListBox();
44
46 void setPosition(const IntPoint& _value) override;
48 void setSize(const IntSize& _value) override;
50 void setCoord(const IntCoord& _value) override;
51
52 using Widget::setPosition;
53 using Widget::setSize;
54 using Widget::setCoord;
55
56 //------------------------------------------------------------------------------//
57 // Methods for work with columns (RU:методы для работы со столбцами)
58 //------------------------------------------------------------------------------//
59 // манипуляции айтемами
60
62 size_t getColumnCount() const;
63
70 void insertColumnAt(size_t _column, const UString& _name, int _width = 0, Any _data = Any::Null);
71
77 void addColumn(const UString& _name, int _width = 0, Any _data = Any::Null);
78
80 void removeColumnAt(size_t _column);
81
83 void removeAllColumns();
84
86 void swapColumnsAt(size_t _index1, size_t _index2);
87
88 //------------------------------------------------------------------------------//
89 // манипуляции отображением
90
95 void setColumnNameAt(size_t _column, const UString& _name);
96
101 void setColumnName(MultiListItem* _item, const UString& _name);
102
107 void setColumnWidthAt(size_t _column, int _width);
108
113 void setColumnWidth(MultiListItem* _item, int _width);
114
116 const UString& getColumnNameAt(size_t _column) const;
117
119 const UString& getColumnName(const MultiListItem* _item) const;
120
122 int getColumnWidthAt(size_t _column) const;
123
125 void sortByColumn(size_t _column, bool _backward = false);
126
128 size_t getColumnIndex(const MultiListItem* _item) const;
129
134 void setColumnResizingPolicy(MultiListItem* _item, ResizingPolicy _value);
139 void setColumnResizingPolicyAt(size_t _index, ResizingPolicy _value);
140
141 //------------------------------------------------------------------------------//
142 // манипуляции данными
143
145 void setColumnDataAt(size_t _index, Any _data);
146
148 void clearColumnDataAt(size_t _index);
149
151 template <typename ValueType>
152 ValueType* getColumnDataAt(size_t _index, bool _throw = true)
153 {
154 MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.size(), "MultiListBox::getItemDataAt");
155 return mVectorColumnInfo[_index].data.castType<ValueType>(_throw);
156 }
157
158 //------------------------------------------------------------------------------//
159 // Methods for work with lines (RU:методы для работы со строками)
165 //------------------------------------------------------------------------------//
166 // манипуляции айтемами
167
169 size_t getItemCount() const;
170
172 void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
173
175 void addItem(const UString& _name, Any _data = Any::Null);
176
178 void removeItemAt(size_t _index);
179
181 void removeAllItems();
182
184 void swapItemsAt(size_t _index1, size_t _index2);
185
186
187 //------------------------------------------------------------------------------//
188 // манипуляции отображением
189
191 void setItemNameAt(size_t _index, const UString& _name);
192
194 const UString& getItemNameAt(size_t _index) const;
195
196
197 //------------------------------------------------------------------------------//
198 // манипуляции выделениями
199
201 size_t getIndexSelected() const;
202
204 void setIndexSelected(size_t _index);
205
207 void clearIndexSelected();
208
209
210 //------------------------------------------------------------------------------//
211 // манипуляции данными
212
214 void setItemDataAt(size_t _index, Any _data);
215
217 void clearItemDataAt(size_t _index);
218
220 template <typename ValueType>
221 ValueType* getItemDataAt(size_t _index, bool _throw = true)
222 {
223 return getSubItemDataAt<ValueType>(0, _index, _throw);
224 }
225
226
227 //------------------------------------------------------------------------------//
228 // Methods for work with sub lines (RU:методы для работы со саб строками)
229 //------------------------------------------------------------------------------//
230 // манипуляции данными
231
237 void setSubItemNameAt(size_t _column, size_t _index, const UString& _name);
238
240 const UString& getSubItemNameAt(size_t _column, size_t _index) const;
241
243 size_t findSubItemWith(size_t _column, const UString& _name);
244
245 //------------------------------------------------------------------------------//
246 // манипуляции данными
247
249 void setSubItemDataAt(size_t _column, size_t _index, Any _data);
250
252 void clearSubItemDataAt(size_t _column, size_t _index);
253
255 template <typename ValueType>
256 ValueType* getSubItemDataAt(size_t _column, size_t _index, bool _throw = true)
257 {
258 MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.begin()->list->getItemCount(), "MultiListBox::getSubItemDataAt");
259
260 size_t index = BiIndexBase::convertToBack(_index);
261 return getSubItemAt(_column)->getItemDataAt<ValueType>(index, _throw);
262 }
263
264 /*events:*/
270 EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT> eventListSelectAccept;
271
277 EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT> eventListChangePosition;
278
287 EventPair<EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef, EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef> requestOperatorLess;
288
294 EventHandle_MultiListPtrCIBNotifyCellDataRef eventNotifyItem;
295
296 /*internal:*/
297 // IItemContainer impl
298 size_t _getItemCount() const override;
299 void _addItem(const MyGUI::UString& _name) override;
300 void _removeItemAt(size_t _index) override;
301 Widget* _getItemAt(size_t _index) const override;
302 void _setItemNameAt(size_t _index, const UString& _name) override;
303 const UString& _getItemNameAt(size_t _index) const override;
304
305 protected:
306 void initialiseOverride() override;
307 void shutdownOverride() override;
308
309 void onWidgetCreated(Widget* _widget) override;
310 void onWidgetDestroy(Widget* _widget) override;
311
312 private:
313 void notifyListChangePosition(ListBox* _sender, size_t _position);
314 void notifyListChangeFocus(ListBox* _sender, size_t _position);
315 void notifyListChangeScrollPosition(ListBox* _sender, size_t _position);
316 void notifyButtonClick(Widget* _sender);
317 void notifyListSelectAccept(ListBox* _sender, size_t _position);
318 void notifyListNotifyItem(ListBox* _sender, const MyGUI::IBNotifyItemData& _info);
319
320 void updateColumns();
321 void redrawButtons();
322 void updateOnlyEmpty();
323
324 bool compare(ListBox* _list, size_t _left, size_t _right);
325 void sortList();
326 void flipList();
327
328 Widget* getOrCreateSeparator(size_t _index);
329
330 void updateBackSelected(size_t _index);
331
332 struct ColumnInfo
333 {
334 MultiListItem* item;
335 ListBox* list;
336 Button* button;
337 int width;
338 int realWidth;
339 UString name;
340 Any data;
341 ResizingPolicy sizeType;
342 };
343
344 typedef std::vector<ColumnInfo> VectorColumnInfo;
345
346 void frameEntered(float _frame);
347 void frameAdvise(bool _advise);
348
349 ListBox* getSubItemAt(size_t _column) const;
350 int getButtonHeight() const;
351
352 void _wrapItem(MultiListItem* _item);
353 void _unwrapItem(MultiListItem* _item);
354 void _swapColumnsAt(size_t _index1, size_t _index2);
355
356 int getColumnWidth(size_t _index, int _freeSpace, size_t _countStars, size_t _lastIndexStar, int _starWidth) const;
357 bool getUpdateByResize() const;
358 int updateWidthColumns(size_t& _countStars, size_t& _lastIndexStar);
359
360 private:
361 int mHeightButton;
362 int mWidthBar;
363 std::string mSkinButton;
364 std::string mSkinList;
365 Widget* mWidgetEmpty;
366
367 VectorColumnInfo mVectorColumnInfo;
368
369 VectorWidgetPtr mSeparators;
370
371 size_t mLastMouseFocusIndex;
372
373 bool mSortUp;
374 size_t mSortColumnIndex;
375
376 int mWidthSeparator;
377 std::string mSkinSeparator;
378
379 size_t mItemSelected;
380
381 bool mFrameAdvise;
382 Widget* mHeaderPlace;
383 };
384
385} // namespace MyGUI
386
387#endif // MYGUI_MULTI_LIST_BOX_H_
MyGUI_Any.h
MyGUI_BiIndexBase.h
MYGUI_ASSERT_RANGE
#define MYGUI_ASSERT_RANGE(index, size, owner)
Definition MyGUI_Diagnostic.h:40
MyGUI_EventPair.h
MyGUI_IItem.h
MyGUI_IItemContainer.h
MyGUI_ListBox.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:48
MyGUI_ResizingPolicy.h
MyGUI_Widget.h
MyGUI::Any
Definition MyGUI_Any.h:56
MyGUI::BiIndexBase
Definition MyGUI_BiIndexBase.h:18
MyGUI::Button
widget description should be here.
Definition MyGUI_Button.h:22
MyGUI::EventPair
Definition MyGUI_EventPair.h:17
MyGUI::IItemContainer
Definition MyGUI_IItemContainer.h:19
MyGUI::ListBox
widget description should be here.
Definition MyGUI_ListBox.h:31
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::MultiListBox
widget description should be here.
Definition MyGUI_MultiListBox.h:39
MyGUI::MultiListBox::eventListChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT > eventListChangePosition
Definition MyGUI_MultiListBox.h:277
MyGUI::MultiListBox::eventListSelectAccept
EventPair< EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT > eventListSelectAccept
Definition MyGUI_MultiListBox.h:270
MyGUI::MultiListBox::getSubItemDataAt
ValueType * getSubItemDataAt(size_t _column, size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_MultiListBox.h:256
MyGUI::MultiListBox::requestOperatorLess
EventPair< EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef, EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef > requestOperatorLess
Definition MyGUI_MultiListBox.h:287
MyGUI::MultiListBox::eventNotifyItem
EventHandle_MultiListPtrCIBNotifyCellDataRef eventNotifyItem
Definition MyGUI_MultiListBox.h:294
MyGUI::MultiListBox::getColumnDataAt
ValueType * getColumnDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_MultiListBox.h:152
MyGUI::MultiListBox::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_MultiListBox.h:221
MyGUI::MultiListItem
widget description should be here.
Definition MyGUI_MultiListItem.h:23
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition MyGUI_UString.h:145
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:37
MyGUI::delegates::Delegate
Definition MyGUI_Delegate.h:136
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:200
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::EventHandle_WidgetIntUTFStringUTFStringBool
delegates::CMultiDelegate5< Widget *, size_t, const UString &, const UString &, bool & > EventHandle_WidgetIntUTFStringUTFStringBool
Definition MyGUI_MultiListBox.h:24
MyGUI::EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef
delegates::CDelegate5< MultiListBox *, size_t, const UString &, const UString &, bool & > EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef
Definition MyGUI_MultiListBox.h:26
MyGUI::EventHandle_MultiListPtrCIBNotifyCellDataRef
delegates::CMultiDelegate2< MultiListBox *, const IBNotifyItemData & > EventHandle_MultiListPtrCIBNotifyCellDataRef
Definition MyGUI_MultiListBox.h:29
MyGUI::EventHandle_MultiListPtrSizeT
delegates::CMultiDelegate2< MultiListBox *, size_t > EventHandle_MultiListPtrSizeT
Definition MyGUI_MultiListBox.h:28
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition MyGUI_WidgetDefines.h:20
MyGUI::EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef
delegates::CDelegate5< MultiListBox *, size_t, size_t, size_t, bool & > EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef
Definition MyGUI_MultiListBox.h:27
MyGUI::IBNotifyItemData
Definition MyGUI_IBItemInfo.h:62
MyGUI::ResizingPolicy
Definition MyGUI_ResizingPolicy.h:16
MyGUI::types::TCoord< int >
MyGUI::types::TPoint< int >
MyGUI::types::TSize< int >