Vaca::LinkLabel Class Reference

#include <LinkLabel.h>

Inheritance diagram for Vaca::LinkLabel:

Vaca::CustomLabel Vaca::Label Vaca::Widget Vaca::Component Vaca::Referenceable Vaca::NonCopyable

List of all members.


Detailed Description

A link to Internet (or whatever you want).

Public Member Functions

 LinkLabel (const String &urlOrText, Widget *parent, Style style=LinkLabelStyle)
 It creates a LinkLabel.
 LinkLabel (const String &url, const String &text, Widget *parent, Style style=LinkLabelStyle)
 LinkLabel (const String &url, Image &image, Widget *parent, Style style=LinkLabelStyle)
virtual ~LinkLabel ()
virtual void setFont (Font font)
 Sets the font of the widget.
virtual Color getLinkColor ()
virtual Color getHoverColor ()

Public Attributes

Signal1< void, Event & > Action

Protected Member Functions

virtual void onPreferredSize (Size &sz)
 Returns the preferred size of the label using Graphics::measureString.
virtual void onPaint (Graphics &g)
 Draws the background and the label.
virtual void onMouseEnter (MouseEvent &ev)
 The mouse enters in the Widget.
virtual void onMouseMove (MouseEvent &ev)
 The mouse is moving inside the Widget's client area.
virtual void onMouseLeave ()
 The mouse leaves the Widget.
virtual void onMouseDown (MouseEvent &ev)
 Opens the URL (if it's not empty), and calls the onAction event.
virtual void onSetCursor (WidgetHitTest hitTest)
 Uses the Cursor::Hand when the mouse is over the label.
virtual void onGotFocus (Event &ev)
virtual void onLostFocus (Event &ev)
virtual void onKeyDown (KeyEvent &ev)
 The user presses a key.
virtual void onAction (Event &ev)
 If the label is resized, we must to redraw it.

Private Types

enum  State { Outside, Inside, Hover }

Private Member Functions

void init (String text, Image *image=NULL)
void action ()
void updateFont (const Font &font)
Rect getLinkBounds (Graphics &g)

Private Attributes

State m_state
String m_url
Font m_underlineFont
Imagem_image

Member Enumeration Documentation

enum Vaca::LinkLabel::State [private]

Enumerator:
Outside 
Inside 
Hover 


Constructor & Destructor Documentation

LinkLabel::LinkLabel ( const String urlOrText,
Widget parent,
Style  style = LinkLabelStyle 
)

It creates a LinkLabel.

Parameters:
urlOrText If it contains "www", "://", or "@@", the LinkLabel'll open the browser when it's clicked. If not, it's just like test, and you should hook the LinkLabel::Action signal or LinkLabel::onAction event.
parent It's a Widget (generally a Frame) that will act as the container parent of the new LinkLabel.
style Style to put to this widget.

LinkLabel::LinkLabel ( const String url,
const String text,
Widget parent,
Style  style = LinkLabelStyle 
)

LinkLabel::LinkLabel ( const String url,
Image image,
Widget parent,
Style  style = LinkLabelStyle 
)

LinkLabel::~LinkLabel (  )  [virtual]


Member Function Documentation

void LinkLabel::setFont ( Font  font  )  [virtual]

Sets the font of the widget.

Reimplemented from Vaca::Widget.

Color LinkLabel::getLinkColor (  )  [virtual]

Color LinkLabel::getHoverColor (  )  [virtual]

void LinkLabel::onPreferredSize ( Size sz  )  [protected, virtual]

Returns the preferred size of the label using Graphics::measureString.

Reimplemented from Vaca::Label.

void LinkLabel::onPaint ( Graphics g  )  [protected, virtual]

Draws the background and the label.

By default, the background color is getBgColor() and the label color is getLinkColor(), if the mouse is over the label, it's drawn using the m_underlineFont font and the getHoverColor() color.

Reimplemented from Vaca::Widget.

void LinkLabel::onMouseEnter ( MouseEvent ev  )  [protected, virtual]

The mouse enters in the Widget.

Win32 Specific:
This event is generated when the first WM_MOUSEMOVE(W32) message is received.

Reimplemented from Vaca::Widget.

void LinkLabel::onMouseMove ( MouseEvent ev  )  [protected, virtual]

The mouse is moving inside the Widget's client area.

If you capture the mouse, you should use the System::getCursorPos function to get the cursor position when it's outside the widget's client area.

Reimplemented from Vaca::Widget.

void LinkLabel::onMouseLeave (  )  [protected, virtual]

The mouse leaves the Widget.

Win32 Specific:
This event is generated when WM_MOUSELEAVE(W32) message is received.

Reimplemented from Vaca::Widget.

void LinkLabel::onMouseDown ( MouseEvent ev  )  [protected, virtual]

Opens the URL (if it's not empty), and calls the onAction event.

Reimplemented from Vaca::Widget.

void LinkLabel::onSetCursor ( WidgetHitTest  hitTest  )  [protected, virtual]

Uses the Cursor::Hand when the mouse is over the label.

Reimplemented from Vaca::Widget.

void LinkLabel::onGotFocus ( Event ev  )  [protected, virtual]

Todo:
docme

Reimplemented from Vaca::Widget.

void LinkLabel::onLostFocus ( Event ev  )  [protected, virtual]

Todo:
docme

Reimplemented from Vaca::Widget.

void LinkLabel::onKeyDown ( KeyEvent ev  )  [protected, virtual]

The user presses a key.

Parameters:
ev Has the information about the key pressed.
Win32 Specific:
If KeyEvent::getKeyCode is not 0 the received message was WM_KEYDOWN(W32), otherwise KeyEvent::getCharCode is not 0 and the message was WM_CHAR(W32).

Reimplemented from Vaca::Widget.

void LinkLabel::onAction ( Event ev  )  [protected, virtual]

If the label is resized, we must to redraw it.

This is necessary mainly if the LinkLabel isn't TextAlign::Left. Called when the user press the mouse button down over the label.

void LinkLabel::init ( String  text,
Image image = NULL 
) [private]

void LinkLabel::action (  )  [private]

void LinkLabel::updateFont ( const Font font  )  [private]

Rect LinkLabel::getLinkBounds ( Graphics g  )  [private]


Member Data Documentation

See also:
onAction