MyGUI 3.2.0

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

- File List
- Globals

MyGUI_MultiListBox.h
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_MULTI_LIST_BOX_H__
23 #define __MYGUI_MULTI_LIST_BOX_H__
24
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Widget.h"
27 #include "MyGUI_ListBox.h"
28 #include "MyGUI_Any.h"
29 #include "MyGUI_BiIndexBase.h"
30 #include "MyGUI_EventPair.h"
31 #include "MyGUI_IItem.h"
32 #include "MyGUI_IItemContainer.h"
33 #include "MyGUI_ResizingPolicy.h"
34
35 namespace MyGUI
36 {
37
38 //OBSOLETE
39 typedef delegates::CMultiDelegate5<Widget*, size_t, const UString&, const UString&, bool&> EventHandle_WidgetIntUTFStringUTFStringBool;
40
41 typedef delegates::CDelegate5<MultiListBox*, size_t, const UString&, const UString&, bool&> EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef;
42 typedef delegates::CMultiDelegate2<MultiListBox*, size_t> EventHandle_MultiListPtrSizeT;
43
44 class MYGUI_EXPORT MultiListBox :
45 public Widget,
46 public BiIndexBase,
47 public IItemContainer,
48 public MemberObsolete<MultiListBox>
49 {
50 MYGUI_RTTI_DERIVED( MultiListBox )
51
52 public:
53 MultiListBox();
54
56 virtual void setPosition(const IntPoint& _value);
58 virtual void setSize(const IntSize& _value);
60 virtual void setCoord(const IntCoord& _value);
61
63 void setPosition(int _left, int _top);
65 void setSize(int _width, int _height);
67 void setCoord(int _left, int _top, int _width, int _height);
68
69 //------------------------------------------------------------------------------//
70 // Methods for work with columns (RU:методы для работы со столбцами)
71 //------------------------------------------------------------------------------//
72 // манипуляции айтемами
73
75 size_t getColumnCount() const;
76
83 void insertColumnAt(size_t _column, const UString& _name, int _width = 0, Any _data = Any::Null);
84
90 void addColumn(const UString& _name, int _width = 0, Any _data = Any::Null);
91
93 void removeColumnAt(size_t _column);
94
96 void removeAllColumns();
97
99 void swapColumnsAt(size_t _index1, size_t _index2);
100
101 //------------------------------------------------------------------------------//
102 // манипуляции отображением
103
108 void setColumnNameAt(size_t _column, const UString& _name);
109
114 void setColumnName(MultiListItem* _item, const UString& _name);
115
120 void setColumnWidthAt(size_t _column, int _width);
121
126 void setColumnWidth(MultiListItem* _item, int _width);
127
129 const UString& getColumnNameAt(size_t _column);
130
132 const UString& getColumnName(MultiListItem* _item);
133
135 int getColumnWidthAt(size_t _column);
136
138 void sortByColumn(size_t _column, bool _backward = false);
139
141 size_t getColumnIndex(MultiListItem* _item);
142
147 void setColumnResizingPolicy(MultiListItem* _item, ResizingPolicy _value);
152 void setColumnResizingPolicyAt(size_t _index, ResizingPolicy _value);
153
154 //------------------------------------------------------------------------------//
155 // манипуляции данными
156
158 void setColumnDataAt(size_t _index, Any _data);
159
161 void clearColumnDataAt(size_t _index);
162
164 template <typename ValueType>
165 ValueType* getColumnDataAt(size_t _index, bool _throw = true)
166 {
167 MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.size(), "MultiListBox::getItemDataAt");
168 return mVectorColumnInfo[_index].data.castType<ValueType>(_throw);
169 }
170
171 //------------------------------------------------------------------------------//
172 // Methods for work with lines (RU:методы для работы со строками)
178 //------------------------------------------------------------------------------//
179 // манипуляции айтемами
180
182 size_t getItemCount() const;
183
185 void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
186
188 void addItem(const UString& _name, Any _data = Any::Null);
189
191 void removeItemAt(size_t _index);
192
194 void removeAllItems();
195
197 void swapItemsAt(size_t _index1, size_t _index2);
198
199
200 //------------------------------------------------------------------------------//
201 // манипуляции отображением
202
204 void setItemNameAt(size_t _index, const UString& _name);
205
207 const UString& getItemNameAt(size_t _index);
208
209
210 //------------------------------------------------------------------------------//
211 // манипуляции выделениями
212
214 size_t getIndexSelected() const;
215
217 void setIndexSelected(size_t _index);
218
220 void clearIndexSelected();
221
222
223 //------------------------------------------------------------------------------//
224 // манипуляции данными
225
227 void setItemDataAt(size_t _index, Any _data);
228
230 void clearItemDataAt(size_t _index);
231
233 template <typename ValueType>
234 ValueType* getItemDataAt(size_t _index, bool _throw = true)
235 {
236 return getSubItemDataAt<ValueType>(0, _index, _throw);
237 }
238
239
240 //------------------------------------------------------------------------------//
241 // Methods for work with sub lines (RU:методы для работы со саб строками)
242 //------------------------------------------------------------------------------//
243 // манипуляции данными
244
250 void setSubItemNameAt(size_t _column, size_t _index, const UString& _name);
251
253 const UString& getSubItemNameAt(size_t _column, size_t _index);
254
256 size_t findSubItemWith(size_t _column, const UString& _name);
257
258 //------------------------------------------------------------------------------//
259 // манипуляции данными
260
262 void setSubItemDataAt(size_t _column, size_t _index, Any _data);
263
265 void clearSubItemDataAt(size_t _column, size_t _index);
266
268 template <typename ValueType>
269 ValueType* getSubItemDataAt(size_t _column, size_t _index, bool _throw = true)
270 {
271 MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.begin()->list->getItemCount(), "MultiListBox::getSubItemDataAt");
272
273 size_t index = BiIndexBase::convertToBack(_index);
274 return getSubItemAt(_column)->getItemDataAt<ValueType>(index, _throw);
275 }
276
277 /*events:*/
283 EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT>
284 eventListSelectAccept;
285
291 EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT>
292 eventListChangePosition;
293
302 EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef
303 requestOperatorLess;
304
305 /*internal:*/
306 // IItemContainer impl
307 virtual size_t _getItemCount();
308 virtual void _addItem(const MyGUI::UString& _name);
309 virtual void _removeItemAt(size_t _index);
310 virtual Widget* _getItemAt(size_t _index);
311 virtual void _setItemNameAt(size_t _index, const UString& _name);
312 virtual const UString& _getItemNameAt(size_t _index);
313
314 protected:
315 virtual void initialiseOverride();
316 virtual void shutdownOverride();
317
318 virtual void onWidgetCreated(Widget* _widget);
319 virtual void onWidgetDestroy(Widget* _widget);
320
321 private:
322 void notifyListChangePosition(ListBox* _sender, size_t _position);
323 void notifyListChangeFocus(ListBox* _sender, size_t _position);
324 void notifyListChangeScrollPosition(ListBox* _sender, size_t _position);
325 void notifyButtonClick(Widget* _sender);
326 void notifyListSelectAccept(ListBox* _sender, size_t _position);
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* getSeparator(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 typedef std::vector<ColumnInfo> VectorColumnInfo;
353
354 void frameEntered(float _frame);
355 void frameAdvise(bool _advise);
356
357 ListBox* getSubItemAt(size_t _column);
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) const;
365 bool getUpdateByResize();
366 int updateWidthColumns(size_t& _countStars, size_t& _lastIndexStar);
367
368 private:
369 int mHeightButton;
370 int mWidthBar;
371 std::string mSkinButton;
372 std::string mSkinList;
373 Widget* mWidgetEmpty;
374
375 VectorColumnInfo mVectorColumnInfo;
376
377 VectorWidgetPtr mSeparators;
378
379 size_t mLastMouseFocusIndex;
380
381 bool mSortUp;
382 size_t mSortColumnIndex;
383
384 int mWidthSeparator;
385 std::string mSkinSeparator;
386 int mOffsetButtonSeparator;
387
388 size_t mItemSelected;
389
390 bool mFrameAdvise;
391 Widget* mClient;
392 Widget* mHeaderPlace;
393 };
394
395 } // namespace MyGUI
396
397 #endif // __MYGUI_MULTI_LIST_BOX_H__
MyGUI::types::TCoord< int >
MyGUI::Widget
Definition: MyGUI_Widget.h:41
MyGUI_IItemContainer.h
MyGUI::EventHandle_WidgetIntUTFStringUTFStringBool
delegates::CMultiDelegate5< Widget *, size_t, const UString &, const UString &, bool & > EventHandle_WidgetIntUTFStringUTFStringBool
Definition: MyGUI_MultiListBox.h:39
MyGUI::types::TPoint< int >
MyGUI_Prerequest.h
MyGUI_IItem.h
MyGUI::types::TSize< int >
MyGUI::Any
Definition: MyGUI_Any.h:81
MyGUI_ListBox.h
MyGUI::ListBox
Definition: MyGUI_ListBox.h:37
MyGUI::IItemContainer
Definition: MyGUI_IItemContainer.h:33
MyGUI::MultiListItem
Definition: MyGUI_MultiListItem.h:33
MyGUI::Button
Definition: MyGUI_Button.h:31
MyGUI::EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef
delegates::CDelegate5< MultiListBox *, size_t, const UString &, const UString &, bool & > EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef
Definition: MyGUI_MultiListBox.h:41
MyGUI::ResizingPolicy
Definition: MyGUI_ResizingPolicy.h:30
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:88
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:120
MyGUI::EventPair
Definition: MyGUI_EventPair.h:31
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition: MyGUI_WidgetDefines.h:33
MyGUI_Any.h
MyGUI_BiIndexBase.h
MyGUI::BiIndexBase
Definition: MyGUI_BiIndexBase.h:30
MyGUI::MultiListBox::eventListChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT > eventListChangePosition
Definition: MyGUI_MultiListBox.h:292
MyGUI::EventHandle_MultiListPtrSizeT
delegates::CMultiDelegate2< MultiListBox *, size_t > EventHandle_MultiListPtrSizeT
Definition: MyGUI_MultiListBox.h:42
MyGUI::delegates::CMultiDelegate2
Definition: MyGUI_Delegate.h:239
MyGUI_ResizingPolicy.h
MYGUI_ASSERT_RANGE
#define MYGUI_ASSERT_RANGE(index, size, owner)
Definition: MyGUI_Diagnostic.h:70
MyGUI::MultiListBox::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition: MyGUI_MultiListBox.h:234
MyGUI::MultiListBox::requestOperatorLess
EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef requestOperatorLess
Definition: MyGUI_MultiListBox.h:303
MyGUI_Widget.h
MyGUI::delegates::CMultiDelegate5
Definition: MyGUI_Delegate.h:239
MyGUI::MultiListBox
Definition: MyGUI_MultiListBox.h:44
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition: MyGUI_UString.h:169
MyGUI::BiIndexBase::convertToBack
size_t convertToBack(size_t _index) const
Definition: MyGUI_BiIndexBase.cpp:124
MyGUI::MultiListBox::eventListSelectAccept
EventPair< EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT > eventListSelectAccept
Definition: MyGUI_MultiListBox.h:284
MyGUI::MemberObsolete
Definition: MyGUI_DeprecatedTypes.h:28
MyGUI_EventPair.h
MyGUI::MultiListBox::getSubItemDataAt
ValueType * getSubItemDataAt(size_t _column, size_t _index, bool _throw=true)
Get item data from specified position.
Definition: MyGUI_MultiListBox.h:269
MyGUI::delegates::CDelegate5< MultiListBox *, size_t, const UString &, const UString &, bool & >
MyGUI::Any::Null
static AnyEmpty Null
Definition: MyGUI_Any.h:85