ManaPlus
Public Member Functions | Protected Attributes
SetupItemDropDownStr Class Reference

#include <setupitem.h>

Inheritance diagram for SetupItemDropDownStr:
SetupItem ActionListener Widget2

Public Member Functions

 SetupItemDropDownStr (const std::string &text, const std::string &description, const std::string &keyName, SetupTabScroll *const parent, const std::string &eventName, ListModel *const model, const int width, const MainConfig mainConfig)
 
 SetupItemDropDownStr (const std::string &text, const std::string &description, const std::string &keyName, SetupTabScroll *const parent, const std::string &eventName, ListModel *const model, const int width, const std::string &def, const MainConfig mainConfig)
 
 ~SetupItemDropDownStr ()
 
void createControls ()
 
void fromWidget ()
 
void toWidget ()
 
int selectionByValue ()
 
- 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
 
void action (const ActionEvent &event)
 
virtual void doAction ()
 
virtual void apply (const std::string &eventName)
 
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
 
ListModelmModel
 
DropDownmDropDown
 
int mWidth
 
- 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 353 of file setupitem.h.

Constructor & Destructor Documentation

◆ SetupItemDropDownStr() [1/2]

SetupItemDropDownStr::SetupItemDropDownStr ( const std::string &  text,
const std::string &  description,
const std::string &  keyName,
SetupTabScroll *const  parent,
const std::string &  eventName,
ListModel *const  model,
const int  width,
const MainConfig  mainConfig 
)

Definition at line 745 of file setupitem.cpp.

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

755  :
756  SetupItem(text, description, keyName, parent, eventName, mainConfig),
757  mHorizont(nullptr),
758  mLabel(nullptr),
759  mModel(model),
760  mDropDown(nullptr),
761  mWidth(width)
762 {
763  mValueType = VSTR;
764  createControls();
765 }
HorizontContainer * mHorizont
Definition: setupitem.h:388
DropDown * mDropDown
Definition: setupitem.h:391
ListModel * mModel
Definition: setupitem.h:390
int mValueType
Definition: setupitem.h:146
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

◆ SetupItemDropDownStr() [2/2]

SetupItemDropDownStr::SetupItemDropDownStr ( const std::string &  text,
const std::string &  description,
const std::string &  keyName,
SetupTabScroll *const  parent,
const std::string &  eventName,
ListModel *const  model,
const int  width,
const std::string &  def,
const MainConfig  mainConfig 
)

Definition at line 767 of file setupitem.cpp.

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

778  :
779  SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
780  mHorizont(nullptr),
781  mLabel(nullptr),
782  mModel(model),
783  mDropDown(nullptr),
784  mWidth(width)
785 {
786  mValueType = VSTR;
787  createControls();
788 }
HorizontContainer * mHorizont
Definition: setupitem.h:388
DropDown * mDropDown
Definition: setupitem.h:391
ListModel * mModel
Definition: setupitem.h:390
int mValueType
Definition: setupitem.h:146
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

◆ ~SetupItemDropDownStr()

SetupItemDropDownStr::~SetupItemDropDownStr ( )

Definition at line 790 of file setupitem.cpp.

References mDropDown, mHorizont, mLabel, mModel, and SetupItem::mWidget.

791 {
792  mHorizont = nullptr;
793  mWidget = nullptr;
794  mModel = nullptr;
795  mDropDown = nullptr;
796  mLabel = nullptr;
797 }
HorizontContainer * mHorizont
Definition: setupitem.h:388
DropDown * mDropDown
Definition: setupitem.h:391
ListModel * mModel
Definition: setupitem.h:390
Widget * mWidget
Definition: setupitem.h:142

Member Function Documentation

◆ createControls()

void SetupItemDropDownStr::createControls ( )

Definition at line 799 of file setupitem.cpp.

References HorizontContainer::add(), VertContainer::add2(), Widget::addActionListener(), SetupTabScroll::addControl(), SetupItem::fixFirstItemSize(), SetupTabScroll::getContainer(), SetupItem::load(), SetupItem::mDescription, mDropDown, SetupItem::mEventName, mHorizont, mLabel, mModel, Modal_false, SetupItem::mParent, SetupItem::mText, SetupItem::mWidget, mWidth, selectionByValue(), Widget::setActionEventId(), DropDown::setSelected(), ToolTipListener::setToolTip(), and Widget::setWidth().

