ManaPlus
Public Member Functions | Protected Attributes
SetupItemIntTextField Class Reference

#include <setupitem.h>

Inheritance diagram for SetupItemIntTextField:
SetupItem ActionListener Widget2

Public Member Functions

 SetupItemIntTextField (const std::string &text, const std::string &description, const std::string &keyName, SetupTabScroll *const parent, const std::string &eventName, const int min, const int max, const MainConfig mainConfig)
 
 SetupItemIntTextField (const std::string &text, const std::string &description, const std::string &keyName, SetupTabScroll *const parent, const std::string &eventName, const int min, const int max, const std::string &def, const MainConfig mainConfig)
 
 ~SetupItemIntTextField ()
 
void createControls ()
 
void fromWidget ()
 
void toWidget ()
 
void action (const ActionEvent &event)
 
void apply (const std::string &eventName)
 
- 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
 
IntTextFieldmTextField
 
ButtonmButton
 
EditDialogmEditDialog
 
int mMin
 
int mMax
 
- 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 240 of file setupitem.h.

Constructor & Destructor Documentation

◆ SetupItemIntTextField() [1/2]

SetupItemIntTextField::SetupItemIntTextField ( const std::string &  text,
const std::string &  description,
const std::string &  keyName,
SetupTabScroll *const  parent,
const std::string &  eventName,
const int  min,
const int  max,
const MainConfig  mainConfig 
)

Definition at line 451 of file setupitem.cpp.

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

461  :
462  SetupItem(text, description, keyName, parent, eventName, mainConfig),
463  mHorizont(nullptr),
464  mLabel(nullptr),
465  mTextField(nullptr),
466  mButton(nullptr),
467  mEditDialog(nullptr),
468  mMin(min),
469  mMax(max)
470 {
471  mValueType = VSTR;
472  createControls();
473 }
IntTextField * mTextField
Definition: setupitem.h:277
int mValueType
Definition: setupitem.h:146
EditDialog * mEditDialog
Definition: setupitem.h:279
HorizontContainer * mHorizont
Definition: setupitem.h:275
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

◆ SetupItemIntTextField() [2/2]

SetupItemIntTextField::SetupItemIntTextField ( const std::string &  text,
const std::string &  description,
const std::string &  keyName,
SetupTabScroll *const  parent,
const std::string &  eventName,
const int  min,
const int  max,
const std::string &  def,
const MainConfig  mainConfig 
)

Definition at line 475 of file setupitem.cpp.

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

486  :
487  SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
488  mHorizont(nullptr),
489  mLabel(nullptr),
490  mTextField(nullptr),
491  mButton(nullptr),
492  mEditDialog(nullptr),
493  mMin(min),
494  mMax(max)
495 {
496  mValueType = VSTR;
497  createControls();
498 }
IntTextField * mTextField
Definition: setupitem.h:277
int mValueType
Definition: setupitem.h:146
EditDialog * mEditDialog
Definition: setupitem.h:279
HorizontContainer * mHorizont
Definition: setupitem.h:275
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

◆ ~SetupItemIntTextField()

SetupItemIntTextField::~SetupItemIntTextField ( )

Definition at line 500 of file setupitem.cpp.

References mButton, mHorizont, mLabel, mTextField, and SetupItem::mWidget.

501 {
502  mHorizont = nullptr;
503  mWidget = nullptr;
504  mTextField = nullptr;
505  mLabel = nullptr;
506  mButton = nullptr;
507 }
IntTextField * mTextField
Definition: setupitem.h:277
Widget * mWidget
Definition: setupitem.h:142
HorizontContainer * mHorizont
Definition: setupitem.h:275

Member Function Documentation

◆ action()

void SetupItemIntTextField::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 559 of file setupitem.cpp.

References Widget::addActionListener(), CREATEWIDGETR, fromWidget(), Widget::getActionEventId(), EditDialog::getMsg(), TextField::getText(), mEditDialog, SetupItem::mEventName, Modal_true, SetupItem::mText, mTextField, SetupItem::mWidget, and IntTextField::setValue().

560 {
561  if (mTextField == nullptr)
562  return;
563 
564  const std::string &eventId = event.getId();
565  if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
566  {
567  fromWidget();
568  }
569  else if (eventId == mEventName + "_EDIT")
570  {
572  mText,
573  mTextField->getText(),
574  mEventName + "_EDIT_OK",
575  300,
576  nullptr,
577  Modal_true);
579  }
580  else if (eventId == mEventName + "_EDIT_OK")
581  {
582  mTextField->setValue(atoi(mEditDialog->getMsg().c_str()));
583  mEditDialog = nullptr;
584  }
585 }
std::string mEventName
Definition: setupitem.h:136
void setValue(const int value)
std::string getMsg() const
Definition: editdialog.h:65
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
IntTextField * mTextField
Definition: setupitem.h:277
const std::string & getActionEventId() const
Definition: widget.h:604
Widget * mWidget
Definition: setupitem.h:142
EditDialog * mEditDialog
Definition: setupitem.h:279
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
const std::string & getText() const
Definition: textfield.h:223
std::string mText
Definition: setupitem.h:128

