00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _WX_HYPERLINKCTRL_H_
00026 #define _WX_HYPERLINKCTRL_H_
00027
00028
00029 #if defined(__GNUG__) && !defined(__APPLE__)
00030 #pragma interface "hyperlinkctrl.h"
00031 #endif
00032
00033
00034
00035
00036
00037 #include <wx/wx.h>
00038 #include "httpenginedef.h"
00039
00040 BEGIN_DECLARE_EVENT_TYPES()
00041 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_HTTPENGINE, wxEVT_COMMAND_LINK_CLICKED, 7771)
00042 #ifndef HYPERLINKCTRL_COMMANDEVENT
00043 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_HTTPENGINE, wxEVT_COMMAND_LINK_MCLICKED, 7772)
00044 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_HTTPENGINE, wxEVT_COMMAND_LINK_RCLICKED, 7773)
00045 #endif
00046 END_DECLARE_EVENT_TYPES()
00047
00048
00049 #ifdef HYPERLINKCTRL_COMMANDEVENT
00050
00051 #define EVT_LINK(id, fn) \
00052 DECLARE_EVENT_TABLE_ENTRY( \
00053 wxEVT_COMMAND_LINK_CLICKED, id, -1, \
00054 (wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction)&fn, \
00055 (wxObject *) NULL \
00056 ),
00057
00058 #else
00059
00060 class wxHyperlinkEvent : public wxCommandEvent
00061 {
00062 public:
00063 wxHyperlinkEvent( WXTYPE eventType = wxEVT_COMMAND_LINK_RCLICKED, int id = 0 ) : wxCommandEvent( eventType, id ) { };
00064
00065 virtual wxEvent *Clone() const { return new wxHyperlinkEvent(*this); };
00066
00067 void SetPosition( const wxPoint &pos ) { m_pos = pos; };
00068 wxPoint GetPosition(void) { return m_pos; };
00069 private:
00070 wxPoint m_pos;
00071 };
00072
00073 typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent);
00074
00075
00076 #define EVT_LINK(id, fn) \
00077 DECLARE_EVENT_TABLE_ENTRY( \
00078 wxEVT_COMMAND_LINK_CLICKED, id, -1, \
00079 (wxObjectEventFunction)(wxEventFunction)(wxHyperlinkEventFunction)&fn, \
00080 (wxObject *) NULL \
00081 ),
00082 #define EVT_LINK_MCLICKED(id, fn) \
00083 DECLARE_EVENT_TABLE_ENTRY( \
00084 wxEVT_COMMAND_LINK_MCLICKED, id, -1, \
00085 (wxObjectEventFunction)(wxEventFunction)(wxHyperlinkEventFunction)&fn, \
00086 (wxObject *) NULL \
00087 ),
00088 #define EVT_LINK_RCLICKED(id, fn) \
00089 DECLARE_EVENT_TABLE_ENTRY( \
00090 wxEVT_COMMAND_LINK_RCLICKED, id, -1, \
00091 (wxObjectEventFunction)(wxEventFunction)(wxHyperlinkEventFunction)&fn, \
00092 (wxObject *) NULL \
00093 ),
00094
00095 #endif
00096
00097 enum
00098 {
00099 HYPERLINKS_POPUP_COPY = 1000,
00100 };
00101
00102
00103 class wxHyperlinkCtrl : public wxStaticText
00104 {
00105 public:
00106
00107 #ifdef __WIN95__
00108 long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
00109 #endif
00110
00111
00112 wxHyperlinkCtrl( wxWindow *parent, wxWindowID id, const wxString &label,
00113 const wxPoint &pos= wxDefaultPosition, const wxSize &size= wxDefaultSize, int style = 0, const wxString& name = wxT("staticText"), const wxString& szURL = wxEmptyString);
00114
00115
00116 void SetColours( const wxColour &link = wxColour( wxT("BLUE") ), const wxColour &visited = wxColour(wxT("VIOLET")), const wxColour &rollover = wxColour( wxT("BLUE") ))
00117 {
00118 m_crLinkColour = link;
00119 m_crVisitedColour = visited;
00120 m_crLinkRolloverColor = rollover;
00121 };
00122 void GetColous( wxColour &link, wxColour &visited, wxColour &rollover )
00123 {
00124 link = m_crLinkColour;
00125 visited = m_crVisitedColour;
00126 rollover = m_crLinkRolloverColor;
00127 };
00128
00129
00130 void SetUnderlines( const bool link = true, const bool visited = true, const bool rollover = true )
00131 {
00132 m_bLinkUnderline = link;
00133 m_bRolloverUnderline = rollover;
00134 m_bVisitedUnderline = visited;
00135 };
00136 void GetUnderlines( bool link, bool visited, bool rollover )
00137 {
00138 link = m_bLinkUnderline;
00139 rollover = m_bRolloverUnderline;
00140 visited = m_bVisitedUnderline;
00141 };
00142
00143
00144 void SetLinkCursor( const wxCursor &cur = wxCURSOR_HAND) { m_crHand = cur; };
00145 void GetLinkCursor( wxCursor &cur ) { cur = m_crHand; };
00146
00147
00148 void SetVisited( const bool bVisited = false ) { m_bVisited = bVisited; };
00149 bool GetVisited( void ) { return m_bVisited; }
00150
00151
00152 void SetBold( const bool bBold = false) { m_bBold = bBold; };
00153 bool GetBold( void ) { return m_bBold; };
00154
00155
00156 void SetURL( const wxString &szURL ) { m_szURL = szURL; }
00157 wxString GetURL( void ) { return m_szURL; }
00158
00159
00160 void OpenInSameWindow( const bool bIfPossible = false ) { m_bSameWinIfPossible = bIfPossible; };
00161
00162
00163 void SetBrowserPath( const wxString &browser ) { m_szBrowserPath = browser; };
00164 wxString GetBrowserPath( void ) { return m_szBrowserPath; };
00165
00166
00167 void EnableRollover( const bool bEnable = false ) { m_bEnableRollover = bEnable; };
00168
00169
00170 void ReportErrors( const bool bReport = true ) { m_bReportErrors = bReport; };
00171
00172
00173
00174 void AutoBrowse( const bool bBrowse = true ){ m_bAutoBrowse = bBrowse; };
00175
00176
00177 void DoPopup( const bool bPopup = true ) { m_bDoPopup = bPopup; };
00178
00179
00180
00181
00182 static bool GotoURL( const wxString &szUrl, const wxString &szBrowser = wxEmptyString, const bool bReportErrors = false, const bool bSameWinIfPossible = false );
00183
00184
00185 void UpdateLink( const bool bRefresh = true );
00186
00187 private:
00188
00189 void OnPopUpCopy( wxCommandEvent &event );
00190
00191
00192 void OnMouseEvent( wxMouseEvent &event );
00193
00194
00195 static void DisplayError( const wxString &szError, const bool bReportErrors );
00196
00197
00198 wxString m_szURL;
00199
00200
00201 wxString m_szBrowserPath;
00202
00203
00204 wxColour m_crLinkColour;
00205 wxColour m_crVisitedColour;
00206 wxColour m_crLinkRolloverColor;
00207
00208
00209 bool m_bLinkUnderline;
00210 bool m_bRolloverUnderline;
00211 bool m_bVisitedUnderline;
00212
00213
00214 bool m_bEnableRollover;
00215
00216
00217 bool m_bVisited;
00218
00219
00220 bool m_bBold;
00221
00222
00223 wxCursor m_crHand;
00224
00225
00226 bool m_bReportErrors;
00227
00228
00229
00230
00231 bool m_bAutoBrowse;
00232
00233
00234 bool m_bDoPopup;
00235
00236
00237 bool m_bSameWinIfPossible;
00238
00239 wxMenu *m_menuPopUp;
00240
00241 DECLARE_EVENT_TABLE()
00242 };
00243
00244 #endif