ManaPlus
Public Member Functions | Private Types | Private Attributes | Static Private Attributes
RadioButton Class Reference

#include <radiobutton.h>

Inheritance diagram for RadioButton:
Widget MouseListener KeyListener WidgetListener Widget2

Public Member Functions

 RadioButton (const Widget2 *const widget, const std::string &caption, const std::string &group, const bool marked)
 
 ~RadioButton ()
 
void drawBox (Graphics *const graphics)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void mouseEntered (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void keyPressed (KeyEvent &event)
 
void updateAlpha ()
 
void adjustSize ()
 
bool isSelected () const
 
void setSelected (const bool selected)
 
const std::string & getCaption () const
 
void setCaption (const std::string &caption)
 
void mouseClicked (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void setGroup (const std::string &group)
 
const std::string & getGroup () const
 
void setParent (Widget *widget)
 
void widgetHidden (const Event &event)
 
void setWindow (Widget *const widget)
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
virtual void logic ()
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
virtual void setFocusHandler (FocusHandler *const focusHandler)
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
virtual WidgetgetWidgetAt (int x, int y)
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual Rect getChildrenArea ()
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
virtual void moveToTop (Widget *widget)
 
virtual void moveToBottom (Widget *widget)
 
virtual void focusNext ()
 
virtual void focusPrevious ()
 
virtual void showWidgetPart (Widget *const widget, const Rect &area)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- 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
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mousePressed (MouseEvent &event)
 
virtual void mouseReleased (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
virtual void mouseMoved (MouseEvent &event)
 
- Public Member Functions inherited from KeyListener
virtual ~KeyListener ()
 
virtual void keyReleased (KeyEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetResized (const Event &event)
 
virtual void widgetMoved (const Event &event)
 
virtual void widgetShown (const Event &event)
 

Private Types

typedef std::multimap< std::string, RadioButton * > GroupMap
 
typedef GroupMap::iterator GroupIterator
 

Private Attributes

bool mSelected
 
std::string mCaption
 
std::string mGroup
 
TextChunk mTextChunk
 
int mPadding
 
int mImagePadding
 
int mImageSize
 
int mSpacing
 
int mTextX
 
bool mHasMouse
 
bool mTextChanged
 

Static Private Attributes

static int instances = 0
 
static SkinmSkin = 0
 
static float mAlpha = 1.0
 
static GroupMap mGroupMap
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from KeyListener
 KeyListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

Guichan based RadioButton with custom look

Definition at line 85 of file radiobutton.h.

Member Typedef Documentation

◆ GroupIterator

typedef GroupMap::iterator RadioButton::GroupIterator
private

Typdef.

Definition at line 232 of file radiobutton.h.

◆ GroupMap

typedef std::multimap<std::string, RadioButton *> RadioButton::GroupMap
private

Typdef.

Definition at line 227 of file radiobutton.h.

Constructor & Destructor Documentation

◆ RadioButton()

RadioButton::RadioButton ( const Widget2 *const  widget,
const std::string &  caption,
const std::string &  group,
const bool  marked 
)

Constructor.

Definition at line 90 of file radiobutton.cpp.

93  :
94  Widget(widget),
95  MouseListener(),
96  KeyListener(),
98  mSelected(false),
99  mCaption(),
100  mGroup(),
101  mTextChunk(),
102  mPadding(0),
103  mImagePadding(0),
104  mImageSize(9),
105  mSpacing(2),
106  mTextX(0 + 9 + 2),
107  mHasMouse(false),
108  mTextChanged(true)
109 {
110  mAllowLogic = false;
111  setCaption(caption);
112  setGroup(group);
113  setSelected(marked);
114 
115  setFocusable(true);
116  addMouseListener(this);
117  addKeyListener(this);
118 
119  mForegroundColor = getThemeColor(ThemeColorId::RADIOBUTTON, 255U);
120  mForegroundColor2 = getThemeColor(ThemeColorId::RADIOBUTTON_OUTLINE, 255U);
121  if (instances == 0)
122  {
123  if (theme != nullptr)
124  {
125  mSkin = theme->load("radio.xml",
126  "",
127  true,
129  updateAlpha();
130  }
131  }
132 
133  instances++;
134 
135  if (mSkin != nullptr)
136  {
138  mImagePadding = mSkin->getOption("imagePadding");
139  mImageSize = mSkin->getOption("imageSize");
140  mSpacing = mSkin->getOption("spacing");
142  }
143 
144  adjustSize();
145 }
void setGroup(const std::string &group)
TextChunk mTextChunk
Definition: radiobutton.h:222
static Skin * mSkin
Definition: radiobutton.h:204
void setSelected(const bool selected)
std::string mGroup
Definition: radiobutton.h:220
void updateAlpha()
int mImagePadding
Definition: radiobutton.h:240
void adjustSize()
std::string mCaption
Definition: radiobutton.h:215
bool mSelected
Definition: radiobutton.h:210
static int instances
Definition: radiobutton.h:203
bool mHasMouse
Definition: radiobutton.h:244
void setCaption(const std::string &caption)
bool mTextChanged
Definition: radiobutton.h:245
int getOption(const std::string &name) const
Definition: skin.h:106
int getPadding() const
Definition: skin.h:100
static std::string getThemePath()
Definition: theme.h:67
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:179
Color mForegroundColor2
Definition: widget2.h:113
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:45
Color mForegroundColor
Definition: widget.h:1086
void setFocusable(const bool focusable)
Definition: widget.cpp:192
Widget(const Widget2 *const widget)
Definition: widget.cpp:85
bool mAllowLogic
Definition: widget.h:1160
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:292
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:272
Theme * theme
Definition: theme.cpp:62

References Widget::addKeyListener(), Widget::addMouseListener(), adjustSize(), Skin::getOption(), Skin::getPadding(), Widget2::getThemeColor(), Theme::getThemePath(), instances, Theme::load(), Widget::mAllowLogic, Widget::mForegroundColor, Widget2::mForegroundColor2, mImagePadding, mImageSize, mPadding, mSkin, mSpacing, mTextX, setCaption(), Widget::setFocusable(), setGroup(), setSelected(), theme, and updateAlpha().

◆ ~RadioButton()

RadioButton::~RadioButton ( )

Destructor.

Definition at line 147 of file radiobutton.cpp.

148 {
149  if (mWindow != nullptr)
151 
152  setGroup(std::string());
153 
154  if (gui != nullptr)
155  gui->removeDragged(this);
156 
157  instances--;
158 
159  if (instances == 0)
160  {
161  if (theme != nullptr)
162  theme->unload(mSkin);
163  }
164 }
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1162
void unload(Skin *const skin)
Definition: theme.cpp:250
Widget * mWindow
Definition: widget2.h:112
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:307
Gui * gui
Definition: gui.cpp:111

References gui, instances, mSkin, Widget2::mWindow, Gui::removeDragged(), Widget::removeWidgetListener(), setGroup(), theme, and Theme::unload().

Member Function Documentation

◆ adjustSize()

void RadioButton::adjustSize ( )

Definition at line 283 of file radiobutton.cpp.

284 {
285  Font *const font = getFont();
286  setHeight(font->getHeight() + 2 * mPadding);
288  + font->getWidth(mCaption) + mPadding);
289 }
Definition: font.h:90
int getHeight() const
Definition: font.cpp:362
int getWidth(const std::string &text) const
Definition: font.cpp:334
void setWidth(const int width)
Definition: widget.cpp:133
void setHeight(const int height)
Definition: widget.cpp:140
Font * getFont() const
Definition: widget.cpp:331

References Widget::getFont(), Font::getHeight(), Font::getWidth(), mCaption, mImagePadding, mImageSize, mPadding, mSpacing, Widget::setHeight(), and Widget::setWidth().

Referenced by RadioGroup::createWidget(), and RadioButton().

◆ draw()

void RadioButton::draw ( Graphics *const  graphics)
virtual

Implementation of the draw methods. Thus, avoiding the rhomb around the radio button.

Implements Widget.

Definition at line 232 of file radiobutton.cpp.

233 {
234  BLOCK_START("RadioButton::draw")
235  drawBox(graphics);
236 
237  Font *const font = getFont();
238 
239  if (mTextChanged)
240  {
241  mTextChunk.textFont = font;
246  font->generate(mTextChunk);
247  mTextChanged = false;
248  }
249 
250  const Image *const image = mTextChunk.img;
251  if (image != nullptr)
252  graphics->drawImage(image, mTextX, mPadding);
253 
254  BLOCK_END("RadioButton::draw")
255 }
void drawBox(Graphics *const graphics)
void deleteImage()
Definition: textchunk.cpp:193
Font * textFont
Definition: textchunk.h:64
Image * img
Definition: textchunk.h:63
Color color
Definition: textchunk.h:66
Color color2
Definition: textchunk.h:67
std::string text
Definition: textchunk.h:65
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, TextChunk::color, TextChunk::color2, TextChunk::deleteImage(), drawBox(), Graphics::drawImage(), Font::generate(), Widget::getFont(), TextChunk::img, mCaption, Widget::mForegroundColor, Widget2::mForegroundColor2, mPadding, mTextChanged, mTextChunk, mTextX, TextChunk::text, and TextChunk::textFont.

Referenced by safeDraw().

◆ drawBox()

void RadioButton::drawBox ( Graphics *const  graphics)

Draws the radiobutton, not the caption.

Definition at line 187 of file radiobutton.cpp.

188 {
189  if (mSkin == nullptr)
190  return;
191 
192  const ImageRect &rect = mSkin->getBorder();
193  int index = 0;
194 
195  if (mEnabled && mVisible == Visible_true)
196  {
197  if (mSelected)
198  {
199  if (mHasMouse)
200  index = 1;
201  else
202  index = 0;
203  }
204  else
205  {
206  if (mHasMouse)
207  index = 3;
208  else
209  index = 2;
210  }
211  }
212  else
213  {
214  if (mSelected)
215  index = 0;
216  else
217  index = 2;
218  }
219 
220  const Image *const box = rect.grid[index];
221 
222  updateAlpha();
223 
224  if (box != nullptr)
225  {
226  graphics->drawImage(box,
228  (getHeight() - mImageSize) / 2);
229  }
230 }
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
Image * grid[9]
Definition: imagerect.h:42
const ImageRect & getBorder() const
Definition: skin.h:68
bool mEnabled
Definition: widget.h:1158
Visible mVisible
Definition: widget.h:963
int getHeight() const
Definition: widget.h:240
const bool Visible_true
Definition: visible.h:30

References Graphics::drawImage(), Skin::getBorder(), Widget::getHeight(), ImageRect::grid, Widget::mEnabled, mHasMouse, mImagePadding, mImageSize, mSelected, mSkin, Widget::mVisible, updateAlpha(), and Visible_true.

Referenced by draw().

◆ getCaption()

const std::string& RadioButton::getCaption ( ) const
inline

Gets the caption of the radio button.

Returns
The caption of the radio button.
See also
setCaption

Definition at line 160 of file radiobutton.h.

161  { return mCaption; }

References mCaption.

◆ getGroup()

const std::string& RadioButton::getGroup ( ) const
inline

Gets the group the radio button belongs to.

Returns
The group the radio button belongs to.
See also
setGroup

Definition at line 193 of file radiobutton.h.

194  { return mGroup; }

References mGroup.

◆ isSelected()

bool RadioButton::isSelected ( ) const
inline

Checks if the radio button is selected.

Returns
True if the radio button is selecte, false otherwise.
See also
setSelected

Definition at line 142 of file radiobutton.h.

143  { return mSelected; }

References mSelected.

Referenced by QuitDialog::action(), and RegisterDialog::action().

◆ keyPressed()

void RadioButton::keyPressed ( KeyEvent event)
virtual

Called if a key is pressed when the widget has keyboard focus. If a key is held down the widget will generate multiple key presses.

Parameters
eventDiscribes the event.

Reimplemented from KeyListener.

Definition at line 272 of file radiobutton.cpp.

273 {
274  const InputActionT action = event.getActionId();
275  if (action == InputAction::GUI_SELECT)
276  {
277  setSelected(true);
279  event.consume();
280  }
281 }
void distributeActionEvent()
Definition: widget.cpp:493
InputAction ::T InputActionT
Definition: inputaction.h:717

References Widget::distributeActionEvent(), InputAction::GUI_SELECT, and setSelected().

◆ mouseClicked()

void RadioButton::mouseClicked ( MouseEvent event)
virtual

Called when a mouse button is pressed and released (clicked) on the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 308 of file radiobutton.cpp.

309 {
310  if (event.getButton() == MouseButton::LEFT)
311  {
312  setSelected(true);
313  event.consume();
315  }
316 }
MouseButtonT getButton() const
Definition: mouseevent.h:116

References Widget::distributeActionEvent(), MouseEvent::getButton(), MouseButton::LEFT, and setSelected().

◆ mouseDragged()

void RadioButton::mouseDragged ( MouseEvent event)
virtual

Called when the mouse has moved and the mouse has previously been pressed on the widget.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 318 of file radiobutton.cpp.

319 {
320  event.consume();
321 }

◆ mouseEntered()

void RadioButton::mouseEntered ( MouseEvent event)
virtual

Called when the mouse enteres the widget area.

Reimplemented from MouseListener.

Definition at line 262 of file radiobutton.cpp.

263 {
264  mHasMouse = true;
265 }

References mHasMouse.

◆ mouseExited()

void RadioButton::mouseExited ( MouseEvent event)
virtual

Called when the mouse leaves the widget area.

Reimplemented from MouseListener.

Definition at line 267 of file radiobutton.cpp.

268 {
269  mHasMouse = false;
270 }

References mHasMouse.

◆ safeDraw()

void RadioButton::safeDraw ( Graphics *const  graphics)
virtual

Implements Widget.

Definition at line 257 of file radiobutton.cpp.

258 {
259  RadioButton::draw(graphics);
260 }
void draw(Graphics *const graphics)

References draw().

◆ setCaption()

void RadioButton::setCaption ( const std::string &  caption)

Sets the caption of the radio button. It's advisable to call adjustSize after setting of the caption to adjust the radio button's size to fit the caption.

Parameters
captionThe caption of the radio button.
See also
getCaption, adjustSize

Definition at line 346 of file radiobutton.cpp.

347 {
348  if (caption != mCaption)
349  mTextChanged = true;
350  mCaption = caption;
351 }

References mCaption, and mTextChanged.

Referenced by RadioButton().

◆ setGroup()

void RadioButton::setGroup ( const std::string &  group)

Sets the group the radio button should belong to. Note that a radio button group is unique per application, not per Gui object as the group is stored in a static map.

Parameters
groupThe name of the group.
See also
getGroup

Definition at line 323 of file radiobutton.cpp.

324 {
325  if (!mGroup.empty())
326  {
327  for (GroupIterator iter = mGroupMap.lower_bound(mGroup),
328  iterEnd = mGroupMap.upper_bound(mGroup);
329  iter != iterEnd;
330  ++ iter)
331  {
332  if (iter->second == this)
333  {
334  mGroupMap.erase(iter);
335  break;
336  }
337  }
338  }
339 
340  if (!group.empty())
341  mGroupMap.insert(std::pair<std::string, RadioButton *>(group, this));
342 
343  mGroup = group;
344 }
GroupMap::iterator GroupIterator
Definition: radiobutton.h:232
static GroupMap mGroupMap
Definition: radiobutton.h:237

References mGroup, and mGroupMap.

Referenced by RadioButton(), and ~RadioButton().

◆ setParent()

void RadioButton::setParent ( Widget parent)
virtual

Sets the parent of the widget. A parent must be a BasicContainer.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Parameters
parentThe parent of the widget.
See also
getParent

Reimplemented from Widget.

Definition at line 353 of file radiobutton.cpp.

354 {
355  if (mWindow != nullptr)
356  mWindow->addWidgetListener(this);
357  Widget::setParent(widget);
358 }
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:302
virtual void setParent(Widget *parent)
Definition: widget.h:626

References Widget::addWidgetListener(), Widget2::mWindow, and Widget::setParent().

◆ setSelected()

void RadioButton::setSelected ( const bool  selected)

Sets the radio button to selected or not.

Parameters
selectedTrue if the radio button should be selected, false otherwise.
See also
isSelected

Definition at line 291 of file radiobutton.cpp.

292 {
293  if (selected && !mGroup.empty())
294  {
295  for (GroupIterator iter = mGroupMap.lower_bound(mGroup),
296  iterEnd = mGroupMap.upper_bound(mGroup);
297  iter != iterEnd;
298  ++ iter)
299  {
300  if ((iter->second != nullptr) && iter->second->isSelected())
301  iter->second->setSelected(false);
302  }
303  }
304 
305  mSelected = selected;
306 }

References mGroup, mGroupMap, and mSelected.

Referenced by keyPressed(), mouseClicked(), and RadioButton().

◆ setWindow()

void RadioButton::setWindow ( Widget *const  widget)
virtual

Reimplemented from Widget2.

Definition at line 366 of file radiobutton.cpp.

367 {
368  if ((widget == nullptr) && (mWindow != nullptr))
369  {
371  mWindow = nullptr;
372  }
373  else
374  {
375  Widget2::setWindow(widget);
376  }
377 }
virtual void setWindow(Widget *const window)
Definition: widget2.h:97

References Widget2::mWindow, Widget::removeWidgetListener(), and Widget2::setWindow().

◆ updateAlpha()

void RadioButton::updateAlpha ( )

Definition at line 166 of file radiobutton.cpp.

167 {
168  const float alpha = std::max(settings.guiAlpha,
170 
171  if (mAlpha != alpha)
172  {
173  mAlpha = alpha;
174  if (mSkin != nullptr)
175  {
176  const ImageRect &rect = mSkin->getBorder();
177  for (int a = 0; a < 4; a ++)
178  {
179  Image *const image = rect.grid[a];
180  if (image != nullptr)
181  image->setAlpha(mAlpha);
182  }
183  }
184  }
185 }
static float mAlpha
Definition: radiobutton.h:205
float guiAlpha
Definition: settings.h:131
float getMinimumOpacity() const
Definition: theme.h:124
Settings settings
Definition: settings.cpp:32

References Skin::getBorder(), Theme::getMinimumOpacity(), ImageRect::grid, Settings::guiAlpha, mAlpha, mSkin, settings, and theme.

Referenced by drawBox(), and RadioButton().

◆ widgetHidden()

void RadioButton::widgetHidden ( const Event event)
virtual

Invoked when a widget is hidden, i.e it's set to be not visible.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 360 of file radiobutton.cpp.

361 {
362  mTextChanged = true;
364 }

References TextChunk::deleteImage(), mTextChanged, and mTextChunk.

Field Documentation

◆ instances

int RadioButton::instances = 0
staticprivate

Definition at line 203 of file radiobutton.h.

Referenced by RadioButton(), and ~RadioButton().

◆ mAlpha

float RadioButton::mAlpha = 1.0
staticprivate

Definition at line 205 of file radiobutton.h.

Referenced by updateAlpha().

◆ mCaption

std::string RadioButton::mCaption
private

Holds the caption of the radio button.

Definition at line 215 of file radiobutton.h.

Referenced by adjustSize(), draw(), getCaption(), and setCaption().

◆ mGroup

std::string RadioButton::mGroup
private

Holds the group of the radio button.

Definition at line 220 of file radiobutton.h.

Referenced by getGroup(), setGroup(), and setSelected().

◆ mGroupMap

RadioButton::GroupMap RadioButton::mGroupMap
staticprivate

Holds all available radio button groups.

Definition at line 237 of file radiobutton.h.

Referenced by setGroup(), and setSelected().

◆ mHasMouse

bool RadioButton::mHasMouse
private

Definition at line 244 of file radiobutton.h.

Referenced by drawBox(), mouseEntered(), and mouseExited().

◆ mImagePadding

int RadioButton::mImagePadding
private

Definition at line 240 of file radiobutton.h.

Referenced by adjustSize(), drawBox(), and RadioButton().

◆ mImageSize

int RadioButton::mImageSize
private

Definition at line 241 of file radiobutton.h.

Referenced by adjustSize(), drawBox(), and RadioButton().

◆ mPadding

int RadioButton::mPadding
private

Definition at line 239 of file radiobutton.h.

Referenced by adjustSize(), draw(), and RadioButton().

◆ mSelected

bool RadioButton::mSelected
private

True if the radio button is selected, false otherwise.

Definition at line 210 of file radiobutton.h.

Referenced by drawBox(), isSelected(), and setSelected().

◆ mSkin

Skin * RadioButton::mSkin = 0
staticprivate

Definition at line 204 of file radiobutton.h.

Referenced by drawBox(), RadioButton(), updateAlpha(), and ~RadioButton().

◆ mSpacing

int RadioButton::mSpacing
private

Definition at line 242 of file radiobutton.h.

Referenced by adjustSize(), and RadioButton().

◆ mTextChanged

bool RadioButton::mTextChanged
private

Definition at line 245 of file radiobutton.h.

Referenced by draw(), setCaption(), and widgetHidden().

◆ mTextChunk

TextChunk RadioButton::mTextChunk
private

Definition at line 222 of file radiobutton.h.

Referenced by draw(), and widgetHidden().

◆ mTextX

int RadioButton::mTextX
private

Definition at line 243 of file radiobutton.h.

Referenced by draw(), and RadioButton().


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