Referenced by SetupItemDropDownStr().

800 {
801  load();
802  mHorizont = new HorizontContainer(this, 32, 2);
803 
804  mLabel = new Label(this, mText);
806  mDropDown = new DropDown(this,
807  mModel,
808  false,
809  Modal_false,
810  nullptr,
811  std::string());
816 
817  mWidget = mDropDown;
818  if (!mText.empty())
820  mHorizont->add(mLabel);
822 
823  mParent->getContainer()->add2(mHorizont, true, 4);
824  mParent->addControl(this);
825  mParent->addActionListener(this);
826  mWidget->addActionListener(this);
827 }
HorizontContainer * mHorizont
Definition: setupitem.h:388
void load()
Definition: setupitem.cpp:112
std::string mEventName
Definition: setupitem.h:136
void addControl(SetupItem *const widget)
void setWidth(const int width)
Definition: widget.cpp:132
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
std::string mDescription
Definition: setupitem.h:130
DropDown * mDropDown
Definition: setupitem.h:391
ListModel * mModel
Definition: setupitem.h:390
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
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)
void setSelected(int selected)
Definition: dropdown.cpp:514
std::string mText
Definition: setupitem.h:128

◆ fromWidget()

void SetupItemDropDownStr::fromWidget ( )
virtual

Implements SetupItem.

Definition at line 842 of file setupitem.cpp.

References ListModel::getElementAt(), ListModel::getNumberOfElements(), DropDown::getSelected(), mDropDown, mModel, and SetupItem::mValue.

843 {
844  if (mDropDown == nullptr)
845  return;
846 
847  const int sel = mDropDown->getSelected();
848  // use first element in model as empty string
849  if (sel == 0 || sel >= mModel->getNumberOfElements())
850  mValue.clear();
851  else
852  mValue = mModel->getElementAt(sel);
853 }
std::string mValue
Definition: setupitem.h:138
DropDown * mDropDown
Definition: setupitem.h:391
virtual int getNumberOfElements()=0
ListModel * mModel
Definition: setupitem.h:390
virtual std::string getElementAt(int i)=0
int getSelected() const
Definition: dropdown.cpp:509

◆ selectionByValue()

int SetupItemDropDownStr::selectionByValue ( )

Definition at line 829 of file setupitem.cpp.

References ListModel::getElementAt(), ListModel::getNumberOfElements(), mModel, and SetupItem::mValue.

Referenced by createControls(), and toWidget().

830 {
831  const int sz = mModel->getNumberOfElements();
832  for (int f = 0; f < sz; f ++)
833  {
834  if (mModel->getElementAt(f) == mValue)
835  {
836  return f;
837  }
838  }
839  return 0;
840 }
std::string mValue
Definition: setupitem.h:138
virtual int getNumberOfElements()=0
ListModel * mModel
Definition: setupitem.h:390
virtual std::string getElementAt(int i)=0

◆ toWidget()

void SetupItemDropDownStr::toWidget ( )
virtual

Implements SetupItem.

Definition at line 855 of file setupitem.cpp.

References mDropDown, selectionByValue(), and DropDown::setSelected().

856 {
857  if (mDropDown == nullptr)
858  return;
859 
861 }
DropDown * mDropDown
Definition: setupitem.h:391
void setSelected(int selected)
Definition: dropdown.cpp:514

Field Documentation

◆ mDropDown

DropDown* SetupItemDropDownStr::mDropDown
protected

Definition at line 391 of file setupitem.h.

Referenced by createControls(), fromWidget(), toWidget(), and ~SetupItemDropDownStr().

◆ mHorizont

HorizontContainer* SetupItemDropDownStr::mHorizont
protected

Definition at line 388 of file setupitem.h.

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

◆ mLabel

Label* SetupItemDropDownStr::mLabel
protected

Definition at line 389 of file setupitem.h.

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

◆ mModel

ListModel* SetupItemDropDownStr::mModel
protected

Definition at line 390 of file setupitem.h.

Referenced by createControls(), fromWidget(), selectionByValue(), and ~SetupItemDropDownStr().

◆ mWidth

int SetupItemDropDownStr::mWidth
protected

Definition at line 392 of file setupitem.h.

Referenced by createControls().


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