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

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

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

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

487  :
488  SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
489  mHorizont(nullptr),
490  mLabel(nullptr),
491  mTextField(nullptr),
492  mButton(nullptr),
493  mEditDialog(nullptr),
494  mMin(min),
495  mMax(max)
496 {
497  mValueType = VSTR;
498  createControls();
499 }

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

◆ ~SetupItemIntTextField()

SetupItemIntTextField::~SetupItemIntTextField ( )

Definition at line 501 of file setupitem.cpp.

502 {
503  mHorizont = nullptr;
504  mWidget = nullptr;
505  mTextField = nullptr;
506  mLabel = nullptr;
507  mButton = nullptr;
508 }
Widget * mWidget
Definition: setupitem.h:143

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

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

561 {
562  if (mTextField == nullptr)
563  return;
564 
565  const std::string &eventId = event.getId();
566  if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
567  {
568  fromWidget();
569  }
570  else if (eventId == mEventName + "_EDIT")
571  {
573  mText,
574  mTextField->getText(),
575  mEventName + "_EDIT_OK",
576  300,
577  nullptr,
578  Modal_true);
580  }
581  else if (eventId == mEventName + "_EDIT_OK")
582  {
583  mTextField->setValue(atoi(mEditDialog->getMsg().c_str()));
584  mEditDialog = nullptr;
585  }
586 }
std::string getMsg() const
Definition: editdialog.h:65
void setValue(const int value)
std::string mText
Definition: setupitem.h:129
std::string mEventName
Definition: setupitem.h:137
const std::string & getText() const
Definition: textfield.h:224
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
const std::string & getActionEventId() const
Definition: widget.h:605
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
const bool Modal_true
Definition: modal.h:30

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

◆ apply()

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

Reimplemented from SetupItem.

Definition at line 588 of file setupitem.cpp.

589 {
590  if (eventName != mEventName)
591  return;
592 
593  fromWidget();
594  save();
595 }
virtual void save()
Definition: setupitem.cpp:146

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

◆ createControls()

void SetupItemIntTextField::createControls ( )

Definition at line 510 of file setupitem.cpp.

511 {
512  load();
513  mHorizont = new HorizontContainer(this, 32, 2);
514 
515  mLabel = new Label(this, mText);
517  mTextField = new IntTextField(this, atoi(mValue.c_str()),
518  mMin, mMax, Enable_true, 30);
521 
522  mButton = new Button(this,
523  // TRANSLATORS: setup item button
524  _("Edit"),
525  mEventName + "_EDIT",
526  BUTTON_SKIN,
527  mParent);
529  mTextField->setWidth(50);
531  mHorizont->add(mLabel);
534 
535  mParent->getContainer()->add2(mHorizont, true, 4);
536  mParent->addControl(this);
537  mParent->addControl(this, mEventName + "_EDIT");
538  mParent->addControl(this, mEventName + "_EDIT_OK");
539  mParent->addActionListener(this);
540  mWidget->addActionListener(this);
541  mButton->addActionListener(this);
542 }
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
void add(Widget *const widget)
Definition: label.h:91
SetupTabScroll * mParent
Definition: setupitem.h:135
std::string mDescription
Definition: setupitem.h:131
std::string mValue
Definition: setupitem.h:139
void fixFirstItemSize(Widget *const widget)
Definition: setupitem.cpp:198
void load()
Definition: setupitem.cpp:113
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 setWidth(const int width)
Definition: widget.cpp:133
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
const bool Enable_true
Definition: enable.h:30
#define _(s)
Definition: gettext.h:35

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

◆ fromWidget()

void SetupItemIntTextField::fromWidget ( )
virtual

Implements SetupItem.

Definition at line 544 of file setupitem.cpp.

545 {
546  if (mTextField == nullptr)
547  return;
548 
550 }

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

Referenced by action(), and apply().

◆ toWidget()

void SetupItemIntTextField::toWidget ( )
virtual

Implements SetupItem.

Definition at line 552 of file setupitem.cpp.

553 {
554  if (mTextField == nullptr)
555  return;
556 
558 }
void setText(const std::string &text)
Definition: textfield.cpp:803

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

Field Documentation

◆ mButton

Button* SetupItemIntTextField::mButton
protected

Definition at line 279 of file setupitem.h.

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

◆ mEditDialog

EditDialog* SetupItemIntTextField::mEditDialog
protected

Definition at line 280 of file setupitem.h.

Referenced by action().

◆ mHorizont

HorizontContainer* SetupItemIntTextField::mHorizont
protected

Definition at line 276 of file setupitem.h.

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

◆ mLabel

Label* SetupItemIntTextField::mLabel
protected

Definition at line 277 of file setupitem.h.

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

◆ mMax

int SetupItemIntTextField::mMax
protected

Definition at line 282 of file setupitem.h.

Referenced by createControls().

◆ mMin

int SetupItemIntTextField::mMin
protected

Definition at line 281 of file setupitem.h.

Referenced by createControls().

◆ mTextField

IntTextField* SetupItemIntTextField::mTextField
protected

Definition at line 278 of file setupitem.h.

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


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