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 36 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 32 of file setupquickitem.cpp.

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

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

◆ ~SetupQuickItem()

SetupQuickItem::~SetupQuickItem ( )

Definition at line 49 of file setupquickitem.cpp.

References mButton, mHorizont, and SetupItem::mWidget.

50 {
51  mHorizont = nullptr;
52  mWidget = nullptr;
53  mButton = nullptr;
54 }
HorizontContainer * mHorizont
Widget * mWidget
Definition: setupitem.h:142
Button * mButton

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 100 of file setupquickitem.cpp.

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

101 {
102  if (event.getId() == mEventName + "_CHANGE")
103  {
104  // need change game modifier
105  mChangeFunc(true);
106  toWidget();
107  }
108 }
std::string mEventName
Definition: setupitem.h:136
ModifierChangeFuncPtr mChangeFunc

◆ apply()

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

Reimplemented from SetupItem.

Definition at line 110 of file setupquickitem.cpp.

111 {
112 }

◆ cancel()

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

Reimplemented from SetupItem.

Definition at line 60 of file setupquickitem.cpp.

61 {
62 }

◆ createControls()

void SetupQuickItem::createControls ( )

Definition at line 72 of file setupquickitem.cpp.

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

Referenced by SetupQuickItem().

73 {
74  mHorizont = new HorizontContainer(this, 32, 2);
75 
76  mWidget = new Button(this, ">", mEventName + "_CHANGE", nullptr);
77  mLabel = new Label(this, std::string());
79  mLabel->adjustSize();
80 
81  mHorizont->add(mWidget, 5);
83 
84  mParent->getContainer()->add2(mHorizont, true, 4);
85  mParent->addControl(this);
87  toWidget();
88 }
std::string mEventName
Definition: setupitem.h:136
void addControl(SetupItem *const widget)
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
std::string mDescription
Definition: setupitem.h:130
Definition: button.h:94
VertContainer * getContainer() const
void add2(Widget *const widget, const bool resizable, const int spacing)
HorizontContainer * mHorizont
Definition: label.h:87
Widget * mWidget
Definition: setupitem.h:142
SetupTabScroll * mParent
Definition: setupitem.h:134
void add(Widget *const widget)
void setToolTip(const std::string &str)
void adjustSize()
Definition: label.cpp:197

◆ externalUpdated()

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

Reimplemented from SetupItem.

Definition at line 64 of file setupquickitem.cpp.

65 {
66 }

◆ fromWidget()

void SetupQuickItem::fromWidget ( )
virtual

Implements SetupItem.

Definition at line 90 of file setupquickitem.cpp.

91 {
92 }

◆ gameModifiersChanged()

void SetupQuickItem::gameModifiersChanged ( )
virtual

Implements GameModifierListener.

Definition at line 114 of file setupquickitem.cpp.

References toWidget().

115 {
116  toWidget();
117 }

◆ rereadValue()

void SetupQuickItem::rereadValue ( )
virtual

Reimplemented from SetupItem.

Definition at line 68 of file setupquickitem.cpp.

69 {
70 }

◆ save()

void SetupQuickItem::save ( )
virtual

Reimplemented from SetupItem.

Definition at line 56 of file setupquickitem.cpp.

57 {
58 }

◆ toWidget()

void SetupQuickItem::toWidget ( )
virtual

Implements SetupItem.

Definition at line 94 of file setupquickitem.cpp.

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

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

95 {
97  mLabel->adjustSize();
98 }
void setCaption(const std::string &caption)
Definition: label.cpp:261
ModifierGetFuncPtr mGetFunc
void adjustSize()
Definition: label.cpp:197

Field Documentation

◆ mButton

Button* SetupQuickItem::mButton
protected

Definition at line 73 of file setupquickitem.h.

Referenced by ~SetupQuickItem().

◆ mChangeFunc

ModifierChangeFuncPtr SetupQuickItem::mChangeFunc
protected

Definition at line 76 of file setupquickitem.h.

Referenced by action().

◆ mGetFunc

ModifierGetFuncPtr SetupQuickItem::mGetFunc
protected

Definition at line 75 of file setupquickitem.h.

Referenced by toWidget().

◆ mHorizont

HorizontContainer* SetupQuickItem::mHorizont
protected

Definition at line 72 of file setupquickitem.h.

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

◆ mLabel

Label* SetupQuickItem::mLabel
protected

Definition at line 74 of file setupquickitem.h.

Referenced by createControls(), and toWidget().


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