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

764  :
765  SetupItem(text, description, keyName, parent, eventName, mainConfig),
766  mHorizont(nullptr),
767  mLabel(nullptr),
768  mModel(model),
769  mDropDown(nullptr),
770  mWidth(width)
771 {
772  mValueType = VSTR;
773  createControls();
774 }
HorizontContainer * mHorizont
Definition: setupitem.h:389
DropDown * mDropDown
Definition: setupitem.h:392
ListModel * mModel
Definition: setupitem.h:391
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.

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

787  :
788  SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
789  mHorizont(nullptr),
790  mLabel(nullptr),
791  mModel(model),
792  mDropDown(nullptr),
793  mWidth(width)
794 {
795  mValueType = VSTR;
796  createControls();
797 }

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

◆ ~SetupItemDropDownStr()

SetupItemDropDownStr::~SetupItemDropDownStr ( )

Definition at line 799 of file setupitem.cpp.

800 {
801  mHorizont = nullptr;
802  mWidget = nullptr;
803  mModel = nullptr;
804  mDropDown = nullptr;
805  mLabel = nullptr;
806 }
Widget * mWidget
Definition: setupitem.h:143

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

Member Function Documentation

◆ createControls()

void SetupItemDropDownStr::createControls ( )

Definition at line 808 of file setupitem.cpp.

809 {
810  load();
811  mHorizont = new HorizontContainer(this, 32, 2);
812 
813  mLabel = new Label(this, mText);
815  mDropDown = new DropDown(this,
816  mModel,
817  false,
818  Modal_false,
819  nullptr,
820  std::string());
825 
826  mWidget = mDropDown;
827  if (!mText.empty())
829  mHorizont->add(mLabel);
831 
832  mParent->getContainer()->add2(mHorizont, true, 4);
833  mParent->addControl(this);
834  mParent->addActionListener(this);
835  mWidget->addActionListener(this);
836 }
void setSelected(int selected)
Definition: dropdown.cpp:514
void add(Widget *const widget)
Definition: label.h:91
SetupTabScroll * mParent
Definition: setupitem.h:135
std::string mDescription
Definition: setupitem.h:131
void fixFirstItemSize(Widget *const widget)
Definition: setupitem.cpp:198
std::string mText
Definition: setupitem.h:129
void load()
Definition: setupitem.cpp:113
std::string mEventName
Definition: setupitem.h:137
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
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
const bool Modal_false
Definition: modal.h:30

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

◆ fromWidget()

void SetupItemDropDownStr::fromWidget ( )
virtual

Implements SetupItem.

Definition at line 851 of file setupitem.cpp.

852 {
853  if (mDropDown == nullptr)
854  return;
855 
856  const int sel = mDropDown->getSelected();
857  // use first element in model as empty string
858  if (sel == 0 || sel >= mModel->getNumberOfElements())
859  mValue.clear();
860  else
861  mValue = mModel->getElementAt(sel);
862 }
int getSelected() const
Definition: dropdown.cpp:509
virtual std::string getElementAt(int i)=0
virtual int getNumberOfElements()=0
std::string mValue
Definition: setupitem.h:139

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

◆ selectionByValue()

int SetupItemDropDownStr::selectionByValue ( )

Definition at line 838 of file setupitem.cpp.

839 {
840  const int sz = mModel->getNumberOfElements();
841  for (int f = 0; f < sz; f ++)
842  {
843  if (mModel->getElementAt(f) == mValue)
844  {
845  return f;
846  }
847  }
848  return 0;
849 }

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

Referenced by createControls(), and toWidget().

◆ toWidget()

void SetupItemDropDownStr::toWidget ( )
virtual

Implements SetupItem.

Definition at line 864 of file setupitem.cpp.

865 {
866  if (mDropDown == nullptr)
867  return;
868 
870 }

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

Field Documentation

◆ mDropDown

DropDown* SetupItemDropDownStr::mDropDown
protected

Definition at line 392 of file setupitem.h.

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

◆ mHorizont

HorizontContainer* SetupItemDropDownStr::mHorizont
protected

Definition at line 389 of file setupitem.h.

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

◆ mLabel

Label* SetupItemDropDownStr::mLabel
protected

Definition at line 390 of file setupitem.h.

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

◆ mModel

ListModel* SetupItemDropDownStr::mModel
protected

Definition at line 391 of file setupitem.h.

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

◆ mWidth

int SetupItemDropDownStr::mWidth
protected

Definition at line 393 of file setupitem.h.

Referenced by createControls().


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