]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/hyperlink.h
wxHeaderColumnBase -> wxHeaderColumn; Fixed UpdateColumnWidthToFit() sample code
[wxWidgets.git] / interface / wx / hyperlink.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: hyperlink.h
e54c96f1 3// Purpose: interface of wxHyperlinkEvent
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxHyperlinkEvent
7c913512 11
9cc56d1f
FM
12 This event class is used for the events generated by wxHyperlinkCtrl.
13
14 @beginEventTable{wxHyperlinkEvent}
15 @event{EVT_HYPERLINK(id, func)}
16 User clicked on an hyperlink.
17 @endEventTable
7c913512 18
23324ae1 19 @library{wxadv}
9cc56d1f 20 @category{events}
23324ae1
FM
21*/
22class wxHyperlinkEvent : public wxCommandEvent
23{
24public:
25 /**
26 The constructor is not normally used by the user code.
27 */
9cc56d1f 28 wxHyperlinkEvent(wxObject* generator, int id, const wxString& url);
23324ae1
FM
29
30 /**
31 Returns the URL of the hyperlink where the user has just clicked.
32 */
328f5751 33 wxString GetURL() const;
23324ae1
FM
34
35 /**
36 Sets the URL associated with the event.
37 */
4cc4bfaf 38 void SetURL(const wxString& url);
23324ae1
FM
39};
40
41
e54c96f1 42
23324ae1
FM
43/**
44 @class wxHyperlinkCtrl
7c913512 45
23324ae1 46 This class shows a static text element which links to an URL.
9cc56d1f
FM
47 Appearance and behaviour is completely customizable.
48
49 In fact, when the user clicks on the hyperlink, a wxHyperlinkEvent is
50 sent but if that event is not handled (or it's skipped; see wxEvent::Skip),
51 then a call to wxLaunchDefaultBrowser() is done with the hyperlink's URL.
7c913512 52
23324ae1 53 Note that standard wxWindow functions like wxWindow::SetBackgroundColour,
9cc56d1f
FM
54 wxWindow::SetFont, wxWindow::SetCursor, wxWindow::SetLabel can be used to
55 customize appearance of the hyperlink.
7c913512 56
23324ae1 57 @beginStyleTable
8c6791e4 58 @style{wxHL_ALIGN_LEFT}
23324ae1 59 Align the text to the left.
8c6791e4 60 @style{wxHL_ALIGN_RIGHT}
23324ae1 61 Align the text to the right.
8c6791e4 62 @style{wxHL_ALIGN_CENTRE}
23324ae1 63 Center the text (horizontally).
8c6791e4 64 @style{wxHL_CONTEXTMENU}
23324ae1
FM
65 Pop up a context menu when the hyperlink is right-clicked. The
66 context menu contains a "Copy URL" menu item which is automatically
67 handled by the hyperlink and which just copies in the clipboard the
68 URL (not the label) of the control.
8c6791e4 69 @style{wxHL_DEFAULT_STYLE}
23324ae1
FM
70 The default style for wxHyperlinkCtrl:
71 wxBORDER_NONE|wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE.
72 @endStyleTable
7c913512 73
3051a44a 74 @beginEventEmissionTable{wxHyperlinkEvent}
9cc56d1f
FM
75 @event{EVT_HYPERLINK(id, func)}
76 The hyperlink was (left) clicked. If this event is not handled in user's
77 code (or it's skipped; see wxEvent::Skip), then a call to wxLaunchDefaultBrowser
78 is done with the hyperlink's URL.
79 @endEventTable
80
81
23324ae1
FM
82 @library{wxadv}
83 @category{ctrl}
7e59b885 84 @appearance{hyperlinkctrl.png}
7c913512 85
e54c96f1 86 @see wxURL, wxHyperlinkEvent
23324ae1
FM
87*/
88class wxHyperlinkCtrl : public wxControl
89{
90public:
a6052817
FM
91 /**
92 Constructor. See Create() for more info.
93 */
ccf39540
FM
94 wxHyperLinkCtrl(wxWindow* parent, wxWindowID id,
95 const wxString& label,
96 const wxString& url,
97 const wxPoint& pos = wxDefaultPosition,
98 const wxSize& size = wxDefaultSize,
99 long style = wxHL_DEFAULT_STYLE,
100 const wxString& name = wxHyperlinkCtrlNameStr);
a6052817 101
23324ae1
FM
102 /**
103 Creates the hyperlink control.
3c4f71cc 104
7c913512 105 @param parent
4cc4bfaf 106 Parent window. Must not be @NULL.
7c913512 107 @param id
4cc4bfaf 108 Window identifier. A value of wxID_ANY indicates a default value.
7c913512 109 @param label
4cc4bfaf 110 The label of the hyperlink.
7c913512 111 @param url
4cc4bfaf 112 The URL associated with the given label.
7c913512 113 @param pos
4cc4bfaf 114 Window position.
7c913512 115 @param size
9cc56d1f
FM
116 Window size.
117 If the wxDefaultSize is specified then the window is sized appropriately.
7c913512 118 @param style
4cc4bfaf 119 Window style. See wxHyperlinkCtrl.
7c913512 120 @param name
4cc4bfaf 121 Window name.
23324ae1 122 */
43c48e1e
FM
123 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
124 const wxString& url, const wxPoint& pos = wxDefaultPosition,
23324ae1 125 const wxSize& size = wxDefaultSize,
a6052817 126 long style = wxHL_DEFAULT_STYLE,
43c48e1e 127 const wxString& name = wxHyperlinkCtrlNameStr);
23324ae1
FM
128
129 /**
130 Returns the colour used to print the label of the hyperlink when the mouse is
131 over the control.
132 */
adaaa686 133 virtual wxColour GetHoverColour() const;
23324ae1
FM
134
135 /**
136 Returns the colour used to print the label when the link has never been clicked
9cc56d1f 137 before (i.e. the link has not been @e visited) and the mouse is not over the control.
23324ae1 138 */
adaaa686 139 virtual wxColour GetNormalColour() const;
23324ae1
FM
140
141 /**
142 Returns the URL associated with the hyperlink.
143 */
adaaa686 144 virtual wxString GetURL() const;
23324ae1
FM
145
146 /**
147 Returns @true if the hyperlink has already been clicked by the user at least
148 one time.
149 */
a6052817 150 virtual bool GetVisited() const = 0;
23324ae1
FM
151
152 /**
153 Returns the colour used to print the label when the mouse is not over the
9cc56d1f
FM
154 control and the link has already been clicked before (i.e. the link has
155 been @e visited).
23324ae1 156 */
adaaa686 157 virtual wxColour GetVisitedColour() const;
23324ae1
FM
158
159 /**
160 Sets the colour used to print the label of the hyperlink when the mouse is over
161 the control.
162 */
adaaa686 163 virtual void SetHoverColour(const wxColour& colour);
23324ae1
FM
164
165 /**
9cc56d1f 166 Sets the colour used to print the label when the link has never been clicked before
23324ae1
FM
167 (i.e. the link has not been @e visited) and the mouse is not over the control.
168 */
adaaa686 169 virtual void SetNormalColour(const wxColour& colour);
23324ae1
FM
170
171 /**
172 Sets the URL associated with the hyperlink.
173 */
adaaa686 174 virtual void SetURL(const wxString& url);
23324ae1
FM
175
176 /**
177 Marks the hyperlink as visited (see wxHyperlinkCtrl::SetVisitedColour).
178 */
a6052817 179 virtual void SetVisited(bool visited = true) = 0;
23324ae1
FM
180
181 /**
182 Sets the colour used to print the label when the mouse is not over the control
9cc56d1f 183 and the link has already been clicked before (i.e. the link has been @e visited).
23324ae1 184 */
adaaa686 185 virtual void SetVisitedColour(const wxColour& colour);
23324ae1 186};
e54c96f1 187