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

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

457  :
458  SetupItem(text, description, keyName, parent, eventName, mainConfig),
459  mHorizont(nullptr),
460  mLabel(nullptr),
461  mTextField(nullptr),
462  mButton(nullptr),
463  mEditDialog(nullptr),
464  mMin(min),
465  mMax(max)
466 {
467  mValueType = VSTR;
468  createControls();
469 }
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 471 of file setupitem.cpp.

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

482  :
483  SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
484  mHorizont(nullptr),
485  mLabel(nullptr),
486  mTextField(nullptr),
487  mButton(nullptr),
488  mEditDialog(nullptr),
489  mMin(min),
490  mMax(max)
491 {
492  mValueType = VSTR;
493  createControls();
494 }
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 496 of file setupitem.cpp.

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

497 {
498  mHorizont = nullptr;
499  mWidget = nullptr;
500  mTextField = nullptr;
501  mLabel = nullptr;
502  mButton = nullptr;
503 }
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 551 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().

552 {
553  if (mTextField == nullptr)
554  return;
555 
556  const std::string &eventId = event.getId();
557  if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
558  {
559  fromWidget();
560  }
561  else if (eventId == mEventName + "_EDIT")
562  {
564  mText,
565  mTextField->getText(),
566  mEventName + "_EDIT_OK",
567  300,
568  nullptr,
569  Modal_true);
571  }
572  else if (eventId == mEventName + "_EDIT_OK")
573  {
574  mTextField->setValue(atoi(mEditDialog->getMsg().c_str()));
575  mEditDialog = nullptr;
576  }
577 }
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 579 of file setupitem.cpp.

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

580 {
581  if (eventName != mEventName)
582  return;
583 
584  fromWidget();
585  save();
586 }
std::string mEventName
Definition: setupitem.h:136
virtual void save()
Definition: setupitem.cpp:145

◆ createControls()

void SetupItemIntTextField::createControls ( )

Definition at line 505 of file setupitem.cpp.

References _, HorizontContainer::add(), VertContainer::add2(), Widget::addActionListener(), SetupTabScroll::addControl(), 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().

506 {
507  load();
508  mHorizont = new HorizontContainer(this, 32, 2);
509 
510  mLabel = new Label(this, mText);
512  mTextField = new IntTextField(this, atoi(mValue.c_str()),
513  mMin, mMax, Enable_true, 30);
516 
517  // TRANSLATORS: setup item button
518  mButton = new Button(this, _("Edit"), mEventName + "_EDIT", mParent);
520  mTextField->setWidth(50);
522  mHorizont->add(mLabel);
525 
526  mParent->getContainer()->add2(mHorizont, true, 4);
527  mParent->addControl(this);
528  mParent->addControl(this, mEventName + "_EDIT");
529  mParent->addControl(this, mEventName + "_EDIT_OK");
530  mParent->addActionListener(this);
531  mWidget->addActionListener(this);
532  mButton->addActionListener(this);
533 }
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:94
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
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 535 of file setupitem.cpp.

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

Referenced by action(), and apply().

536 {
537  if (mTextField == nullptr)
538  return;
539 
541 }
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 543 of file setupitem.cpp.

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

544 {
545  if (mTextField == nullptr)
546  return;
547 
549 }
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: