FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
fcn::ClickLabel Class Reference

Implementation of a label capable of displaying a single or multiline caption. More...

#include <clicklabel.h>

Inherits Widget, MouseListener, KeyListener, FocusListener, and WidgetListener.

+ Collaboration diagram for fcn::ClickLabel:

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::GuiFontmGuiFont
 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
captionThe caption of the label.

Definition at line 54 of file clicklabel.cpp.

References adjustSize(), mGuiFont, mHasMouse, mKeyPressed, mMousePressed, mTextWrapping, setAlignment(), setCaption(), and setOpaque().

fcn::ClickLabel::~ClickLabel ( )
virtual

Definition at line 72 of file clicklabel.cpp.

Member Function Documentation

void fcn::ClickLabel::adjustSize ( )
virtual
void fcn::ClickLabel::ancestorHidden ( const Event &  event)
virtual

Definition at line 269 of file clicklabel.cpp.

References mHasMouse, mKeyPressed, and mMousePressed.

void fcn::ClickLabel::focusLost ( const Event &  event)
virtual

Definition at line 263 of file clicklabel.cpp.

References mHasMouse, mKeyPressed, and mMousePressed.

void fcn::ClickLabel::fontChanged ( )
virtual

Definition at line 208 of file clicklabel.cpp.

References adjustSize(), mGuiFont, and wrapText().

Graphics::Alignment fcn::ClickLabel::getAlignment ( ) const
virtual

Gets the alignment of the caption.

The alignment is relative to the center of the label.

Returns
The alignment of caption of the label.
See also
setAlignmentm Graphics

Definition at line 89 of file clicklabel.cpp.

References mAlignment.

Referenced by draw().

+ Here is the caller graph for this function:

const std::string & fcn::ClickLabel::getCaption ( ) const
virtual

Gets the caption of the label.

Returns
The caption of the label.
See also
setCaption

Definition at line 81 of file clicklabel.cpp.

References mCaption.

bool fcn::ClickLabel::isOpaque ( ) const
virtual
Returns
Whether this background is opaque or not.

Definition at line 97 of file clicklabel.cpp.

References mOpaque.

Referenced by draw().

+ Here is the caller graph for this function:

bool fcn::ClickLabel::isTextWrapping ( ) const
virtual

Gets the text wrapping of the caption.

The text will be splitted to the width of the label if it returns true.

Returns
True if text wrapping is enabled, false otherwise.

Definition at line 109 of file clicklabel.cpp.

References mTextWrapping.

Referenced by adjustSize(), draw(), setDimension(), and wrapText().

+ Here is the caller graph for this function:

void fcn::ClickLabel::keyPressed ( KeyEvent &  keyEvent)
virtual

Definition at line 244 of file clicklabel.cpp.

References mKeyPressed.

void fcn::ClickLabel::keyReleased ( KeyEvent &  keyEvent)
virtual

Definition at line 253 of file clicklabel.cpp.

References mKeyPressed.

void fcn::ClickLabel::mouseDragged ( MouseEvent &  mouseEvent)
virtual

Definition at line 240 of file clicklabel.cpp.

void fcn::ClickLabel::mouseEntered ( MouseEvent &  mouseEvent)
virtual

Definition at line 225 of file clicklabel.cpp.

References mHasMouse.

void fcn::ClickLabel::mouseExited ( MouseEvent &  mouseEvent)
virtual

Definition at line 221 of file clicklabel.cpp.

References mHasMouse.

void fcn::ClickLabel::mousePressed ( MouseEvent &  mouseEvent)
virtual

Definition at line 214 of file clicklabel.cpp.

References mMousePressed.

void fcn::ClickLabel::mouseReleased ( MouseEvent &  mouseEvent)
virtual

Definition at line 229 of file clicklabel.cpp.

References mHasMouse, and mMousePressed.

void fcn::ClickLabel::resizeToContent ( bool  recursiv = true)
virtual

Definition at line 128 of file clicklabel.cpp.

References adjustSize().

void fcn::ClickLabel::setAlignment ( Graphics::Alignment  alignment)
virtual

Sets the alignment of the caption.

The alignment is relative to the center of the label.

Parameters
alignemntThe alignment of the caption of the label.
See also
getAlignment, Graphics

Definition at line 85 of file clicklabel.cpp.

References mAlignment.

Referenced by ClickLabel().

+ Here is the caller graph for this function:

void fcn::ClickLabel::setCaption ( const std::string &  caption)
virtual

Sets the caption of the label.

Parameters
captionThe caption of the label.
See also
getCaption, adjustSize

Definition at line 75 of file clicklabel.cpp.

References mCaption, mGuiFont, and wrapText().

Referenced by ClickLabel().

+ Here is the caller graph for this function:

void fcn::ClickLabel::setDimension ( const Rectangle &  dimension)
virtual

Definition at line 120 of file clicklabel.cpp.

References isTextWrapping(), and wrapText().

void fcn::ClickLabel::setOpaque ( bool  opaque)
virtual

Sets the opacity of the background.

Parameters
opaqueTrue if opaque, false otherwise.

Definition at line 93 of file clicklabel.cpp.

References mOpaque.

Referenced by ClickLabel().

+ Here is the caller graph for this function:

void fcn::ClickLabel::setTextWrapping ( bool  textWrapping)
virtual

Sets the text wrapping of the caption.

The text will be splitted to the width of the label if enabled.

Parameters
textWrappingTrue if text wrapping is enabled, false otherwise.

Definition at line 101 of file clicklabel.cpp.

References mTextWrapping, and wrapText().

void fcn::ClickLabel::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().

+ Here is the caller graph for this function:

Member Data Documentation

Graphics::Alignment fcn::ClickLabel::mAlignment
protected

Holds the alignment of the caption.

Definition at line 183 of file clicklabel.h.

Referenced by getAlignment(), and setAlignment().

std::string fcn::ClickLabel::mCaption
protected

Holds the caption of the label.

Definition at line 173 of file clicklabel.h.

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

FIFE::GuiFont* fcn::ClickLabel::mGuiFont
protected

Holds the gui font.

Definition at line 168 of file clicklabel.h.

Referenced by adjustSize(), ClickLabel(), draw(), fontChanged(), setCaption(), and wrapText().

bool fcn::ClickLabel::mHasMouse
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().

bool fcn::ClickLabel::mKeyPressed
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().

bool fcn::ClickLabel::mMousePressed
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().

bool fcn::ClickLabel::mOpaque
protected

True if opaque, otherwise false.

Definition at line 188 of file clicklabel.h.

Referenced by isOpaque(), and setOpaque().

bool fcn::ClickLabel::mTextWrapping
protected

True if text wrapping is enabled, otherwise false.

Definition at line 193 of file clicklabel.h.

Referenced by ClickLabel(), isTextWrapping(), and setTextWrapping().

std::string fcn::ClickLabel::mWrappedText
protected

Holds the wrapped text of the label.

Definition at line 178 of file clicklabel.h.

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


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