ManaPlus
Public Member Functions | Protected Attributes
SetupItemSlider Class Reference

#include <setupitem.h>

Inheritance diagram for SetupItemSlider:
SetupItem ActionListener Widget2

Public Member Functions

 SetupItemSlider (const std::string &text, const std::string &description, const std::string &keyName, SetupTabScroll *const parent, const std::string &eventName, const double min, const double max, const double step, const int width, const OnTheFly onTheFly, const MainConfig mainConfig)
 
 SetupItemSlider (const std::string &text, const std::string &description, const std::string &keyName, SetupTabScroll *const parent, const std::string &eventName, const double min, const double max, const double step, const std::string &def, const int width, const OnTheFly onTheFly, const MainConfig mainConfig)
 
 ~SetupItemSlider ()
 
void createControls ()
 
void fromWidget ()
 
void toWidget ()
 
void action (const ActionEvent &event)
 
void apply (const std::string &eventName)
 
void updateLabel ()
 
- Public Member Functions inherited from SetupItem
 ~SetupItem ()
 
void load ()
 
virtual void save ()
 
void setWidget (Widget *widget)
 
WidgetgetWidget () const
 
ConfigurationgetConfig () const
 
virtual std::string getActionEventId () const
 
virtual void doAction ()
 
virtual void cancel (const std::string &eventName)
 
virtual void externalUpdated (const std::string &eventName)
 
virtual void externalUnloaded (const std::string &eventName)
 
MainConfig isMainConfig () const
 
void fixFirstItemSize (Widget *const widget)
 
virtual void rereadValue ()
 
void setValue (const std::string &str)
 
std::string getValue () const
 
std::string getEventName () const
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 

Protected Attributes

HorizontContainermHorizont
 
LabelmLabel
 
SlidermSlider
 
double mMin
 
double mMax
 
double mStep
 
int mWidth
 
OnTheFly mOnTheFly
 
- Protected Attributes inherited from SetupItem
std::string mText
 
std::string mDescription
 
std::string mKeyName
 
SetupTabScrollmParent
 
std::string mEventName
 
std::string mValue
 
std::string mDefault
 
WidgetmWidget
 
std::list< Widget * > mTempWidgets
 
int mValueType
 
MainConfig mMainConfig
 
bool mUseDefault
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 

Additional Inherited Members

- Public Types inherited from SetupItem
enum  { VBOOL = 0 , VSTR , VINT , VNONE }
 
- Protected Member Functions inherited from SetupItem
 SetupItem (const std::string &text, const std::string &description, const std::string &keyName, SetupTabScroll *const parent, const std::string &eventName, const MainConfig mainConfig)
 
 SetupItem (const std::string &text, const std::string &description, const std::string &keyName, SetupTabScroll *const parent, const std::string &eventName, const std::string &def, const MainConfig mainConfig)
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 

Detailed Description

Definition at line 396 of file setupitem.h.

Constructor & Destructor Documentation

◆ SetupItemSlider() [1/2]

SetupItemSlider::SetupItemSlider ( const std::string &  text,
const std::string &  description,
const std::string &  keyName,
SetupTabScroll *const  parent,
const std::string &  eventName,
const double  min,
const double  max,
const double  step,
const int  width,
const OnTheFly  onTheFly,
const MainConfig  mainConfig 
)

Definition at line 873 of file setupitem.cpp.

883  :
884  SetupItem(text, description, keyName, parent, eventName, mainConfig),
885  mHorizont(nullptr),
886  mLabel(nullptr),
887  mSlider(nullptr),
888  mMin(min),
889  mMax(max),
890  mStep(step),
891  mWidth(width),
892  mOnTheFly(onTheFly)
893 {
894  mValueType = VSTR;
895  createControls();
896 }
HorizontContainer * mHorizont
Definition: setupitem.h:441
Label * mLabel
Definition: setupitem.h:442
void createControls()
Definition: setupitem.cpp:932
Slider * mSlider
Definition: setupitem.h:443
OnTheFly mOnTheFly
Definition: setupitem.h:448
SetupItem(const std::string &text, const std::string &description, const std::string &keyName, SetupTabScroll *const parent, const std::string &eventName, const MainConfig mainConfig)
Definition: setupitem.cpp:55
int mValueType
Definition: setupitem.h:147

References createControls(), SetupItem::mValueType, and SetupItem::VSTR.

◆ SetupItemSlider() [2/2]

SetupItemSlider::SetupItemSlider ( const std::string &  text,
const std::string &  description,
const std::string &  keyName,
SetupTabScroll *const  parent,
const std::string &  eventName,
const double  min,
const double  max,
const double  step,
const std::string &  def,
const int  width,
const OnTheFly  onTheFly,
const MainConfig  mainConfig 
)

Definition at line 898 of file setupitem.cpp.

909  :
910  SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
911  mHorizont(nullptr),
912  mLabel(nullptr),
913  mSlider(nullptr),
914  mMin(min),
915  mMax(max),
916  mStep(step),
917  mWidth(width),
918  mOnTheFly(onTheFly)
919 {
920  mValueType = VSTR;
921  createControls();
922 }

References createControls(), SetupItem::mValueType, and SetupItem::VSTR.

◆ ~SetupItemSlider()

SetupItemSlider::~SetupItemSlider ( )

Definition at line 924 of file setupitem.cpp.

