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

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

874  :
875  SetupItem(text, description, keyName, parent, eventName, mainConfig),
876  mHorizont(nullptr),
877  mLabel(nullptr),
878  mSlider(nullptr),
879  mMin(min),
880  mMax(max),
881  mStep(step),
882  mWidth(width),
883  mOnTheFly(onTheFly)
884 {
885  mValueType = VSTR;
886  createControls();
887 }
int mValueType
Definition: setupitem.h:146
Slider * mSlider
Definition: setupitem.h:442
HorizontContainer * mHorizont
Definition: setupitem.h:440
void createControls()
Definition: setupitem.cpp:923
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 889 of file setupitem.cpp.

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

900  :
901  SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
902  mHorizont(nullptr),
903  mLabel(nullptr),
904  mSlider(nullptr),
905  mMin(min),
906  mMax(max),
907  mStep(step),
908  mWidth(width),
909  mOnTheFly(onTheFly)
910 {
911  mValueType = VSTR;
912  createControls();
913 }
int mValueType
Definition: setupitem.h:146
Slider * mSlider
Definition: setupitem.h:442
HorizontContainer * mHorizont
Definition: setupitem.h:440
void createControls()
Definition: setupitem.cpp:923
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 915 of file setupitem.cpp.

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

916 {
917  mHorizont = nullptr;
918  mWidget = nullptr;
919  mSlider = nullptr;
920  mLabel = nullptr;
921 }
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 965 of file setupitem.cpp.

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

966 {
967  fromWidget();
968  if (mOnTheFly == OnTheFly_true)
969  save();
970 }
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 972 of file setupitem.cpp.

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

973 {
974  if (eventName != mEventName)
975  return;
976 
977  fromWidget();
978  save();
979 }
std::string mEventName
Definition: setupitem.h:136
virtual void save()
Definition: setupitem.cpp:145

◆ createControls()

void SetupItemSlider::createControls ( )

Definition at line 923 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().

924 {
925  load();
926  mHorizont = new HorizontContainer(this, 32, 2);
927 
928  mLabel = new Label(this, mText);
930  mSlider = new Slider(this, mMin, mMax, mStep);
933  mSlider->setValue(atof(mValue.c_str()));
934  mSlider->setHeight(30);
935 
936  mWidget = mSlider;
938  mSlider->setHeight(40);
940  mHorizont->add(mLabel);
941  mHorizont->add(mSlider, -10);
942 
943  mParent->getContainer()->add2(mHorizont, true, 4);
944  mParent->addControl(this);
945  mParent->addActionListener(this);
946  mWidget->addActionListener(this);
947 }
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 949 of file setupitem.cpp.

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

Referenced by action(), and apply().

950 {
951  if (mSlider == nullptr)
952  return;
953 
955 }
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 957 of file setupitem.cpp.

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

958 {
959  if (mSlider == nullptr)
960  return;
961 
962  mSlider->setValue(atof(mValue.c_str()));
963 }
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: