ManaPlus
|
#include <radiobutton.h>
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 () |
Widget * | getParent () 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 Rect & | getDimension () 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 Color & | getBaseColor () const |
void | setForegroundColor (const Color &color) |
const Color & | getForegroundColor () const |
void | setBackgroundColor (const Color &color) |
const Color & | getBackgroundColor () const |
virtual void | requestFocus () |
virtual void | requestMoveToTop () |
virtual void | requestMoveToBottom () |
virtual void | setFocusHandler (FocusHandler *const focusHandler) |
FocusHandler * | getFocusHandler () |
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 |
Font * | getFont () 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 Widget * | getWidgetAt (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 FocusHandler * | getInternalFocusHandler () |
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 Color & | getThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE |
const Color & | getThemeCharColor (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) |
Widget * | getWindow () 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 Skin * | mSkin = 0 |
static float | mAlpha = 1.0 |
static GroupMap | mGroupMap |
Guichan based RadioButton with custom look
Definition at line 85 of file radiobutton.h.
|
private |
Typdef.
Definition at line 232 of file radiobutton.h.
|
private |
Typdef.
Definition at line 227 of file radiobutton.h.
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.
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 | ( | ) |
Destructor.
Definition at line 147 of file radiobutton.cpp.
References gui, instances, mSkin, Widget2::mWindow, Gui::removeDragged(), Widget::removeWidgetListener(), setGroup(), theme, and Theme::unload().
void RadioButton::adjustSize | ( | ) |
Definition at line 283 of file radiobutton.cpp.
References Widget::getFont(), Font::getHeight(), Font::getWidth(), mCaption, mImagePadding, mImageSize, mPadding, mSpacing, Widget::setHeight(), and Widget::setWidth().
Referenced by RadioGroup::createWidget(), and RadioButton().
|
virtual |
Implementation of the draw methods. Thus, avoiding the rhomb around the radio button.
Implements Widget.
Definition at line 232 of file radiobutton.cpp.
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().
void RadioButton::drawBox | ( | Graphics *const | graphics | ) |
Draws the radiobutton, not the caption.
Definition at line 187 of file radiobutton.cpp.
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().
|
inline |
Gets the caption of the radio button.
Definition at line 160 of file radiobutton.h.
References mCaption.
|
inline |
Gets the group the radio button belongs to.
Definition at line 193 of file radiobutton.h.
References mGroup.
|
inline |
Checks if the radio button is selected.
Definition at line 142 of file radiobutton.h.
References mSelected.
Referenced by QuitDialog::action(), and RegisterDialog::action().
|
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.
event | Discribes the event. |
Reimplemented from KeyListener.
Definition at line 272 of file radiobutton.cpp.
References Widget::distributeActionEvent(), InputAction::GUI_SELECT, and setSelected().
|
virtual |
Called when a mouse button is pressed and released (clicked) on the widget area.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 308 of file radiobutton.cpp.
References Widget::distributeActionEvent(), MouseEvent::getButton(), MouseButton::LEFT, and setSelected().
|
virtual |
Called when the mouse has moved and the mouse has previously been pressed on the widget.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 318 of file radiobutton.cpp.
|
virtual |
Called when the mouse enteres the widget area.
Reimplemented from MouseListener.
Definition at line 262 of file radiobutton.cpp.
References mHasMouse.
|
virtual |
Called when the mouse leaves the widget area.
Reimplemented from MouseListener.
Definition at line 267 of file radiobutton.cpp.
References mHasMouse.
|
virtual |
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.
caption | The caption of the radio button. |
Definition at line 346 of file radiobutton.cpp.
References mCaption, and mTextChanged.
Referenced by RadioButton().
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.
group | The name of the group. |
Definition at line 323 of file radiobutton.cpp.
References mGroup, and mGroupMap.
Referenced by RadioButton(), and ~RadioButton().
|
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.
parent | The parent of the widget. |
Reimplemented from Widget.
Definition at line 353 of file radiobutton.cpp.
References Widget::addWidgetListener(), Widget2::mWindow, and Widget::setParent().
void RadioButton::setSelected | ( | const bool | selected | ) |
Sets the radio button to selected or not.
selected | True if the radio button should be selected, false otherwise. |
Definition at line 291 of file radiobutton.cpp.
References mGroup, mGroupMap, and mSelected.
Referenced by keyPressed(), mouseClicked(), and RadioButton().
|
virtual |
Reimplemented from Widget2.
Definition at line 366 of file radiobutton.cpp.
References Widget2::mWindow, Widget::removeWidgetListener(), and Widget2::setWindow().
void RadioButton::updateAlpha | ( | ) |
Definition at line 166 of file radiobutton.cpp.
References Skin::getBorder(), Theme::getMinimumOpacity(), ImageRect::grid, Settings::guiAlpha, mAlpha, mSkin, settings, and theme.
Referenced by drawBox(), and RadioButton().
|
virtual |
Invoked when a widget is hidden, i.e it's set to be not visible.
event | Describes the event. |
Reimplemented from WidgetListener.
Definition at line 360 of file radiobutton.cpp.
References TextChunk::deleteImage(), mTextChanged, and mTextChunk.
|
staticprivate |
Definition at line 203 of file radiobutton.h.
Referenced by RadioButton(), and ~RadioButton().
|
staticprivate |
Definition at line 205 of file radiobutton.h.
Referenced by updateAlpha().
|
private |
Holds the caption of the radio button.
Definition at line 215 of file radiobutton.h.
Referenced by adjustSize(), draw(), getCaption(), and setCaption().
|
private |
Holds the group of the radio button.
Definition at line 220 of file radiobutton.h.
Referenced by getGroup(), setGroup(), and setSelected().
|
staticprivate |
Holds all available radio button groups.
Definition at line 237 of file radiobutton.h.
Referenced by setGroup(), and setSelected().
|
private |
Definition at line 244 of file radiobutton.h.
Referenced by drawBox(), mouseEntered(), and mouseExited().
|
private |
Definition at line 240 of file radiobutton.h.
Referenced by adjustSize(), drawBox(), and RadioButton().
|
private |
Definition at line 241 of file radiobutton.h.
Referenced by adjustSize(), drawBox(), and RadioButton().
|
private |
Definition at line 239 of file radiobutton.h.
Referenced by adjustSize(), draw(), and RadioButton().
|
private |
True if the radio button is selected, false otherwise.
Definition at line 210 of file radiobutton.h.
Referenced by drawBox(), isSelected(), and setSelected().
|
staticprivate |
Definition at line 204 of file radiobutton.h.
Referenced by drawBox(), RadioButton(), updateAlpha(), and ~RadioButton().
|
private |
Definition at line 242 of file radiobutton.h.
Referenced by adjustSize(), and RadioButton().
|
private |
Definition at line 245 of file radiobutton.h.
Referenced by draw(), setCaption(), and widgetHidden().
|
private |
Definition at line 222 of file radiobutton.h.
Referenced by draw(), and widgetHidden().
|
private |
Definition at line 243 of file radiobutton.h.
Referenced by draw(), and RadioButton().