]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/hyperlink.h
Applied rowspan patch #15276 (dghart)
[wxWidgets.git] / include / wx / generic / hyperlink.h
... / ...
CommitLineData
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
12#ifndef _WX_GENERICHYPERLINKCTRL_H_
13#define _WX_GENERICHYPERLINKCTRL_H_
14
15// ----------------------------------------------------------------------------
16// wxGenericHyperlinkCtrl
17// ----------------------------------------------------------------------------
18
19class WXDLLIMPEXP_ADV wxGenericHyperlinkCtrl : public wxHyperlinkCtrlBase
20{
21public:
22 // Default constructor (for two-step construction).
23 wxGenericHyperlinkCtrl() { Init(); }
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 Init();
35 (void) Create(parent, id, label, url, pos, size, style, name);
36 }
37
38 // Creation function (for two-step construction).
39 bool Create(wxWindow *parent,
40 wxWindowID id,
41 const wxString& label, const wxString& url,
42 const wxPoint& pos = wxDefaultPosition,
43 const wxSize& size = wxDefaultSize,
44 long style = wxHL_DEFAULT_STYLE,
45 const wxString& name = wxHyperlinkCtrlNameStr);
46
47
48 // get/set
49 wxColour GetHoverColour() const { return m_hoverColour; }
50 void SetHoverColour(const wxColour &colour) { m_hoverColour = colour; }
51
52 wxColour GetNormalColour() const { return m_normalColour; }
53 void SetNormalColour(const wxColour &colour);
54
55 wxColour GetVisitedColour() const { return m_visitedColour; }
56 void SetVisitedColour(const wxColour &colour);
57
58 wxString GetURL() const { return m_url; }
59 void SetURL (const wxString &url) { m_url=url; }
60
61 void SetVisited(bool visited = true) { m_visited=visited; }
62 bool GetVisited() const { return m_visited; }
63
64 // NOTE: also wxWindow::Set/GetLabel, wxWindow::Set/GetBackgroundColour,
65 // wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important !
66
67
68protected:
69 // Helper used by this class itself and native MSW implementation that
70 // connects OnRightUp() and OnPopUpCopy() handlers.
71 void ConnectMenuHandlers();
72
73 // event handlers
74
75 // Renders the hyperlink.
76 void OnPaint(wxPaintEvent& event);
77
78 // Handle set/kill focus events (invalidate for painting focus rect)
79 void OnFocus(wxFocusEvent& event);
80
81 // Fire a HyperlinkEvent on space
82 void OnChar(wxKeyEvent& event);
83
84 // Returns the wxRect of the label of this hyperlink.
85 // This is different from the clientsize's rectangle when
86 // clientsize != bestsize and this rectangle is influenced
87 // by the alignment of the label (wxHL_ALIGN_*).
88 wxRect GetLabelRect() const;
89
90 // If the click originates inside the bounding box of the label,
91 // a flag is set so that an event will be fired when the left
92 // button is released.
93 void OnLeftDown(wxMouseEvent& event);
94
95 // If the click both originated and finished inside the bounding box
96 // of the label, a HyperlinkEvent is fired.
97 void OnLeftUp(wxMouseEvent& event);
98 void OnRightUp(wxMouseEvent& event);
99
100 // Changes the cursor to a hand, if the mouse is inside the label's
101 // bounding box.
102 void OnMotion(wxMouseEvent& event);
103
104 // Changes the cursor back to the default, if necessary.
105 void OnLeaveWindow(wxMouseEvent& event);
106
107 // handles "Copy URL" menuitem
108 void OnPopUpCopy(wxCommandEvent& event);
109
110 // overridden base class virtuals
111
112 // Returns the best size for the window, which is the size needed
113 // to display the text label.
114 virtual wxSize DoGetBestClientSize() const;
115
116 // creates a context menu with "Copy URL" menuitem
117 virtual void DoContextMenu(const wxPoint &);
118
119private:
120 // Common part of all ctors.
121 void Init();
122
123 // URL associated with the link. This is transmitted inside
124 // the HyperlinkEvent fired when the user clicks on the label.
125 wxString m_url;
126
127 // Foreground colours for various link types.
128 // NOTE: wxWindow::m_backgroundColour is used for background,
129 // wxWindow::m_foregroundColour is used to render non-visited links
130 wxColour m_hoverColour;
131 wxColour m_normalColour;
132 wxColour m_visitedColour;
133
134 // True if the mouse cursor is inside the label's bounding box.
135 bool m_rollover;
136
137 // True if the link has been clicked before.
138 bool m_visited;
139
140 // True if a click is in progress (left button down) and the click
141 // originated inside the label's bounding box.
142 bool m_clicking;
143};
144
145#endif // _WX_GENERICHYPERLINKCTRL_H_