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()
|
2014-10-12 21:26:03 +00:00
|
|
|
: 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-10-22 21:57:53 +00:00
|
|
|
void initialiseOverride() override;
|
|
|
|
void shutdownOverride() override;
|
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-10-22 21:57:53 +00:00
|
|
|
void onKeyLostFocus(MyGUI::Widget* _new) override;
|
|
|
|
void onKeyButtonPressed(MyGUI::KeyCode key, MyGUI::Char character) override;
|
2014-09-25 18:28:00 +00:00
|
|
|
|
|
|
|
int mValue;
|
|
|
|
|
|
|
|
int mMinValue;
|
|
|
|
int mMaxValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|