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

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

763  :
764  SetupItem(text, description, keyName, parent, eventName, mainConfig),
765  mHorizont(nullptr),
766  mLabel(nullptr),
767  mModel(model),
768  mDropDown(nullptr),
769  mWidth(width)
770 {
771  mValueType = VSTR;
772  createControls();
773 }
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 775 of file setupitem.cpp.

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

786  :
787  SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
788  mHorizont(nullptr),
789  mLabel(nullptr),
790  mModel(model),
791  mDropDown(nullptr),
792  mWidth(width)
793 {
794  mValueType = VSTR;
795  createControls();
796 }
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 798 of file setupitem.cpp.

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

799 {
800  mHorizont = nullptr;
801  mWidget = nullptr;
802  mModel = nullptr;
803  mDropDown = nullptr;
804  mLabel = nullptr;
805 }
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 807 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().

808 {
809  load();
810  mHorizont = new HorizontContainer(this, 32, 2);
811 
812  mLabel = new Label(this, mText);
814  mDropDown = new DropDown(this,
815  mModel,
816  false,
817  Modal_false,
818  nullptr,
819  std::string());
824 
825  mWidget = mDropDown;
826  if (!mText.empty())
828  mHorizont->add(mLabel);
830 
831  mParent->getContainer()->add2(mHorizont, true, 4);
832  mParent->addControl(this);
833  mParent->addActionListener(this);
834  mWidget->addActionListener(this);
835 }
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 850 of file setupitem.cpp.

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

851 {
852  if (mDropDown == nullptr)
853  return;
854 
855  const int sel = mDropDown->getSelected();
856  // use first element in model as empty string
857  if (sel == 0 || sel >= mModel->getNumberOfElements())
858  mValue.clear();
859  else
860  mValue = mModel->getElementAt(sel);
861 }
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 837 of file setupitem.cpp.

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

Referenced by createControls(), and toWidget().

838 {
839  const int sz = mModel->getNumberOfElements();
840  for (int f = 0; f < sz; f ++)
841  {
842  if (mModel->getElementAt(f) == mValue)
843  {
844  return f;
845  }
846  }
847  return 0;
848 }
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 863 of file setupitem.cpp.

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

864 {
865  if (mDropDown == nullptr)
866  return;
867 
869 }
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: