MyGUI_MultiListBox.h
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_MULTI_LIST_BOX_H_
#define MYGUI_MULTI_LIST_BOX_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Widget.h"
#include "MyGUI_ListBox.h"
#include "MyGUI_Any.h"
#include "MyGUI_BiIndexBase.h"
#include "MyGUI_EventPair.h"
#include "MyGUI_IItem.h"
#include "MyGUI_IItemContainer.h"
#include "MyGUI_ResizingPolicy.h"
namespace MyGUI
{
//OBSOLETE
using EventHandle_WidgetIntUTFStringUTFStringBool =
delegates::MultiDelegate<Widget*, size_t, const UString&, const UString&, bool&>;
using EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef =
delegates::Delegate<MultiListBox*, size_t, const UString&, const UString&, bool&>;
using EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef =
delegates::Delegate<MultiListBox*, size_t, size_t, size_t, bool&>;
using EventHandle_MultiListPtrSizeT = delegates::MultiDelegate<MultiListBox*, size_t>;
using EventHandle_MultiListPtrCIBNotifyCellDataRef =
delegates::MultiDelegate<MultiListBox*, const IBNotifyItemData&>;
class MYGUI_EXPORT MultiListBox :
public Widget,
public BiIndexBase,
public IItemContainer,
public MemberObsolete<MultiListBox>
{
MYGUI_RTTI_DERIVED(MultiListBox)
public:
void setPosition(const IntPoint& _point) override;
void setSize(const IntSize& _size) override;
void setCoord(const IntCoord& _coord) override;
using Widget::setPosition;
using Widget::setSize;
using Widget::setCoord;
//------------------------------------------------------------------------------//
// Methods for work with columns (RU:методы для работы со столбцами)
//------------------------------------------------------------------------------//
// манипуляции айтемами
size_t getColumnCount() const;
void insertColumnAt(size_t _column, const UString& _name, int _width = 0, Any _data = Any::Null);
void addColumn(const UString& _name, int _width = 0, Any _data = Any::Null);
void removeColumnAt(size_t _column);
void removeAllColumns();
void swapColumnsAt(size_t _index1, size_t _index2);
//------------------------------------------------------------------------------//
// манипуляции отображением
void setColumnNameAt(size_t _column, const UString& _name);
void setColumnName(MultiListItem* _item, const UString& _name);
void setColumnWidthAt(size_t _column, int _width);
void setColumnWidth(MultiListItem* _item, int _width);
const UString& getColumnNameAt(size_t _column) const;
const UString& getColumnName(const MultiListItem* _item) const;
int getColumnWidthAt(size_t _column) const;
void sortByColumn(size_t _column, bool _backward = false);
size_t getColumnIndex(const MultiListItem* _item) const;
void setColumnResizingPolicy(MultiListItem* _item, ResizingPolicy _value);
void setColumnResizingPolicyAt(size_t _index, ResizingPolicy _value);
//------------------------------------------------------------------------------//
// манипуляции данными
void setColumnDataAt(size_t _index, Any _data);
void clearColumnDataAt(size_t _index);
template<typename ValueType>
ValueType* getColumnDataAt(size_t _index, bool _throw = true)
{
MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.size(), "MultiListBox::getItemDataAt");
return mVectorColumnInfo[_index].data.castType<ValueType>(_throw);
}
//------------------------------------------------------------------------------//
// Methods for work with lines (RU:методы для работы со строками)
//------------------------------------------------------------------------------//
// манипуляции айтемами
size_t getItemCount() const;
void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
void addItem(const UString& _name, Any _data = Any::Null);
void removeItemAt(size_t _index);
void removeAllItems();
void swapItemsAt(size_t _index1, size_t _index2);
//------------------------------------------------------------------------------//
// манипуляции отображением
void setItemNameAt(size_t _index, const UString& _name);
const UString& getItemNameAt(size_t _index) const;
//------------------------------------------------------------------------------//
// манипуляции выделениями
size_t getIndexSelected() const;
void setIndexSelected(size_t _index);
void clearIndexSelected();
//------------------------------------------------------------------------------//
// манипуляции данными
void setItemDataAt(size_t _index, Any _data);
void clearItemDataAt(size_t _index);
template<typename ValueType>
ValueType* getItemDataAt(size_t _index, bool _throw = true)
{
return getSubItemDataAt<ValueType>(0, _index, _throw);
}
//------------------------------------------------------------------------------//
// Methods for work with sub lines (RU:методы для работы со саб строками)
//------------------------------------------------------------------------------//
// манипуляции данными
void setSubItemNameAt(size_t _column, size_t _index, const UString& _name);
const UString& getSubItemNameAt(size_t _column, size_t _index) const;
size_t findSubItemWith(size_t _column, const UString& _name);
//------------------------------------------------------------------------------//
// манипуляции данными
void setSubItemDataAt(size_t _column, size_t _index, Any _data);
void clearSubItemDataAt(size_t _column, size_t _index);
template<typename ValueType>
ValueType* getSubItemDataAt(size_t _column, size_t _index, bool _throw = true)
{
MYGUI_ASSERT_RANGE(
_index,
mVectorColumnInfo.begin()->list->getItemCount(),
"MultiListBox::getSubItemDataAt");
size_t index = BiIndexBase::convertToBack(_index);
return getSubItemAt(_column)->getItemDataAt<ValueType>(index, _throw);
}
/*events:*/
EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT> eventListSelectAccept;
EventPair<EventHandle_WidgetSizeT, EventHandle_MultiListPtrSizeT> eventListChangePosition;
EventPair<
EventHandle_MultiListPtrSizeTCUTFStringRefCUTFStringRefBoolRef,
EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef>
requestOperatorLess;
EventHandle_MultiListPtrCIBNotifyCellDataRef eventNotifyItem;
/*internal:*/
// IItemContainer impl
size_t _getItemCount() const override;
void _addItem(const MyGUI::UString& _name) override;
void _removeItemAt(size_t _index) override;
Widget* _getItemAt(size_t _index) const override;
void _setItemNameAt(size_t _index, const UString& _name) override;
const UString& _getItemNameAt(size_t _index) const override;
protected:
void initialiseOverride() override;
void shutdownOverride() override;
void onWidgetCreated(Widget* _widget) override;
void onWidgetDestroy(Widget* _widget) override;
private:
void notifyListChangePosition(ListBox* _sender, size_t _position);
void notifyListChangeFocus(ListBox* _sender, size_t _position);
void notifyListChangeScrollPosition(ListBox* _sender, size_t _position);
void notifyButtonClick(Widget* _sender);
void notifyListSelectAccept(ListBox* _sender, size_t _position);
void notifyListNotifyItem(ListBox* _sender, const MyGUI::IBNotifyItemData& _info);
void updateColumns();
void redrawButtons();
void updateOnlyEmpty();
bool compare(ListBox* _list, size_t _left, size_t _right);
void sortList();
void flipList();
Widget* getOrCreateSeparator(size_t _index);
void updateBackSelected(size_t _index);
struct ColumnInfo
{
MultiListItem* item;
ListBox* list;
Button* button;
int width;
int realWidth;
UString name;
Any data;
ResizingPolicy sizeType;
};
using VectorColumnInfo = std::vector<ColumnInfo>;
void frameEntered(float _frame);
void frameAdvise(bool _advise);
ListBox* getSubItemAt(size_t _column) const;
int getButtonHeight() const;
void _wrapItem(MultiListItem* _item);
void _unwrapItem(MultiListItem* _item);
void _swapColumnsAt(size_t _index1, size_t _index2);
int getColumnWidth(size_t _index, int _freeSpace, size_t _countStars, size_t _lastIndexStar, int _starWidth)
const;
bool getUpdateByResize() const;
int updateWidthColumns(size_t& _countStars, size_t& _lastIndexStar);
private:
int mHeightButton{0};
int mWidthBar{0};
std::string mSkinButton;
std::string mSkinList;
Widget* mWidgetEmpty{nullptr};
VectorColumnInfo mVectorColumnInfo;
VectorWidgetPtr mSeparators;
size_t mLastMouseFocusIndex{ITEM_NONE};
bool mSortUp{true};
size_t mSortColumnIndex{ITEM_NONE};
int mWidthSeparator{0};
std::string mSkinSeparator;
size_t mItemSelected{ITEM_NONE};
bool mFrameAdvise{false};
Widget* mHeaderPlace{nullptr};
};
} // namespace MyGUI
#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_MultiListPtrCIBNotifyCellDataRef
delegates::MultiDelegate< MultiListBox *, const IBNotifyItemData & > EventHandle_MultiListPtrCIBNotifyCellDataRef
Definition MyGUI_MultiListBox.h:32
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_WidgetIntUTFStringUTFStringBool
delegates::MultiDelegate< Widget *, size_t, const UString &, const UString &, bool & > EventHandle_WidgetIntUTFStringUTFStringBool
Definition MyGUI_MultiListBox.h:24
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
MyGUI::IntSize
types::TSize< int > IntSize
Definition MyGUI_Types.h:30
MyGUI::EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef
delegates::Delegate< MultiListBox *, size_t, size_t, size_t, bool & > EventHandle_MultiListPtrSizeTSizeTSizeTBoolRef
Definition MyGUI_MultiListBox.h:29
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::IBNotifyItemData
Definition MyGUI_IBItemInfo.h:68
MyGUI::ResizingPolicy
Definition MyGUI_ResizingPolicy.h:16