ManaPlus
Public Member Functions | Protected Attributes
SetupQuickItem Class Reference

#include <setupquickitem.h>

Inheritance diagram for SetupQuickItem:
SetupItem GameModifierListener ActionListener Widget2

Public Member Functions

 SetupQuickItem (const std::string &description, SetupTabScroll *const parent, const std::string &eventName, ModifierGetFuncPtr getFunc, ModifierChangeFuncPtr changeFunc)
 
 ~SetupQuickItem ()
 
void createControls ()
 
void fromWidget ()
 
void toWidget ()
 
void action (const ActionEvent &event)
 
void apply (const std::string &eventName)
 
void cancel (const std::string &eventName)
 
void externalUpdated (const std::string &eventName)
 
void rereadValue ()
 
void save ()
 
void gameModifiersChanged ()
 
- Public Member Functions inherited from SetupItem
 ~SetupItem ()
 
void load ()
 
void setWidget (Widget *widget)
 
WidgetgetWidget () const
 
ConfigurationgetConfig () const
 
virtual std::string getActionEventId () const
 
virtual void doAction ()
 
virtual void externalUnloaded (const std::string &eventName)
 
MainConfig isMainConfig () const
 
void fixFirstItemSize (Widget *const widget)
 
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)
 
- Public Member Functions inherited from GameModifierListener
 GameModifierListener ()
 
virtual ~ GameModifierListener ()
 

Protected Attributes

HorizontContainermHorizont
 
ButtonmButton
 
LabelmLabel
 
ModifierGetFuncPtr mGetFunc
 
ModifierChangeFuncPtr mChangeFunc
 
- 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 }
 
- Static Public Member Functions inherited from GameModifierListener
static void distributeEvent ()
 
static void addListener (GameModifierListener *const listener)
 
static void removeListener (const GameModifierListener *const listener)
 
- 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 37 of file setupquickitem.h.

Constructor & Destructor Documentation

◆ SetupQuickItem()

SetupQuickItem::SetupQuickItem ( const std::string &  description,
SetupTabScroll *const  parent,
const std::string &  eventName,
ModifierGetFuncPtr  getFunc,
ModifierChangeFuncPtr  changeFunc 
)

Definition at line 33 of file setupquickitem.cpp.

37  :
38  SetupItem("", description, "", parent, eventName, MainConfig_false),
40  mHorizont(nullptr),
41  mButton(nullptr),
42  mLabel(nullptr),
43  mGetFunc(getFunc),
44  mChangeFunc(changeFunc)
45 {
46  mValueType = VSTR;
48 }
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
ModifierGetFuncPtr mGetFunc
HorizontContainer * mHorizont
ModifierChangeFuncPtr mChangeFunc
Button * mButton
const bool MainConfig_false
Definition: mainconfig.h:30

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

◆ ~SetupQuickItem()

SetupQuickItem::~SetupQuickItem ( )

Definition at line 50 of file setupquickitem.cpp.

51 {
52  mHorizont = nullptr;
53  mWidget = nullptr;
54  mButton = nullptr;
55 }
Widget * mWidget
Definition: setupitem.h:143

References mButton, mHorizont, and SetupItem::mWidget.

Member Function Documentation

◆ action()

void SetupQuickItem::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 105 of file setupquickitem.cpp.

106 {
107  if (event.getId() == mEventName + "_CHANGE")
108  {
109  // need change game modifier
110  mChangeFunc(true);
111  toWidget();
112  }
113 }
std::string mEventName
Definition: setupitem.h:137

References ActionEvent::getId(), mChangeFunc, SetupItem::mEventName, and toWidget().

◆ apply()

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

Reimplemented from SetupItem.

Definition at line 115 of file setupquickitem.cpp.

116 {
117 }

◆ cancel()

void SetupQuickItem::cancel ( const std::string &  eventName)
virtual

Reimplemented from SetupItem.

Definition at line 61 of file setupquickitem.cpp.

62 {
63 }

◆ createControls()

void SetupQuickItem::createControls ( )

Definition at line 73 of file setupquickitem.cpp.

74 {
75  mHorizont = new HorizontContainer(this, 32, 2);
76 
77  mWidget = new Button(this,
78  ">",
79  mEventName + "_CHANGE",
81  nullptr);
82  mLabel = new Label(this, std::string());
84  mLabel->adjustSize();
85 
86  mHorizont->add(mWidget, 5);
88 
89  mParent->getContainer()->add2(mHorizont, true, 4);
90  mParent->addControl(this);
92  toWidget();
93 }
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
void add(Widget *const widget)
Definition: label.h:91
void adjustSize()
Definition: label.cpp:200
SetupTabScroll * mParent
Definition: setupitem.h:135
std::string mDescription
Definition: setupitem.h:131
void addControl(SetupItem *const widget)
VertContainer * getContainer() const
void setToolTip(const std::string &str)
void add2(Widget *const widget, const bool resizable, const int spacing)
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252

References HorizontContainer::add(), VertContainer::add2(), Widget::addActionListener(), SetupTabScroll::addControl(), Label::adjustSize(), BUTTON_SKIN, SetupTabScroll::getContainer(), SetupItem::mDescription, SetupItem::mEventName, mHorizont, mLabel, SetupItem::mParent, SetupItem::mWidget, ToolTipListener::setToolTip(), and toWidget().

Referenced by SetupQuickItem().

◆ externalUpdated()

void SetupQuickItem::externalUpdated ( const std::string &  eventName)
virtual

Reimplemented from SetupItem.

Definition at line 65 of file setupquickitem.cpp.

66 {
67 }

◆ fromWidget()

void SetupQuickItem::fromWidget ( )
virtual

Implements SetupItem.

Definition at line 95 of file setupquickitem.cpp.

96 {
97 }

◆ gameModifiersChanged()

void SetupQuickItem::gameModifiersChanged ( )
virtual

Implements GameModifierListener.

Definition at line 119 of file setupquickitem.cpp.

120 {
121  toWidget();
122 }

References toWidget().

◆ rereadValue()

void SetupQuickItem::rereadValue ( )
virtual

Reimplemented from SetupItem.

Definition at line 69 of file setupquickitem.cpp.

70 {
71 }

◆ save()

void SetupQuickItem::save ( )
virtual

Reimplemented from SetupItem.

Definition at line 57 of file setupquickitem.cpp.

58 {
59 }

◆ toWidget()

void SetupQuickItem::toWidget ( )
virtual

Implements SetupItem.

Definition at line 99 of file setupquickitem.cpp.

100 {
102  mLabel->adjustSize();
103 }
void setCaption(const std::string &caption)
Definition: label.cpp:264

References Label::adjustSize(), mGetFunc, mLabel, and Label::setCaption().

Referenced by action(), createControls(), and gameModifiersChanged().

Field Documentation

◆ mButton

Button* SetupQuickItem::mButton
protected

Definition at line 74 of file setupquickitem.h.

Referenced by ~SetupQuickItem().

◆ mChangeFunc

ModifierChangeFuncPtr SetupQuickItem::mChangeFunc
protected

Definition at line 77 of file setupquickitem.h.

Referenced by action().

◆ mGetFunc

ModifierGetFuncPtr SetupQuickItem::mGetFunc
protected

Definition at line 76 of file setupquickitem.h.

Referenced by toWidget().

◆ mHorizont

HorizontContainer* SetupQuickItem::mHorizont
protected

Definition at line 73 of file setupquickitem.h.

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

◆ mLabel

Label* SetupQuickItem::mLabel
protected

Definition at line 75 of file setupquickitem.h.

Referenced by createControls(), and toWidget().


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