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 395 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 872 of file setupitem.cpp.

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

882  :
883  SetupItem(text, description, keyName, parent, eventName, mainConfig),
884  mHorizont(nullptr),
885  mLabel(nullptr),
886  mSlider(nullptr),
887  mMin(min),
888  mMax(max),
889  mStep(step),
890  mWidth(width),
891  mOnTheFly(onTheFly)
892 {
893  mValueType = VSTR;
894  createControls();
895 }
int mValueType
Definition: setupitem.h:146
Slider * mSlider
Definition: setupitem.h:442
HorizontContainer * mHorizont
Definition: setupitem.h:440
void createControls()
Definition: setupitem.cpp:931
Label * mLabel
Definition: setupitem.h:441
OnTheFly mOnTheFly
Definition: setupitem.h:447
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:54

◆ 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 897 of file setupitem.cpp.

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

908  :
909  SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
910  mHorizont(nullptr),
911  mLabel(nullptr),
912  mSlider(nullptr),
913  mMin(min),
914  mMax(max),
915  mStep(step),
916  mWidth(width),
917  mOnTheFly(onTheFly)
918 {
919  mValueType = VSTR;
920  createControls();
921 }
int mValueType
Definition: setupitem.h:146
Slider * mSlider
Definition: setupitem.h:442
HorizontContainer * mHorizont
Definition: setupitem.h:440
void createControls()
Definition: setupitem.cpp:931
Label * mLabel
Definition: setupitem.h:441
OnTheFly mOnTheFly
Definition: setupitem.h:447
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:54

◆ ~SetupItemSlider()

SetupItemSlider::~SetupItemSlider ( )

Definition at line 923 of file setupitem.cpp.

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

924 {
925  mHorizont = nullptr;
926  mWidget = nullptr;
927  mSlider = nullptr;
928  mLabel = nullptr;
929 }
Slider * mSlider
Definition: setupitem.h:442
HorizontContainer * mHorizont
Definition: setupitem.h:440
Widget * mWidget
Definition: setupitem.h:142
Label * mLabel
Definition: setupitem.h:441

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 973 of file setupitem.cpp.

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

974 {
975  fromWidget();
976  if (mOnTheFly == OnTheFly_true)
977  save();
978 }
const bool OnTheFly_true
Definition: onthefly.h:29
OnTheFly mOnTheFly
Definition: setupitem.h:447
virtual void save()
Definition: setupitem.cpp:145

◆ apply()

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

Reimplemented from SetupItem.

Definition at line 980 of file setupitem.cpp.

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

981 {
982  if (eventName != mEventName)
983  return;
984 
985  fromWidget();
986  save();
987 }
std::string mEventName
Definition: setupitem.h:136
virtual void save()
Definition: setupitem.cpp:145

◆ createControls()

void SetupItemSlider::createControls ( )

Definition at line 931 of file setupitem.cpp.

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().

932 {
933  load();
934  mHorizont = new HorizontContainer(this, 32, 2);
935 
936  mLabel = new Label(this, mText);
938  mSlider = new Slider(this, mMin, mMax, mStep);
941  mSlider->setValue(atof(mValue.c_str()));
942  mSlider->setHeight(30);
943 
944  mWidget = mSlider;
946  mSlider->setHeight(40);
948  mHorizont->add(mLabel);
949  mHorizont->add(mSlider, -10);
950 
951  mParent->getContainer()->add2(mHorizont, true, 4);
952  mParent->addControl(this);
953  mParent->addActionListener(this);
954  mWidget->addActionListener(this);
955 }
void load()
Definition: setupitem.cpp:112
std::string mEventName
Definition: setupitem.h:136
void addControl(SetupItem *const widget)
void setWidth(const int width)
Definition: widget.cpp:132
std::string mValue
Definition: setupitem.h:138
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
std::string mDescription
Definition: setupitem.h:130
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
VertContainer * getContainer() const
Slider * mSlider
Definition: setupitem.h:442
HorizontContainer * mHorizont
Definition: setupitem.h:440
void add2(Widget *const widget, const bool resizable, const int spacing)
Definition: label.h:87
Widget * mWidget
Definition: setupitem.h:142
Label * mLabel
Definition: setupitem.h:441
SetupTabScroll * mParent
Definition: setupitem.h:134
void add(Widget *const widget)
void fixFirstItemSize(Widget *const widget)
Definition: setupitem.cpp:197
void setHeight(const int height)
Definition: widget.cpp:139
void setToolTip(const std::string &str)
void setValue(const double value)
Definition: slider.cpp:473
Definition: slider.h:85
std::string mText
Definition: setupitem.h:128

◆ fromWidget()

void SetupItemSlider::fromWidget ( )
virtual

Implements SetupItem.

Definition at line 957 of file setupitem.cpp.

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

Referenced by action(), and apply().

958 {
959  if (mSlider == nullptr)
960  return;
961 
963 }
std::string mValue
Definition: setupitem.h:138
Slider * mSlider
Definition: setupitem.h:442
double getValue() const
Definition: slider.h:203
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774

◆ toWidget()

void SetupItemSlider::toWidget ( )
virtual

Implements SetupItem.

Definition at line 965 of file setupitem.cpp.

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

966 {
967  if (mSlider == nullptr)
968  return;
969 
970  mSlider->setValue(atof(mValue.c_str()));
971 }
std::string mValue
Definition: setupitem.h:138
Slider * mSlider
Definition: setupitem.h:442
void setValue(const double value)
Definition: slider.cpp:473

◆ updateLabel()

void SetupItemSlider::updateLabel ( )

Field Documentation

◆ mHorizont

HorizontContainer* SetupItemSlider::mHorizont
protected

Definition at line 440 of file setupitem.h.

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

◆ mLabel

Label* SetupItemSlider::mLabel
protected

Definition at line 441 of file setupitem.h.

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

◆ mMax

double SetupItemSlider::mMax
protected

Definition at line 444 of file setupitem.h.

Referenced by createControls().

◆ mMin

double SetupItemSlider::mMin
protected

Definition at line 443 of file setupitem.h.

Referenced by createControls().

◆ mOnTheFly

OnTheFly SetupItemSlider::mOnTheFly
protected

Definition at line 447 of file setupitem.h.

Referenced by action().

◆ mSlider

Slider* SetupItemSlider::mSlider
protected

Definition at line 442 of file setupitem.h.

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

◆ mStep

double SetupItemSlider::mStep
protected

Definition at line 445 of file setupitem.h.

Referenced by createControls().

◆ mWidth

int SetupItemSlider::mWidth
protected

Definition at line 446 of file setupitem.h.

Referenced by createControls().


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