MyGUI_ComboBox.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_COMBO_BOX_H_
#define MYGUI_COMBO_BOX_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_EditBox.h"
#include "MyGUI_ListBox.h"
#include "MyGUI_Any.h"
#include "MyGUI_EventPair.h"
#include "MyGUI_ControllerFadeAlpha.h"
#include "MyGUI_FlowDirection.h"
#include "MyGUI_IItem.h"
#include "MyGUI_IItemContainer.h"
namespace MyGUI
{
using EventHandle_ComboBoxPtrSizeT = delegates::MultiDelegate<ComboBox*, size_t>;
class MYGUI_EXPORT ComboBox : public EditBox, public IItemContainer, public MemberObsolete<ComboBox>
{
MYGUI_RTTI_DERIVED(ComboBox)
public:
//------------------------------------------------------------------------------//
// манипуляции айтемами
size_t getItemCount() const;
void insertItemAt(size_t _index, const UString& _item, Any _data = Any::Null);
void addItem(const UString& _name, Any _data = Any::Null);
void removeItemAt(size_t _index);
void removeAllItems();
size_t findItemIndexWith(const UString& _name);
//------------------------------------------------------------------------------//
// манипуляции выделениями
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 mList->getItemDataAt<ValueType>(_index, _throw);
}
//------------------------------------------------------------------------------//
// манипуляции отображением
void setItemNameAt(size_t _index, const UString& _name);
const UString& getItemNameAt(size_t _index) const;
//------------------------------------------------------------------------------//
// манипуляции выдимостью
void beginToItemAt(size_t _index);
void beginToItemFirst();
void beginToItemLast();
void beginToItemSelected();
//------------------------------------------------------------------------------------//
// методы для управления отображением
void setComboModeDrop(bool _drop);
bool getComboModeDrop() const;
void setSmoothShow(bool _value);
bool getSmoothShow() const;
void setMaxListLength(int _value);
int getMaxListLength() const;
// RENAME
void setFlowDirection(FlowDirection _value);
FlowDirection getFlowDirection() const;
/*events:*/
EventPairAddParameter<EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT> eventComboAccept;
EventPair<EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT> eventComboChangePosition;
/*internal:*/
// IItemContainer impl
size_t _getItemCount() const override;
void _addItem(const MyGUI::UString& _name) override;
void _removeItemAt(size_t _index) override;
void _setItemNameAt(size_t _index, const UString& _name) override;
const UString& _getItemNameAt(size_t _index) const override;
void _resetContainer(bool _update) override;
protected:
void initialiseOverride() override;
void shutdownOverride() override;
void onKeyButtonPressed(KeyCode _key, Char _char) override;
void setPropertyOverride(std::string_view _key, std::string_view _value) override;
private:
void notifyButtonPressed(Widget* _sender, int _left, int _top, MouseButton _id);
void notifyListLostFocus(Widget* _sender, MyGUI::Widget* _new);
void notifyListSelectAccept(ListBox* _widget, size_t _position);
void notifyListMouseItemActivate(ListBox* _widget, size_t _position);
void notifyListChangePosition(ListBox* _widget, size_t _position);
void notifyMouseWheel(Widget* _sender, int _rel);
void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
void notifyEditTextChange(EditBox* _sender);
void notifyToolTip(Widget* _sender, const ToolTipInfo& _info);
void showList();
void hideList();
void actionWidgetHide(Widget* _widget, ControllerItem* _controller);
ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
IntCoord calculateListPosition();
private:
Button* mButton{nullptr};
ListBox* mList{nullptr};
bool mListShow{false};
int mMaxListLength{-1};
size_t mItemIndex{ITEM_NONE};
bool mModeDrop{false};
bool mDropMouse{false};
bool mShowSmooth{false};
FlowDirection mFlowDirection{FlowDirection::TopToBottom};
};
} // namespace MyGUI
#endif // MYGUI_COMBO_BOX_H_
MyGUI_Any.h
MyGUI_ControllerFadeAlpha.h
MyGUI_EditBox.h
MyGUI_EventPair.h
MyGUI_FlowDirection.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::Any
Definition MyGUI_Any.h:56
MyGUI::Any::Null
static const Any Null
Definition MyGUI_Any.h:58
MyGUI::Button
widget description should be here.
Definition MyGUI_Button.h:20
MyGUI::ComboBox
widget description should be here.
Definition MyGUI_ComboBox.h:29
MyGUI::ComboBox::addItem
void addItem(const UString &_name, Any _data=Any::Null)
Add an item to the end of a array.
Definition MyGUI_ComboBox.cpp:469
MyGUI::ComboBox::eventComboAccept
EventPairAddParameter< EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT > eventComboAccept
Definition MyGUI_ComboBox.h:143
MyGUI::ComboBox::findItemIndexWith
size_t findItemIndexWith(const UString &_name)
Search item, returns the position of the first occurrence in array or ITEM_NONE if item not found.
Definition MyGUI_ComboBox.cpp:372
MyGUI::ComboBox::_setItemNameAt
void _setItemNameAt(size_t _index, const UString &_name) override
Definition MyGUI_ComboBox.cpp:568
MyGUI::ComboBox::clearIndexSelected
void clearIndexSelected()
Clear item selection.
Definition MyGUI_ComboBox.cpp:479
MyGUI::ComboBox::setIndexSelected
void setIndexSelected(size_t _index)
Select specified _index.
Definition MyGUI_ComboBox.cpp:306
MyGUI::ComboBox::removeAllItems
void removeAllItems()
Remove all items.
Definition MyGUI_ComboBox.cpp:348
MyGUI::ComboBox::_addItem
void _addItem(const MyGUI::UString &_name) override
Definition MyGUI_ComboBox.cpp:558
MyGUI::ComboBox::onKeyButtonPressed
void onKeyButtonPressed(KeyCode _key, Char _char) override
Definition MyGUI_ComboBox.cpp:147
MyGUI::ComboBox::_getItemNameAt
const UString & _getItemNameAt(size_t _index) const override
Definition MyGUI_ComboBox.cpp:573
MyGUI::ComboBox::_removeItemAt
void _removeItemAt(size_t _index) override
Definition MyGUI_ComboBox.cpp:563
MyGUI::ComboBox::shutdownOverride
void shutdownOverride() override
Definition MyGUI_ComboBox.cpp:82
MyGUI::ComboBox::insertItemAt
void insertItemAt(size_t _index, const UString &_item, Any _data=Any::Null)
Insert an item into a array at a specified position.
Definition MyGUI_ComboBox.cpp:334
MyGUI::ComboBox::getIndexSelected
size_t getIndexSelected() const
Get index of selected item (ITEM_NONE if none selected).
Definition MyGUI_ComboBox.cpp:474
MyGUI::ComboBox::initialiseOverride
void initialiseOverride() override
Definition MyGUI_ComboBox.cpp:26
MyGUI::ComboBox::eventComboChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT > eventComboChangePosition
Definition MyGUI_ComboBox.h:150
MyGUI::ComboBox::setItemDataAt
void setItemDataAt(size_t _index, Any _data)
Replace an item data at a specified position.
Definition MyGUI_ComboBox.cpp:327
MyGUI::ComboBox::_getItemCount
size_t _getItemCount() const override
Definition MyGUI_ComboBox.cpp:553
MyGUI::ComboBox::removeItemAt
void removeItemAt(size_t _index)
Remove item at a specified position.
Definition MyGUI_ComboBox.cpp:341
MyGUI::ComboBox::clearItemDataAt
void clearItemDataAt(size_t _index)
Clear an item data at a specified position.
Definition MyGUI_ComboBox.cpp:484
MyGUI::ComboBox::_resetContainer
void _resetContainer(bool _update) override
Definition MyGUI_ComboBox.cpp:578
MyGUI::ComboBox::getItemCount
size_t getItemCount() const
Get number of items.
Definition MyGUI_ComboBox.cpp:464
MyGUI::ComboBox::setPropertyOverride
void setPropertyOverride(std::string_view _key, std::string_view _value) override
Definition MyGUI_ComboBox.cpp:433
MyGUI::ComboBox::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_ComboBox.h:80
MyGUI::ControllerFadeAlpha
Definition MyGUI_ControllerFadeAlpha.h:19
MyGUI::ControllerItem
Definition MyGUI_ControllerItem.h:26
MyGUI::EditBox::EditBox
EditBox()
Definition MyGUI_EditBox.cpp:63
MyGUI::EventPairAddParameter
Definition MyGUI_EventPair.h:176
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::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::delegates::MultiDelegate
Definition MyGUI_Delegate.h:190
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::Char
unsigned int Char
Definition MyGUI_Types.h:50
MyGUI::ITEM_NONE
constexpr size_t ITEM_NONE
Definition MyGUI_Macros.h:19
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
MyGUI::EventHandle_ComboBoxPtrSizeT
delegates::MultiDelegate< ComboBox *, size_t > EventHandle_ComboBoxPtrSizeT
Definition MyGUI_ComboBox.h:23
MyGUI::FlowDirection
Definition MyGUI_FlowDirection.h:19
MyGUI::KeyCode
Definition MyGUI_KeyCode.h:16
MyGUI::MouseButton
Definition MyGUI_MouseButton.h:16
MyGUI::ToolTipInfo
Definition MyGUI_WidgetToolTip.h:18