1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-29 03:19:44 +00:00
OpenMW/components/widgets/numericeditbox.hpp

51 lines
1.2 KiB
C++
Raw Normal View History

2014-09-25 18:28:00 +00:00
#ifndef OPENMW_NUMERIC_EDIT_BOX_H
#define OPENMW_NUMERIC_EDIT_BOX_H
#include <MyGUI_EditBox.h>
2018-06-18 09:43:39 +00:00
#include "fontwrapper.hpp"
2014-09-25 18:28:00 +00:00
namespace Gui
{
/**
* @brief A variant of the EditBox that only allows integer inputs
*/
2020-02-13 20:36:56 +00:00
class NumericEditBox final : public FontWrapper<MyGUI::EditBox>
2014-09-25 18:28:00 +00:00
{
MYGUI_RTTI_DERIVED(NumericEditBox)
public:
NumericEditBox()
: mValue(0), mMinValue(std::numeric_limits<int>::min()),
mMaxValue(std::numeric_limits<int>::max())
2018-06-18 09:43:39 +00:00
{
}
2014-09-25 18:28:00 +00:00
2020-02-13 20:36:56 +00:00
void initialiseOverride() final;
void shutdownOverride() final;
2014-09-25 18:28:00 +00:00
typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_ValueChanged;
EventHandle_ValueChanged eventValueChanged;
/// @note Does not trigger eventValueChanged
void setValue (int value);
2018-09-18 10:57:21 +00:00
int getValue();
2014-09-25 18:28:00 +00:00
void setMinValue(int minValue);
void setMaxValue(int maxValue);
private:
void onEditTextChange(MyGUI::EditBox* sender);
2020-02-13 20:36:56 +00:00
void onKeyLostFocus(MyGUI::Widget* _new) final;
void onKeyButtonPressed(MyGUI::KeyCode key, MyGUI::Char character) final;
2014-09-25 18:28:00 +00:00
int mValue;
int mMinValue;
int mMaxValue;
};
}
#endif