MyGUI: MyGUI_MultiListBox.h Source File

MyGUI 3.4.3

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 using EventHandle_WidgetIntUTFStringUTFStringBool =
25 delegates::MultiDelegate<Widget*, size_t, const UString&, const UString&, bool&>;
26
27 using EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef =
28 delegates::Delegate<MultiListBox*, size_t, const UString&, const UString&, bool&>;
29 using EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef =
30 delegates::Delegate<MultiListBox*, size_t, size_t, size_t, bool&>;
31 using EventHandle_MultiListPtrSizeT = delegates::MultiDelegate<MultiListBox*, size_t>;
32 using EventHandle_MultiListPtrCIBNotifyCellDataRef =
33 delegates::MultiDelegate<MultiListBox*, const IBNotifyItemData&>;
34
38 class MYGUI_EXPORT MultiListBox :
39 public Widget,
40 public BiIndexBase,
41 public IItemContainer,
42 public MemberObsolete<MultiListBox>
43 {
44 MYGUI_RTTI_DERIVED(MultiListBox)
45
46 public:
48 void setPosition(const IntPoint& _point) override;
50 void setSize(const IntSize& _size) override;
52 void setCoord(const IntCoord& _coord) override;
53
54 using Widget::setPosition;
55 using Widget::setSize;
56 using Widget::setCoord;
57
58 //------------------------------------------------------------------------------//
59 // Methods for work with columns (RU:методы для работы со столбцами)
60 //------------------------------------------------------------------------------//
61 // манипуляции айтемами
62
64 size_t getColumnCount() const;
65
72 void insertColumnAt(size_t _column, const UString& _name, int _width = 0, Any _data = Any::Null);
73
79 void addColumn(const UString& _name, int _width = 0, Any _data = Any::Null);
80
82 void removeColumnAt(size_t _column);
83
85 void removeAllColumns();
86
88 void swapColumnsAt(size_t _index1, size_t _index2);
89
90 //------------------------------------------------------------------------------//
91 // манипуляции отображением
92
97 void setColumnNameAt(size_t _column, const UString& _name);
98
103 void setColumnName(MultiListItem* _item, const UString& _name);
104
109 void setColumnWidthAt(size_t _column, int _width);
110
115 void setColumnWidth(MultiListItem* _item, int _width);
116
118 const UString& getColumnNameAt(size_t _column) const;
119
121 const UString& getColumnName(const MultiListItem* _item) const;
122
124 int getColumnWidthAt(size_t _column) const;
125
127 void sortByColumn(size_t _column, bool _backward = false);
128
130 size_t getColumnIndex(const MultiListItem* _item) const;
131
136 void setColumnResizingPolicy(MultiListItem* _item, ResizingPolicy _value);
141 void setColumnResizingPolicyAt(size_t _index, ResizingPolicy _value);
142
143 //------------------------------------------------------------------------------//
144 // манипуляции данными
145
147 void setColumnDataAt(size_t _index, Any _data);
148
150 void clearColumnDataAt(size_t _index);
151
153 template<typename ValueType>
154 ValueType* getColumnDataAt(size_t _index, bool _throw = true)
155 {
156 MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.size(), "MultiListBox::getItemDataAt");
157 return mVectorColumnInfo[_index].data.castType<ValueType>(_throw);
158 }
159
160 //------------------------------------------------------------------------------//
161 // Methods for work with lines (RU:методы для работы со строками)
166
167 //------------------------------------------------------------------------------//
168 // манипуляции айтемами
169
171 size_t getItemCount() const;
172
174 void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
175
177 void addItem(const UString& _name, Any _data = Any::Null);
178
180 void removeItemAt(size_t _index);
181
183 void removeAllItems();
184
186 void swapItemsAt(size_t _index1, size_t _index2);
187
188
189 //------------------------------------------------------------------------------//
190 // манипуляции отображением
191
193 void setItemNameAt(size_t _index, const UString& _name);
194
196 const UString& getItemNameAt(size_t _index) const;
197
198
199 //------------------------------------------------------------------------------//
200 // манипуляции выделениями
201
203 size_t getIndexSelected() const;
204
206 void setIndexSelected(size_t _index);
207
209 void clearIndexSelected();
210
211
212 //------------------------------------------------------------------------------//
213 // манипуляции данными
214
216 void setItemDataAt(size_t _index, Any _data);
217
219 void clearItemDataAt(size_t _index);
220
222 template<typename ValueType>
223 ValueType* getItemDataAt(size_t _index, bool _throw = true)
224 {
225 return getSubItemDataAt<ValueType>(0, _index, _throw);
226 }
227
228
229 //------------------------------------------------------------------------------//
230 // Methods for work with sub lines (RU:методы для работы со саб строками)
231 //------------------------------------------------------------------------------//
232 // манипуляции данными
233
239 void setSubItemNameAt(size_t _column, size_t _index, const UString& _name);
240
242 const UString& getSubItemNameAt(size_t _column, size_t _index) const;
243
245 size_t findSubItemWith(size_t _column, const UString& _name);
246
247 //------------------------------------------------------------------------------//
248 // манипуляции данными
249
251 void setSubItemDataAt(size_t _column, size_t _index, Any _data);
252
254 void clearSubItemDataAt(size_t _column, size_t _index);
255
257 template<typename ValueType>
258 ValueType* getSubItemDataAt(size_t _column, size_t _index, bool _throw = true)
259 {
260 MYGUI_ASSERT_RANGE(
261 _index,
262 mVectorColumnInfo.begin()->list->getItemCount(),
263 "MultiListBox::getSubItemDataAt");
264
265 size_t index = BiIndexBase::convertToBack(_index);
266 return getSubItemAt(_column)->getItemDataAt<ValueType>(index, _throw);
267 }
268
269 /*events:*/
275 EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT> eventListSelectAccept;
276
282 EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT> eventListChangePosition;
283
292 EventPair<
293 EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef,
294 EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef>
295 requestOperatorLess;
296
302 EventHandle_MultiListPtrCIBNotifyCellDataRef eventNotifyItem;
303
304 /*internal:*/
305 // IItemContainer impl
306 size_t _getItemCount() const override;
307 void _addItem(const MyGUI::UString& _name) override;
308 void _removeItemAt(size_t _index) override;
309 Widget* _getItemAt(size_t _index) const override;
310 void _setItemNameAt(size_t _index, const UString& _name) override;
311 const UString& _getItemNameAt(size_t _index) const override;
312
313 protected:
314 void initialiseOverride() override;
315 void shutdownOverride() override;
316
317 void onWidgetCreated(Widget* _widget) override;
318 void onWidgetDestroy(Widget* _widget) override;
319
320 private:
321 void notifyListChangePosition(ListBox* _sender, size_t _position);
322 void notifyListChangeFocus(ListBox* _sender, size_t _position);
323 void notifyListChangeScrollPosition(ListBox* _sender, size_t _position);
324 void notifyButtonClick(Widget* _sender);
325 void notifyListSelectAccept(ListBox* _sender, size_t _position);
326 void notifyListNotifyItem(ListBox* _sender, const MyGUI::IBNotifyItemData& _info);
327
328 void updateColumns();
329 void redrawButtons();
330 void updateOnlyEmpty();
331
332 bool compare(ListBox* _list, size_t _left, size_t _right);
333 void sortList();
334 void flipList();
335
336 Widget* getOrCreateSeparator(size_t _index);
337
338 void updateBackSelected(size_t _index);
339
340 struct ColumnInfo
341 {
342 MultiListItem* item;
343 ListBox* list;
344 Button* button;
345 int width;
346 int realWidth;
347 UString name;
348 Any data;
349 ResizingPolicy sizeType;
350 };
351
352 using VectorColumnInfo = std::vector<ColumnInfo>;
353
354 void frameEntered(float _frame);
355 void frameAdvise(bool _advise);
356
357 ListBox* getSubItemAt(size_t _column) const;
358 int getButtonHeight() const;
359
360 void _wrapItem(MultiListItem* _item);
361 void _unwrapItem(MultiListItem* _item);
362 void _swapColumnsAt(size_t _index1, size_t _index2);
363
364 int getColumnWidth(size_t _index, int _freeSpace, size_t _countStars, size_t _lastIndexStar, int _starWidth)
365 const;
366 bool getUpdateByResize() const;
367 int updateWidthColumns(size_t& _countStars, size_t& _lastIndexStar);
368
369 private:
370 int mHeightButton{0};
371 int mWidthBar{0};
372 std::string mSkinButton;
373 std::string mSkinList;
374 Widget* mWidgetEmpty{nullptr};
375
376 VectorColumnInfo mVectorColumnInfo;
377
378 VectorWidgetPtr mSeparators;
379
380 size_t mLastMouseFocusIndex{ITEM_NONE};
381
382 bool mSortUp{true};
383 size_t mSortColumnIndex{ITEM_NONE};
384
385 int mWidthSeparator{0};
386 std::string mSkinSeparator;
387
388 size_t mItemSelected{ITEM_NONE};
389
390 bool mFrameAdvise{false};
391 Widget* mHeaderPlace{nullptr};
392 };
393
394} // namespace MyGUI
395
396#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:44
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:69
MyGUI_ResizingPolicy.h
MyGUI_Widget.h
MyGUI::Any
Definition MyGUI_Any.h:56
MyGUI::Any::Null
static const Any Null
Definition MyGUI_Any.h:58
MyGUI::BiIndexBase
Definition MyGUI_BiIndexBase.h:18
MyGUI::BiIndexBase::convertToBack
size_t convertToBack(size_t _index) const
Definition MyGUI_BiIndexBase.cpp:101
MyGUI::Button
widget description should be here.
Definition MyGUI_Button.h:20
MyGUI::EventPair
Definition MyGUI_EventPair.h:99
MyGUI::IItemContainer
Definition MyGUI_IItemContainer.h:19
MyGUI::ListBox
widget description should be here.
Definition MyGUI_ListBox.h:28
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::MultiListBox
widget description should be here.
Definition MyGUI_MultiListBox.h:43
MyGUI::MultiListBox::_getItemCount
size_t _getItemCount() const override
Definition MyGUI_MultiListBox.cpp:586
MyGUI::MultiListBox::setColumnWidthAt
void setColumnWidthAt(size_t _column, int _width)
Definition MyGUI_MultiListBox.cpp:79
MyGUI::MultiListBox::onWidgetDestroy
void onWidgetDestroy(Widget *_widget) override
Definition MyGUI_MultiListBox.cpp:681
MyGUI::MultiListBox::_removeItemAt
void _removeItemAt(size_t _index) override
Definition MyGUI_MultiListBox.cpp:597
MyGUI::MultiListBox::setColumnResizingPolicyAt
void setColumnResizingPolicyAt(size_t _index, ResizingPolicy _value)
Definition MyGUI_MultiListBox.cpp:811
MyGUI::MultiListBox::setColumnWidth
void setColumnWidth(MultiListItem *_item, int _width)
Definition MyGUI_MultiListBox.cpp:818
MyGUI::MultiListBox::_setItemNameAt
void _setItemNameAt(size_t _index, const UString &_name) override
Definition MyGUI_MultiListBox.cpp:602
MyGUI::MultiListBox::setCoord
void setCoord(const IntCoord &_coord) override
Definition MyGUI_MultiListBox.cpp:836
MyGUI::MultiListBox::requestOperatorLess
EventPair< EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef, EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef > requestOperatorLess
Definition MyGUI_MultiListBox.h:295
MyGUI::MultiListBox::setColumnDataAt
void setColumnDataAt(size_t _index, Any _data)
Replace an item data at a specified position.
Definition MyGUI_MultiListBox.cpp:511
MyGUI::MultiListBox::eventListChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT > eventListChangePosition
Definition MyGUI_MultiListBox.h:282
MyGUI::MultiListBox::sortByColumn
void sortByColumn(size_t _column, bool _backward=false)
Definition MyGUI_MultiListBox.cpp:104
MyGUI::MultiListBox::_getItemNameAt
const UString & _getItemNameAt(size_t _index) const override
Definition MyGUI_MultiListBox.cpp:607
MyGUI::MultiListBox::insertColumnAt
void insertColumnAt(size_t _column, const UString &_name, int _width=0, Any _data=Any::Null)
Definition MyGUI_MultiListBox.cpp:612
MyGUI::MultiListBox::getColumnWidthAt
int getColumnWidthAt(size_t _column) const
Definition MyGUI_MultiListBox.cpp:92
MyGUI::MultiListBox::setSize
void setSize(const IntSize &_size) override
Definition MyGUI_MultiListBox.cpp:828
MyGUI::MultiListBox::eventListSelectAccept
EventPair< EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT > eventListSelectAccept
Definition MyGUI_MultiListBox.h:275
MyGUI::MultiListBox::getColumnCount
size_t getColumnCount() const
Get number of columns.
Definition MyGUI_MultiListBox.cpp:525
MyGUI::MultiListBox::onWidgetCreated
void onWidgetCreated(Widget *_widget) override
Definition MyGUI_MultiListBox.cpp:670
MyGUI::MultiListBox::getSubItemDataAt
ValueType * getSubItemDataAt(size_t _column, size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_MultiListBox.h:258
MyGUI::MultiListBox::removeColumnAt
void removeColumnAt(size_t _column)
Definition MyGUI_MultiListBox.cpp:638
MyGUI::MultiListBox::_getItemAt
Widget * _getItemAt(size_t _index) const override
Definition MyGUI_MultiListBox.cpp:779
MyGUI::MultiListBox::setPosition
void setPosition(const IntPoint &_point) override
Definition MyGUI_MultiListBox.cpp:823
MyGUI::MultiListBox::_addItem
void _addItem(const MyGUI::UString &_name) override
Definition MyGUI_MultiListBox.cpp:591
MyGUI::MultiListBox::clearColumnDataAt
void clearColumnDataAt(size_t _index)
Clear an item data at a specified position.
Definition MyGUI_MultiListBox.cpp:535
MyGUI::MultiListBox::shutdownOverride
void shutdownOverride() override
Definition MyGUI_MultiListBox.cpp:65
MyGUI::MultiListBox::eventNotifyItem
EventHandle_MultiListPtrCIBNotifyCellDataRef eventNotifyItem
Definition MyGUI_MultiListBox.h:302
MyGUI::MultiListBox::initialiseOverride
void initialiseOverride() override
Definition MyGUI_MultiListBox.cpp:20
MyGUI::MultiListBox::getColumnIndex
size_t getColumnIndex(const MultiListItem *_item) const
Get column index.
Definition MyGUI_MultiListBox.cpp:795
MyGUI::MultiListBox::setColumnNameAt
void setColumnNameAt(size_t _column, const UString &_name)
Definition MyGUI_MultiListBox.cpp:70
MyGUI::MultiListBox::getColumnDataAt
ValueType * getColumnDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_MultiListBox.h:154
MyGUI::MultiListBox::addColumn
void addColumn(const UString &_name, int _width=0, Any _data=Any::Null)
Definition MyGUI_MultiListBox.cpp:530
MyGUI::MultiListBox::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_MultiListBox.h:223
MyGUI::MultiListBox::setColumnName
void setColumnName(MultiListItem *_item, const UString &_name)
Definition MyGUI_MultiListBox.cpp:785
MyGUI::MultiListBox::setColumnResizingPolicy
void setColumnResizingPolicy(MultiListItem *_item, ResizingPolicy _value)
Definition MyGUI_MultiListBox.cpp:806
MyGUI::MultiListBox::getColumnNameAt
const UString & getColumnNameAt(size_t _column) const
Definition MyGUI_MultiListBox.cpp:86
MyGUI::MultiListBox::removeAllColumns
void removeAllColumns()
Definition MyGUI_MultiListBox.cpp:98
MyGUI::MultiListBox::swapColumnsAt
void swapColumnsAt(size_t _index1, size_t _index2)
Swap columns at a specified positions.
Definition MyGUI_MultiListBox.cpp:647
MyGUI::MultiListBox::getColumnName
const UString & getColumnName(const MultiListItem *_item) const
Definition MyGUI_MultiListBox.cpp:790
MyGUI::MultiListItem
widget description should be here.
Definition MyGUI_MultiListItem.h:22
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition MyGUI_UString.h:144
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:40
MyGUI::Widget::setSize
void setSize(const IntSize &_size) override
Definition MyGUI_Widget.cpp:693
MyGUI::Widget::setPosition
void setPosition(const IntPoint &_point) override
Definition MyGUI_Widget.cpp:676
MyGUI::Widget::setCoord
void setCoord(const IntCoord &_coord) override
Definition MyGUI_Widget.cpp:730
MyGUI::delegates::Delegate
Definition MyGUI_Delegate.h:158
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:190
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef
delegates::Delegate< MultiListBox *, size_t, const UString &, const UString &, bool & > EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef
Definition MyGUI_MultiListBox.h:27
MyGUI::IntPoint
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:27
MyGUI::ITEM_NONE
constexpr size_t ITEM_NONE
Definition MyGUI_Macros.h:19
MyGUI::EventHandle_MultiListPtrCIBNotifyCellDataRef
delegates::MultiDelegate< MultiListBox *, const IBNotifyItemData & > EventHandle_MultiListPtrCIBNotifyCellDataRef
Definition MyGUI_MultiListBox.h:32
MyGUI::EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef
delegates::Delegate< MultiListBox *, size_t, size_t, size_t, bool & > EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef
Definition MyGUI_MultiListBox.h:29
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
MyGUI::IntSize
types::TSize< int > IntSize
Definition MyGUI_Types.h:30
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition MyGUI_WidgetDefines.h:20
MyGUI::EventHandle_MultiListPtrSizeT
delegates::MultiDelegate< MultiListBox *, size_t > EventHandle_MultiListPtrSizeT
Definition MyGUI_MultiListBox.h:31
MyGUI::EventHandle_WidgetIntUTFStringUTFStringBool
delegates::MultiDelegate< Widget *, size_t, const UString &, const UString &, bool & > EventHandle_WidgetIntUTFStringUTFStringBool
Definition MyGUI_MultiListBox.h:24
MyGUI::IBNotifyItemData
Definition MyGUI_IBItemInfo.h:68
MyGUI::ResizingPolicy
Definition MyGUI_ResizingPolicy.h:16