2019-12-12 17:32:41 +01:00
|
|
|
// Copyright (C) 2006-2012 Michael Zeilfelder
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#ifndef IRR_C_GUI_SPIN_BOX_H_INCLUDED
|
|
|
|
#define IRR_C_GUI_SPIN_BOX_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_GUI_
|
|
|
|
|
|
|
|
#include "IGUISpinBox.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace gui
|
|
|
|
{
|
|
|
|
class IGUIEditBox;
|
|
|
|
class IGUIButton;
|
|
|
|
|
|
|
|
class CGUISpinBox : public IGUISpinBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CGUISpinBox(const wchar_t* text, bool border, IGUIEnvironment* environment,
|
|
|
|
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle);
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~CGUISpinBox();
|
|
|
|
|
|
|
|
//! Access the edit box used in the spin control
|
|
|
|
/** \param enable: If set to true, the override color, which can be set
|
|
|
|
with IGUIEditBox::setOverrideColor is used, otherwise the
|
|
|
|
EGDC_BUTTON_TEXT color of the skin. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IGUIEditBox* getEditBox() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! set the current value of the spinbox
|
|
|
|
/** \param val: value to be set in the spinbox */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setValue(f32 val) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the current value of the spinbox
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual f32 getValue() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! set the range of values which can be used in the spinbox
|
|
|
|
/** \param min: minimum value
|
|
|
|
\param max: maximum value */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setRange(f32 min, f32 max) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! get the minimum value which can be used in the spinbox
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual f32 getMin() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! get the maximum value which can be used in the spinbox
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual f32 getMax() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! step size by which values are changed when pressing the spin buttons
|
|
|
|
/** \param step: stepsize used for value changes when pressing spin buttons */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setStepSize(f32 step=1.f) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! returns the step size
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual f32 getStepSize() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! called if an event happened.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool OnEvent(const SEvent& event) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Draws the element and its children.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void draw() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets the new caption of the element
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setText(const wchar_t* text) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns caption of this element.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const wchar_t* getText() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets the number of decimal places to display.
|
|
|
|
//! Note that this also rounds the range to the same number of decimal places.
|
|
|
|
/** \param places: The number of decimal places to display, use -1 to reset */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setDecimalPlaces(s32 places) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets when the spinbox has to validate entered text.
|
|
|
|
/** \param validateOn Can be any combination of EGUI_SPINBOX_VALIDATION bit flags */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setValidateOn(u32 validateOn) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets when the spinbox has to validate entered text.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getValidateOn() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Writes attributes of the element.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Reads attributes of the element
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void verifyValueRange();
|
|
|
|
void refreshSprites();
|
|
|
|
|
|
|
|
IGUIEditBox * EditBox;
|
|
|
|
IGUIButton * ButtonSpinUp;
|
|
|
|
IGUIButton * ButtonSpinDown;
|
|
|
|
video::SColor CurrentIconColor;
|
|
|
|
f32 StepSize;
|
|
|
|
f32 RangeMin;
|
|
|
|
f32 RangeMax;
|
|
|
|
|
|
|
|
core::stringw FormatString;
|
|
|
|
s32 DecimalPlaces;
|
|
|
|
u32 ValidateOn; // combination of EGUI_SPINBOX_VALIDATION bit-flags
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace gui
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif // _IRR_COMPILE_WITH_GUI_
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#endif // IRR_C_GUI_SPIN_BOX_H_INCLUDED
|