FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
Implementation of a label capable of displaying a single or multiline caption. More...
#include <clicklabel.h>
Inherits Widget, MouseListener, KeyListener, FocusListener, and WidgetListener.
Public Member Functions | |
ClickLabel () | |
Constructor. More... | |
ClickLabel (const std::string &caption) | |
Constructor. More... | |
virtual | ~ClickLabel () |
virtual const std::string & | getCaption () const |
Gets the caption of the label. More... | |
virtual void | setCaption (const std::string &caption) |
Sets the caption of the label. More... | |
virtual void | setAlignment (Graphics::Alignment alignment) |
Sets the alignment of the caption. More... | |
virtual Graphics::Alignment | getAlignment () const |
Gets the alignment of the caption. More... | |
virtual void | setOpaque (bool opaque) |
Sets the opacity of the background. More... | |
virtual bool | isOpaque () const |
virtual void | setTextWrapping (bool textWrapping) |
Sets the text wrapping of the caption. More... | |
virtual bool | isTextWrapping () const |
Gets the text wrapping of the caption. More... | |
virtual void | setDimension (const Rectangle &dimension) |
virtual void | resizeToContent (bool recursiv=true) |
virtual void | adjustSize () |
virtual void | draw (Graphics *graphics) |
virtual void | fontChanged () |
virtual void | focusLost (const Event &event) |
virtual void | mousePressed (MouseEvent &mouseEvent) |
virtual void | mouseReleased (MouseEvent &mouseEvent) |
virtual void | mouseEntered (MouseEvent &mouseEvent) |
virtual void | mouseExited (MouseEvent &mouseEvent) |
virtual void | mouseDragged (MouseEvent &mouseEvent) |
virtual void | keyPressed (KeyEvent &keyEvent) |
virtual void | keyReleased (KeyEvent &keyEvent) |
virtual void | ancestorHidden (const Event &event) |
Protected Member Functions | |
virtual void | wrapText () |
Protected Attributes | |
FIFE::GuiFont * | mGuiFont |
Holds the gui font. More... | |
std::string | mCaption |
Holds the caption of the label. More... | |
std::string | mWrappedText |
Holds the wrapped text of the label. More... | |
Graphics::Alignment | mAlignment |
Holds the alignment of the caption. More... | |
bool | mOpaque |
True if opaque, otherwise false. More... | |
bool | mTextWrapping |
True if text wrapping is enabled, otherwise false. More... | |
bool | mHasMouse |
True if the mouse is ontop of the button, false otherwise. More... | |
bool | mKeyPressed |
True if a key has been pressed, false otherwise. More... | |
bool | mMousePressed |
True if a mouse has been pressed, false otherwise. More... | |
Implementation of a label capable of displaying a single or multiline caption.
In case text wrapping is enabled, the labels width will be the same as the width from the parent. Or as fallback the maximal size parameter is used. If a label is clicked an action event will be sent to all action listener's of the label.
Definition at line 49 of file clicklabel.h.
fcn::ClickLabel::ClickLabel | ( | ) |
Constructor.
Definition at line 38 of file clicklabel.cpp.
References mGuiFont, mHasMouse, mKeyPressed, mMousePressed, mTextWrapping, setAlignment(), and setOpaque().
fcn::ClickLabel::ClickLabel | ( | const std::string & | caption | ) |
Constructor.
The label will be automatically resized to fit the caption.
caption | The caption of the label. |
Definition at line 54 of file clicklabel.cpp.
References adjustSize(), mGuiFont, mHasMouse, mKeyPressed, mMousePressed, mTextWrapping, setAlignment(), setCaption(), and setOpaque().
|
virtual |
Definition at line 72 of file clicklabel.cpp.
|
virtual |
Definition at line 132 of file clicklabel.cpp.
References FIFE::GuiFont::getAsImageMultiline(), FIFE::Image::getHeight(), FIFE::Image::getWidth(), isTextWrapping(), mCaption, mGuiFont, mWrappedText, and FIFE::GuiFont::splitTextToWidth().
Referenced by ClickLabel(), fontChanged(), and resizeToContent().
|
virtual |
Definition at line 269 of file clicklabel.cpp.
References mHasMouse, mKeyPressed, and mMousePressed.
|
virtual |
Definition at line 161 of file clicklabel.cpp.
References FIFE::GuiFont::drawMultiLineString(), getAlignment(), FIFE::GuiFont::getAsImageMultiline(), FIFE::Image::getHeight(), FIFE::Image::getWidth(), isOpaque(), isTextWrapping(), mCaption, mGuiFont, and mWrappedText.
|
virtual |
Definition at line 263 of file clicklabel.cpp.
References mHasMouse, mKeyPressed, and mMousePressed.
|
virtual |
Definition at line 208 of file clicklabel.cpp.
References adjustSize(), mGuiFont, and wrapText().
|
virtual |
Gets the alignment of the caption.
The alignment is relative to the center of the label.
Definition at line 89 of file clicklabel.cpp.
References mAlignment.
Referenced by draw().
|
virtual |
Gets the caption of the label.
Definition at line 81 of file clicklabel.cpp.
References mCaption.
|
virtual |
Definition at line 97 of file clicklabel.cpp.
References mOpaque.
Referenced by draw().
|
virtual |
Gets the text wrapping of the caption.
The text will be splitted to the width of the label if it returns true.
Definition at line 109 of file clicklabel.cpp.
References mTextWrapping.
Referenced by adjustSize(), draw(), setDimension(), and wrapText().
|
virtual |
Definition at line 244 of file clicklabel.cpp.
References mKeyPressed.
|
virtual |
Definition at line 253 of file clicklabel.cpp.
References mKeyPressed.
|
virtual |
Definition at line 240 of file clicklabel.cpp.
|
virtual |
Definition at line 225 of file clicklabel.cpp.
References mHasMouse.
|
virtual |
Definition at line 221 of file clicklabel.cpp.
References mHasMouse.
|
virtual |
Definition at line 214 of file clicklabel.cpp.
References mMousePressed.
|
virtual |
Definition at line 229 of file clicklabel.cpp.
References mHasMouse, and mMousePressed.
|
virtual |
Definition at line 128 of file clicklabel.cpp.
References adjustSize().
|
virtual |
Sets the alignment of the caption.
The alignment is relative to the center of the label.
alignemnt | The alignment of the caption of the label. |
Definition at line 85 of file clicklabel.cpp.
References mAlignment.
Referenced by ClickLabel().
|
virtual |
Sets the caption of the label.
caption | The caption of the label. |
Definition at line 75 of file clicklabel.cpp.
References mCaption, mGuiFont, and wrapText().
Referenced by ClickLabel().
|
virtual |
Definition at line 120 of file clicklabel.cpp.
References isTextWrapping(), and wrapText().
|
virtual |
Sets the opacity of the background.
opaque | True if opaque, false otherwise. |
Definition at line 93 of file clicklabel.cpp.
References mOpaque.
Referenced by ClickLabel().
|
virtual |
Sets the text wrapping of the caption.
The text will be splitted to the width of the label if enabled.
textWrapping | True if text wrapping is enabled, false otherwise. |
Definition at line 101 of file clicklabel.cpp.
References mTextWrapping, and wrapText().
|
protectedvirtual |
Definition at line 113 of file clicklabel.cpp.
References isTextWrapping(), mCaption, mGuiFont, mWrappedText, and FIFE::GuiFont::splitTextToWidth().
Referenced by fontChanged(), setCaption(), setDimension(), and setTextWrapping().
|
protected |
Holds the alignment of the caption.
Definition at line 183 of file clicklabel.h.
Referenced by getAlignment(), and setAlignment().
|
protected |
Holds the caption of the label.
Definition at line 173 of file clicklabel.h.
Referenced by adjustSize(), draw(), getCaption(), setCaption(), and wrapText().
|
protected |
Holds the gui font.
Definition at line 168 of file clicklabel.h.
Referenced by adjustSize(), ClickLabel(), draw(), fontChanged(), setCaption(), and wrapText().
|
protected |
True if the mouse is ontop of the button, false otherwise.
Definition at line 198 of file clicklabel.h.
Referenced by ancestorHidden(), ClickLabel(), focusLost(), mouseEntered(), mouseExited(), and mouseReleased().
|
protected |
True if a key has been pressed, false otherwise.
Definition at line 203 of file clicklabel.h.
Referenced by ancestorHidden(), ClickLabel(), focusLost(), keyPressed(), and keyReleased().
|
protected |
True if a mouse has been pressed, false otherwise.
Definition at line 208 of file clicklabel.h.
Referenced by ancestorHidden(), ClickLabel(), focusLost(), mousePressed(), and mouseReleased().
|
protected |
True if opaque, otherwise false.
Definition at line 188 of file clicklabel.h.
Referenced by isOpaque(), and setOpaque().
|
protected |
True if text wrapping is enabled, otherwise false.
Definition at line 193 of file clicklabel.h.
Referenced by ClickLabel(), isTextWrapping(), and setTextWrapping().
|
protected |
Holds the wrapped text of the label.
Definition at line 178 of file clicklabel.h.
Referenced by adjustSize(), draw(), and wrapText().