925 {
926  mHorizont = nullptr;
927  mWidget = nullptr;
928  mSlider = nullptr;
929  mLabel = nullptr;
930 }
Widget * mWidget
Definition: setupitem.h:143

References mHorizont, mLabel, mSlider, and SetupItem::mWidget.

Member Function Documentation

◆ action()

void SetupItemSlider::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Reimplemented from SetupItem.

Definition at line 974 of file setupitem.cpp.

975 {
976  fromWidget();
977  if (mOnTheFly == OnTheFly_true)
978  save();
979 }
virtual void save()
Definition: setupitem.cpp:146
const bool OnTheFly_true
Definition: onthefly.h:30

References fromWidget(), mOnTheFly, OnTheFly_true, and SetupItem::save().

◆ apply()

void SetupItemSlider::apply ( const std::string &  eventName)
virtual

Reimplemented from SetupItem.

Definition at line 981 of file setupitem.cpp.

982 {
983  if (eventName != mEventName)
984  return;
985 
986  fromWidget();
987  save();
988 }
std::string mEventName
Definition: setupitem.h:137

References fromWidget(), SetupItem::mEventName, and SetupItem::save().

◆ createControls()

void SetupItemSlider::createControls ( )

Definition at line 932 of file setupitem.cpp.

933 {
934  load();
935  mHorizont = new HorizontContainer(this, 32, 2);
936 
937  mLabel = new Label(this, mText);
939  mSlider = new Slider(this, mMin, mMax, mStep);
942  mSlider->setValue(atof(mValue.c_str()));
943  mSlider->setHeight(30);
944 
945  mWidget = mSlider;
947  mSlider->setHeight(40);
949  mHorizont->add(mLabel);
950  mHorizont->add(mSlider, -10);
951 
952  mParent->getContainer()->add2(mHorizont, true, 4);
953  mParent->addControl(this);
954  mParent->addActionListener(this);
955  mWidget->addActionListener(this);
956 }
void add(Widget *const widget)
Definition: label.h:91
SetupTabScroll * mParent
Definition: setupitem.h:135
std::string mDescription
Definition: setupitem.h:131
std::string mValue
Definition: setupitem.h:139
void fixFirstItemSize(Widget *const widget)
Definition: setupitem.cpp:198
std::string mText
Definition: setupitem.h:129
void load()
Definition: setupitem.cpp:113
void addControl(SetupItem *const widget)
VertContainer * getContainer() const
Definition: slider.h:89
void setValue(const double value)
Definition: slider.cpp:474
void setToolTip(const std::string &str)
void add2(Widget *const widget, const bool resizable, const int spacing)
void setWidth(const int width)
Definition: widget.cpp:133
void setHeight(const int height)
Definition: widget.cpp:140
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252

References HorizontContainer::add(), VertContainer::add2(), Widget::addActionListener(), SetupTabScroll::addControl(), SetupItem::fixFirstItemSize(), SetupTabScroll::getContainer(), SetupItem::load(), SetupItem::mDescription, SetupItem::mEventName, mHorizont, mLabel, mMax, mMin, SetupItem::mParent, mSlider, mStep, SetupItem::mText, SetupItem::mValue, SetupItem::mWidget, mWidth, Widget::setActionEventId(), Widget::setHeight(), ToolTipListener::setToolTip(), Slider::setValue(), and Widget::setWidth().

Referenced by SetupItemSlider().

◆ fromWidget()

void SetupItemSlider::fromWidget ( )
virtual

Implements SetupItem.

Definition at line 958 of file setupitem.cpp.

959 {
960  if (mSlider == nullptr)
961  return;
962 
964 }
double getValue() const
Definition: slider.h:204
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774

References Slider::getValue(), mSlider, SetupItem::mValue, and Catch::toString().

Referenced by action(), and apply().

◆ toWidget()

void SetupItemSlider::toWidget ( )
virtual

Implements SetupItem.

Definition at line 966 of file setupitem.cpp.

967 {
968  if (mSlider == nullptr)
969  return;
970 
971  mSlider->setValue(atof(mValue.c_str()));
972 }

References mSlider, SetupItem::mValue, and Slider::setValue().

◆ updateLabel()

void SetupItemSlider::updateLabel ( )

Field Documentation

◆ mHorizont

HorizontContainer* SetupItemSlider::mHorizont
protected

Definition at line 441 of file setupitem.h.

Referenced by createControls(), and ~SetupItemSlider().

◆ mLabel

Label* SetupItemSlider::mLabel
protected

Definition at line 442 of file setupitem.h.

Referenced by createControls(), and ~SetupItemSlider().

◆ mMax

double SetupItemSlider::mMax
protected

Definition at line 445 of file setupitem.h.

Referenced by createControls().

◆ mMin

double SetupItemSlider::mMin
protected

Definition at line 444 of file setupitem.h.

Referenced by createControls().

◆ mOnTheFly

OnTheFly SetupItemSlider::mOnTheFly
protected

Definition at line 448 of file setupitem.h.

Referenced by action().

◆ mSlider

Slider* SetupItemSlider::mSlider
protected

Definition at line 443 of file setupitem.h.

Referenced by createControls(), fromWidget(), toWidget(), and ~SetupItemSlider().

◆ mStep

double SetupItemSlider::mStep
protected

Definition at line 446 of file setupitem.h.

Referenced by createControls().

◆ mWidth

int SetupItemSlider::mWidth
protected

Definition at line 447 of file setupitem.h.

Referenced by createControls().


The documentation for this class was generated from the following files: