![]() |
ManaPlus
|
#include <checkbox.h>
Public Member Functions | |
| CheckBox (const Widget2 *const widget, const std::string &caption, const bool selected, ActionListener *const listener, const std::string &eventId) | |
| ~CheckBox () | |
| void | draw (Graphics *const graphics) |
| void | safeDraw (Graphics *const graphics) |
| void | updateAlpha () |
| void | drawBox (Graphics *const graphics) |
| void | mouseEntered (MouseEvent &event) |
| void | mouseExited (MouseEvent &event) |
| void | keyPressed (KeyEvent &event) |
| 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 | 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 ToolTipListener | |
| ToolTipListener () | |
| void | setToolTip (const std::string &str) |
| std::string | getToolTip () const |
| void | mouseMoved (MouseEvent &event) |
| void | mouseExited (MouseEvent &event) |
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) |
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 Member Functions | |
| void | toggleSelected () |
Private Attributes | |
| bool | mSelected |
| std::string | mCaption |
| TextChunk | mTextChunk |
| int | mPadding |
| int | mImagePadding |
| int | mImageSize |
| int | mSpacing |
| int | mTextX |
| bool | mHasMouse |
| bool | mDrawBox |
| bool | mTextChanged |
Static Private Attributes | |
| static int | instances = 0 |
| static Skin * | mSkin = 0 |
| static float | mAlpha = 1.0 |
Additional Inherited Members | |
Static Public Member Functions inherited from Widget | |
| static void | setGlobalFont (Font *const font) |
| static Font * | getGloablFont () |
| static void | cleanGlobalFont () |
| static bool | widgetExists (const Widget *const widget) |
| static void | distributeWindowResizeEvent () |
| static Widget * | callPostInit (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 |
| FocusHandler * | mFocusHandler |
| FocusHandler * | mInternalFocusHandler |
| Widget * | mParent |
| Font * | mCurrentFont |
| 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 |
| Widget * | mWindow |
| Color | mForegroundColor2 |
Protected Attributes inherited from ToolTipListener | |
| std::string | mToolTip |
Static Protected Attributes inherited from Widget | |
| static Font * | mGlobalFont = 0 |
Check box widget. Same as the Guichan check box but with custom look.
Definition at line 88 of file checkbox.h.
| CheckBox::CheckBox | ( | const Widget2 *const | widget, |
| const std::string & | caption, | ||
| const bool | selected, | ||
| ActionListener *const | listener, | ||
| const std::string & | eventId | ||
| ) |
Constructor.
Definition at line 88 of file checkbox.cpp.
References Widget::addActionListener(), Widget::addKeyListener(), Widget::addMouseListener(), adjustSize(), Skin::getOption(), Skin::getPadding(), Widget2::getThemeColor(), Theme::getThemePath(), instances, anonymous_namespace{itemlinkhandler.cpp}::listener, Theme::load(), Widget::mAllowLogic, mDrawBox, Widget::mForegroundColor, Widget2::mForegroundColor2, mImagePadding, mImageSize, mPadding, mSkin, mSpacing, mTextX, Widget::setActionEventId(), setCaption(), Widget::setFocusable(), theme, and updateAlpha().
| CheckBox::~CheckBox | ( | ) |
Destructor.
Definition at line 150 of file checkbox.cpp.
References gui, instances, mSkin, Widget2::mWindow, Gui::removeDragged(), Widget::removeWidgetListener(), theme, and Theme::unload().
| void CheckBox::adjustSize | ( | ) |
Definition at line 284 of file checkbox.cpp.
References Widget::getFont(), Widget::getHeight(), Widget::getWidth(), mCaption, mImagePadding, mImageSize, mPadding, mSpacing, Widget::setHeight(), and Widget::setWidth().
Referenced by CheckBox().
|
virtual |
Draws the caption, then calls drawBox to draw the check box.
Implements Widget.
Definition at line 167 of file checkbox.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 CheckBox::drawBox | ( | Graphics *const | graphics | ) |
Draws the check box, not the caption.
Definition at line 218 of file checkbox.cpp.
References Graphics::drawImage(), Skin::getBorder(), Widget::getHeight(), ImageRect::grid, mDrawBox, Widget::mEnabled, mHasMouse, mImagePadding, mImageSize, mSelected, mSkin, Widget::mVisible, updateAlpha(), and Visible_true.
Referenced by draw().
|
inline |
Gets the caption of the check box.
Definition at line 165 of file checkbox.h.
References mCaption.
|
inline |
Checks if the check box is selected.
Definition at line 147 of file checkbox.h.
References mSelected.
Referenced by Setup_Joystick::action(), Setup_Video::action(), DidYouKnowWindow::action(), EditServerDialog::action(), LoginDialog::action(), OutfitWindow::action(), ShopWindow::announce(), Setup_Joystick::apply(), Setup_Relations::apply(), Setup_Video::apply(), Setup_Joystick::cancel(), Setup_Video::cancel(), ServerDialog::connectToSelectedServer(), SetupItemCheckBox::fromWidget(), LoginDialog::LoginDialog(), and LoginDialog::prepareUpdate().
|
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 273 of file checkbox.cpp.
References InputAction::GUI_SELECT, and toggleSelected().
|
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 291 of file checkbox.cpp.
References MouseEvent::getButton(), MouseButton::LEFT, and toggleSelected().
|
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 300 of file checkbox.cpp.
|
virtual |
Called when the mouse enteres the widget area.
Reimplemented from MouseListener.
Definition at line 262 of file checkbox.cpp.
References mHasMouse.
|
virtual |
Called when the mouse leaves the widget area.
Reimplemented from MouseListener.
Definition at line 267 of file checkbox.cpp.
References mHasMouse, and ToolTipListener::mouseExited().
|
virtual |
| void CheckBox::setCaption | ( | const std::string & | caption | ) |
Sets the caption of the check box. It's advisable to call adjustSize after setting of the caption to adjust the check box's size to fit the caption.
| caption | The caption of the check box. |
Definition at line 311 of file checkbox.cpp.
References mCaption, and mTextChanged.
Referenced by CheckBox().
|
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 318 of file checkbox.cpp.
References Widget::addWidgetListener(), Widget2::mWindow, and Widget::setParent().
|
inline |
Sets the check box to be selected or not.
| selected | True if the check box should be set as selected. |
Definition at line 156 of file checkbox.h.
References mSelected.
Referenced by LoginDialog::action(), OutfitWindow::action(), Setup_Joystick::cancel(), Setup_Video::cancel(), EditServerDialog::EditServerDialog(), Setup_Relations::externalUpdated(), OutfitWindow::load(), Setup_Joystick::Setup_Joystick(), Setup_Video::Setup_Video(), OutfitWindow::showCurrentOutfit(), SetupItemCheckBox::toWidget(), and Setup_Relations::updatedPlayer().
|
virtual |
Reimplemented from Widget2.
Definition at line 331 of file checkbox.cpp.
References Widget2::mWindow, Widget::removeWidgetListener(), and Widget2::setWindow().
|
private |
Definition at line 305 of file checkbox.cpp.
References Widget::distributeActionEvent(), and mSelected.
Referenced by keyPressed(), and mouseClicked().
| void CheckBox::updateAlpha | ( | ) |
Update the alpha value to the checkbox components.
Definition at line 197 of file checkbox.cpp.
References Skin::getBorder(), Theme::getMinimumOpacity(), ImageRect::grid, Settings::guiAlpha, mAlpha, mSkin, settings, and theme.
Referenced by CheckBox(), and drawBox().
|
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 325 of file checkbox.cpp.
References TextChunk::deleteImage(), mTextChanged, and mTextChunk.
|
staticprivate |
Definition at line 212 of file checkbox.h.
Referenced by CheckBox(), and ~CheckBox().
|
staticprivate |
Definition at line 214 of file checkbox.h.
Referenced by updateAlpha().
|
private |
Holds the caption of the check box.
Definition at line 199 of file checkbox.h.
Referenced by adjustSize(), draw(), getCaption(), and setCaption().
|
private |
Definition at line 209 of file checkbox.h.
Referenced by CheckBox(), and drawBox().
|
private |
Definition at line 208 of file checkbox.h.
Referenced by drawBox(), mouseEntered(), and mouseExited().
|
private |
Definition at line 204 of file checkbox.h.
Referenced by adjustSize(), CheckBox(), and drawBox().
|
private |
Definition at line 205 of file checkbox.h.
Referenced by adjustSize(), CheckBox(), and drawBox().
|
private |
Definition at line 203 of file checkbox.h.
Referenced by adjustSize(), CheckBox(), and draw().
|
private |
True if the check box is selected, false otherwise.
Definition at line 194 of file checkbox.h.
Referenced by drawBox(), isSelected(), setSelected(), and toggleSelected().
|
staticprivate |
Definition at line 213 of file checkbox.h.
Referenced by CheckBox(), drawBox(), updateAlpha(), and ~CheckBox().
|
private |
Definition at line 206 of file checkbox.h.
Referenced by adjustSize(), and CheckBox().
|
private |
Definition at line 210 of file checkbox.h.
Referenced by draw(), setCaption(), and widgetHidden().
|
private |
Definition at line 201 of file checkbox.h.
Referenced by draw(), and widgetHidden().
|
private |
Definition at line 207 of file checkbox.h.
Referenced by CheckBox(), and draw().