X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3cb3b8b84de3ff3b660108724139c24b39746449..c3e54dee9173954a7f18a88632fbc263695938f6:/include/wx/hyperlink.h?ds=sidebyside diff --git a/include/wx/hyperlink.h b/include/wx/hyperlink.h index f696a0ea1a..4ebe3bc98b 100644 --- a/include/wx/hyperlink.h +++ b/include/wx/hyperlink.h @@ -23,9 +23,12 @@ // ---------------------------------------------------------------------------- #define wxHL_CONTEXTMENU 0x0001 -#define wxHL_DEFAULT_STYLE wxHL_CONTEXTMENU|wxNO_BORDER +#define wxHL_ALIGN_LEFT 0x0002 +#define wxHL_ALIGN_RIGHT 0x0004 +#define wxHL_ALIGN_CENTRE 0x0008 +#define wxHL_DEFAULT_STYLE (wxHL_CONTEXTMENU|wxNO_BORDER|wxHL_ALIGN_CENTRE) -extern WXDLLEXPORT_DATA(const wxChar) wxHyperlinkCtrlNameStr[]; +extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxHyperlinkCtrlNameStr[]; // ---------------------------------------------------------------------------- @@ -42,7 +45,7 @@ extern WXDLLEXPORT_DATA(const wxChar) wxHyperlinkCtrlNameStr[]; // just like a wxCommandEvent. // // Use the EVT_HYPERLINK() to catch link events. -class WXDLLIMPEXP_CORE wxHyperlinkCtrl : public wxControl +class WXDLLIMPEXP_ADV wxHyperlinkCtrl : public wxControl { public: // Default constructor (for two-step construction). @@ -96,6 +99,12 @@ protected: // Renders the hyperlink. void OnPaint(wxPaintEvent& event); + // Returns the wxRect of the label of this hyperlink. + // This is different from the clientsize's rectangle when + // clientsize != bestsize and this rectangle is influenced + // by the alignment of the label (wxHL_ALIGN_*). + wxRect GetLabelRect() const; + // If the click originates inside the bounding box of the label, // a flag is set so that an event will be fired when the left // button is released. @@ -108,7 +117,7 @@ protected: // Changes the cursor to a hand, if the mouse is inside the label's // bounding box. - void OnEnterWindow(wxMouseEvent& event); + void OnMotion(wxMouseEvent& event); // Changes the cursor back to the default, if necessary. void OnLeaveWindow(wxMouseEvent& event); @@ -116,12 +125,14 @@ protected: // handles "Copy URL" menuitem void OnPopUpCopy(wxCommandEvent& event); + // Refreshes the control to update label's position if necessary + void OnSize(wxSizeEvent& event); + // overridden base class virtuals // Returns the best size for the window, which is the size needed // to display the text label. - virtual void DoGetSize(int *width, int *height) const; virtual wxSize DoGetBestSize() const; // creates a context menu with "Copy URL" menuitem @@ -161,45 +172,60 @@ private: // Declare an event identifier. BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_HYPERLINK, 3700) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_HYPERLINK, 3700) END_DECLARE_EVENT_TYPES() // // An event fired when the user clicks on the label in a hyperlink control. // See HyperlinkControl for details. // -class WXDLLIMPEXP_CORE wxHyperlinkEvent : public wxCommandEvent +class WXDLLIMPEXP_ADV wxHyperlinkEvent : public wxCommandEvent { public: - wxHyperlinkEvent() {} wxHyperlinkEvent(wxObject *generator, wxWindowID id, const wxString& url) - : wxCommandEvent(wxEVT_COMMAND_HYPERLINK, id), m_url(url) - { SetEventObject(generator); } + : wxCommandEvent(wxEVT_COMMAND_HYPERLINK, id), + m_url(url) + { + SetEventObject(generator); + } // Returns the URL associated with the hyperlink control // that the user clicked on. wxString GetURL() const { return m_url; } void SetURL(const wxString &url) { m_url=url; } + // default copy ctor, assignment operator and dtor are ok + virtual wxEvent *Clone() const { return new wxHyperlinkEvent(*this); } + private: // URL associated with the hyperlink control that the used clicked on. wxString m_url; + + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHyperlinkEvent) }; -// Define a typedef for event handler functions. -typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent&); -// Define an event table macro. -#define EVT_HYPERLINK(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_HYPERLINK, \ - id, id, (wxObjectEventFunction) (wxEventFunction) \ - wxStaticCastEvent(wxHyperlinkEventFunction, &fn), (wxObject *) NULL), +// ---------------------------------------------------------------------------- +// event types and macros +// ---------------------------------------------------------------------------- + +typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent&); -// Newer event macro #define wxHyperlinkEventHandler(func) \ (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxHyperlinkEventFunction, &func) +#define EVT_HYPERLINK(id, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_HYPERLINK, id, wxHyperlinkEventHandler(fn)) + +#ifdef _WX_DEFINE_DATE_EVENTS_ + DEFINE_EVENT_TYPE(wxEVT_COMMAND_HYPERLINK) + + IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkEvent, wxCommandEvent) +#endif + + #endif // wxUSE_HYPERLINKCTRL #endif // _WX_HYPERLINK_H__