]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/hyperlink.h
added alpha channel support to wxDFB's wxBitmap
[wxWidgets.git] / include / wx / generic / hyperlink.h
CommitLineData
c105dda0
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/hyperlink.h
3// Purpose: Hyperlink control
4// Author: David Norris <danorris@gmail.com>, Otto Wyss
5// Modified by: Ryan Norton, Francesco Montorsi
6// Created: 04/02/2005
7// RCS-ID: $Id$
8// Copyright: (c) 2005 David Norris
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
6d020baf
PC
12#ifndef _WX_GENERICHYPERLINKCTRL_H_
13#define _WX_GENERICHYPERLINKCTRL_H_
c105dda0
VZ
14
15// ----------------------------------------------------------------------------
16// wxGenericHyperlinkCtrl
17// ----------------------------------------------------------------------------
18
19class WXDLLIMPEXP_ADV wxGenericHyperlinkCtrl : public wxHyperlinkCtrlBase
20{
21public:
22 // Default constructor (for two-step construction).
23 wxGenericHyperlinkCtrl() { }
24
25 // Constructor.
26 wxGenericHyperlinkCtrl(wxWindow *parent,
27 wxWindowID id,
28 const wxString& label, const wxString& url,
29 const wxPoint& pos = wxDefaultPosition,
30 const wxSize& size = wxDefaultSize,
31 long style = wxHL_DEFAULT_STYLE,
32 const wxString& name = wxHyperlinkCtrlNameStr)
33 {
34 (void)Create(parent, id, label, url, pos, size, style, name);
35 }
36
37 // Creation function (for two-step construction).
38 bool Create(wxWindow *parent,
39 wxWindowID id,
40 const wxString& label, const wxString& url,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = wxHL_DEFAULT_STYLE,
44 const wxString& name = wxHyperlinkCtrlNameStr);
45
46
47 // get/set
48 wxColour GetHoverColour() const { return m_hoverColour; }
49 void SetHoverColour(const wxColour &colour) { m_hoverColour = colour; }
50
51 wxColour GetNormalColour() const { return m_normalColour; }
52 void SetNormalColour(const wxColour &colour);
53
54 wxColour GetVisitedColour() const { return m_visitedColour; }
55 void SetVisitedColour(const wxColour &colour);
56
57 wxString GetURL() const { return m_url; }
58 void SetURL (const wxString &url) { m_url=url; }
59
60 void SetVisited(bool visited = true) { m_visited=visited; }
61 bool GetVisited() const { return m_visited; }
62
63 // NOTE: also wxWindow::Set/GetLabel, wxWindow::Set/GetBackgroundColour,
64 // wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important !
65
66
67protected:
68 // event handlers
69
70 // Renders the hyperlink.
71 void OnPaint(wxPaintEvent& event);
72
73 // Returns the wxRect of the label of this hyperlink.
74 // This is different from the clientsize's rectangle when
75 // clientsize != bestsize and this rectangle is influenced
76 // by the alignment of the label (wxHL_ALIGN_*).
77 wxRect GetLabelRect() const;
78
79 // If the click originates inside the bounding box of the label,
80 // a flag is set so that an event will be fired when the left
81 // button is released.
82 void OnLeftDown(wxMouseEvent& event);
83
84 // If the click both originated and finished inside the bounding box
85 // of the label, a HyperlinkEvent is fired.
86 void OnLeftUp(wxMouseEvent& event);
87 void OnRightUp(wxMouseEvent& event);
88
89 // Changes the cursor to a hand, if the mouse is inside the label's
90 // bounding box.
91 void OnMotion(wxMouseEvent& event);
92
93 // Changes the cursor back to the default, if necessary.
94 void OnLeaveWindow(wxMouseEvent& event);
95
96 // handles "Copy URL" menuitem
97 void OnPopUpCopy(wxCommandEvent& event);
98
c105dda0
VZ
99 // overridden base class virtuals
100
101 // Returns the best size for the window, which is the size needed
102 // to display the text label.
103 virtual wxSize DoGetBestSize() const;
104
105 // creates a context menu with "Copy URL" menuitem
106 virtual void DoContextMenu(const wxPoint &);
107
108private:
109 // URL associated with the link. This is transmitted inside
110 // the HyperlinkEvent fired when the user clicks on the label.
111 wxString m_url;
112
113 // Foreground colours for various link types.
114 // NOTE: wxWindow::m_backgroundColour is used for background,
115 // wxWindow::m_foregroundColour is used to render non-visited links
116 wxColour m_hoverColour;
117 wxColour m_normalColour;
118 wxColour m_visitedColour;
119
120 // True if the mouse cursor is inside the label's bounding box.
121 bool m_rollover;
122
123 // True if the link has been clicked before.
124 bool m_visited;
125
126 // True if a click is in progress (left button down) and the click
127 // originated inside the label's bounding box.
128 bool m_clicking;
129
130private:
131 DECLARE_DYNAMIC_CLASS(wxGenericHyperlinkCtrl)
132};
133
6d020baf 134#endif // _WX_GENERICHYPERLINKCTRL_H_