#include <LinkLabel.h>
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 |
Image * | m_image |
enum Vaca::LinkLabel::State [private] |
It creates a LinkLabel.
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] |
void LinkLabel::setFont | ( | Font | font | ) | [virtual] |
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.
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.
WM_MOUSELEAVE
(W32) message is received. Reimplemented from Vaca::Widget.
void LinkLabel::onMouseDown | ( | MouseEvent & | ev | ) | [protected, virtual] |
void LinkLabel::onSetCursor | ( | WidgetHitTest | hitTest | ) | [protected, virtual] |
void LinkLabel::onGotFocus | ( | Event & | ev | ) | [protected, virtual] |
void LinkLabel::onLostFocus | ( | Event & | ev | ) | [protected, virtual] |
void LinkLabel::onKeyDown | ( | KeyEvent & | ev | ) | [protected, virtual] |
The user presses a key.
ev | Has the information about the key pressed. |
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::action | ( | ) | [private] |
void LinkLabel::updateFont | ( | const Font & | font | ) | [private] |
State Vaca::LinkLabel::m_state [private] |
String Vaca::LinkLabel::m_url [private] |
Font Vaca::LinkLabel::m_underlineFont [private] |
Image* Vaca::LinkLabel::m_image [private] |
Signal1<void, Event&> Vaca::LinkLabel::Action |