◆ apply()

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

Reimplemented from SetupItem.

Definition at line 587 of file setupitem.cpp.

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

588 {
589  if (eventName != mEventName)
590  return;
591 
592  fromWidget();
593  save();
594 }
std::string mEventName
Definition: setupitem.h:136
virtual void save()
Definition: setupitem.cpp:145

◆ createControls()

void SetupItemIntTextField::createControls ( )

Definition at line 509 of file setupitem.cpp.

References _, HorizontContainer::add(), VertContainer::add2(), Widget::addActionListener(), SetupTabScroll::addControl(), BUTTON_SKIN, Enable_true, SetupItem::fixFirstItemSize(), SetupTabScroll::getContainer(), SetupItem::load(), mButton, SetupItem::mDescription, SetupItem::mEventName, mHorizont, mLabel, mMax, mMin, SetupItem::mParent, SetupItem::mText, mTextField, SetupItem::mValue, SetupItem::mWidget, Widget::setActionEventId(), ToolTipListener::setToolTip(), and Widget::setWidth().

Referenced by SetupItemIntTextField().

510 {
511  load();
512  mHorizont = new HorizontContainer(this, 32, 2);
513 
514  mLabel = new Label(this, mText);
516  mTextField = new IntTextField(this, atoi(mValue.c_str()),
517  mMin, mMax, Enable_true, 30);
520 
521  mButton = new Button(this,
522  // TRANSLATORS: setup item button
523  _("Edit"),
524  mEventName + "_EDIT",
525  BUTTON_SKIN,
526  mParent);
528  mTextField->setWidth(50);
530  mHorizont->add(mLabel);
533 
534  mParent->getContainer()->add2(mHorizont, true, 4);
535  mParent->addControl(this);
536  mParent->addControl(this, mEventName + "_EDIT");
537  mParent->addControl(this, mEventName + "_EDIT_OK");
538  mParent->addActionListener(this);
539  mWidget->addActionListener(this);
540  mButton->addActionListener(this);
541 }
void load()
Definition: setupitem.cpp:112
#define _(s)
Definition: gettext.h:34
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
Definition: button.h:96
IntTextField * mTextField
Definition: setupitem.h:277
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
const bool Enable_true
Definition: enable.h:29
VertContainer * getContainer() const
const std::string BUTTON_SKIN
Definition: button.h:88
void add2(Widget *const widget, const bool resizable, const int spacing)
Definition: label.h:87
Widget * mWidget
Definition: setupitem.h:142
SetupTabScroll * mParent
Definition: setupitem.h:134
void add(Widget *const widget)
void fixFirstItemSize(Widget *const widget)
Definition: setupitem.cpp:197
void setToolTip(const std::string &str)
HorizontContainer * mHorizont
Definition: setupitem.h:275
std::string mText
Definition: setupitem.h:128

◆ fromWidget()

void SetupItemIntTextField::fromWidget ( )
virtual

Implements SetupItem.

Definition at line 543 of file setupitem.cpp.

References TextField::getText(), mTextField, and SetupItem::mValue.

Referenced by action(), and apply().

544 {
545  if (mTextField == nullptr)
546  return;
547 
549 }
std::string mValue
Definition: setupitem.h:138
IntTextField * mTextField
Definition: setupitem.h:277
const std::string & getText() const
Definition: textfield.h:223

◆ toWidget()

void SetupItemIntTextField::toWidget ( )
virtual

Implements SetupItem.

Definition at line 551 of file setupitem.cpp.

References mTextField, SetupItem::mValue, and TextField::setText().

552 {
553  if (mTextField == nullptr)
554  return;
555 
557 }
std::string mValue
Definition: setupitem.h:138
IntTextField * mTextField
Definition: setupitem.h:277
void setText(const std::string &text)
Definition: textfield.cpp:802

Field Documentation

◆ mButton

Button* SetupItemIntTextField::mButton
protected

Definition at line 278 of file setupitem.h.

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

◆ mEditDialog

EditDialog* SetupItemIntTextField::mEditDialog
protected

Definition at line 279 of file setupitem.h.

Referenced by action().

◆ mHorizont

HorizontContainer* SetupItemIntTextField::mHorizont
protected

Definition at line 275 of file setupitem.h.

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

◆ mLabel

Label* SetupItemIntTextField::mLabel
protected

Definition at line 276 of file setupitem.h.

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

◆ mMax

int SetupItemIntTextField::mMax
protected

Definition at line 281 of file setupitem.h.

Referenced by createControls().

◆ mMin

int SetupItemIntTextField::mMin
protected

Definition at line 280 of file setupitem.h.

Referenced by createControls().

◆ mTextField

IntTextField* SetupItemIntTextField::mTextField
protected

Definition at line 277 of file setupitem.h.

Referenced by action(), createControls(), fromWidget(), toWidget(), and ~SetupItemIntTextField().


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