void OnButtonReset(wxCommandEvent& event);
void OnAlignment(wxCommandEvent& event);
+ void OnGeneric(wxCommandEvent& event);
// reset the control parameters
void Reset();
// ------------
// the checkbox itself and the sizer it is in
- wxHyperlinkCtrl *m_hyperlink;
- wxHyperlinkCtrl *m_hyperlinkLong;
+ wxGenericHyperlinkCtrl *m_hyperlink;
+ wxGenericHyperlinkCtrl *m_hyperlinkLong;
wxTextCtrl *m_label;
wxTextCtrl *m_url;
wxTextCtrl *m_textLabel;
wxRadioBox *m_radioAlignMode;
+ wxCheckBox *m_checkGeneric;
private:
DECLARE_EVENT_TABLE()
EVT_BUTTON(HyperlinkPage_SetURL, HyperlinkWidgetsPage::OnButtonSetURL)
EVT_RADIOBOX(wxID_ANY, HyperlinkWidgetsPage::OnAlignment)
+ EVT_CHECKBOX(wxID_ANY, HyperlinkWidgetsPage::OnGeneric)
END_EVENT_TABLE()
// ============================================================================
// wxHL_DEFAULT_STYLE contains wxHL_ALIGN_CENTRE
sizerLeft->Add(m_radioAlignMode, 0, wxALL|wxGROW, 5);
-
+ m_checkGeneric = new wxCheckBox(this, wxID_ANY, wxT("Use generic version"),
+ wxDefaultPosition, wxDefaultSize);
+ sizerLeft->Add(m_checkGeneric, 0, wxALL|wxGROW, 5);
// right pane
wxSizer *szHyperlinkLong = new wxBoxSizer(wxVERTICAL);
m_visit = new wxStaticText(this, wxID_ANY, wxT("Visit "));
- m_hyperlink = new wxHyperlinkCtrl(this,
- HyperlinkPage_Ctrl,
- wxT("wxWidgets website"),
- wxT("www.wxwidgets.org"));
+ if (m_checkGeneric->IsChecked())
+ {
+ m_hyperlink = new wxGenericHyperlinkCtrl(this,
+ HyperlinkPage_Ctrl,
+ wxT("wxWidgets website"),
+ wxT("www.wxwidgets.org"));
+ }
+ else
+ {
+ m_hyperlink = new wxHyperlinkCtrl(this,
+ HyperlinkPage_Ctrl,
+ wxT("wxWidgets website"),
+ wxT("www.wxwidgets.org"));
+ }
m_fun = new wxStaticText(this, wxID_ANY, wxT(" for fun!"));
szHyperlink->Add(0, 0, 1, wxCENTRE);
szHyperlink->SetMinSize(150, 0);
- m_hyperlinkLong = new wxHyperlinkCtrl(this,
- wxID_ANY,
- wxT("This is a long hyperlink"),
- wxT("www.wxwidgets.org"));
+ if (m_checkGeneric->IsChecked())
+ {
+ m_hyperlinkLong = new wxGenericHyperlinkCtrl(this,
+ wxID_ANY,
+ wxT("This is a long hyperlink"),
+ wxT("www.wxwidgets.org"));
+ }
+ else
+ {
+ m_hyperlinkLong = new wxHyperlinkCtrl(this,
+ wxID_ANY,
+ wxT("This is a long hyperlink"),
+ wxT("www.wxwidgets.org"));
+ }
szHyperlinkLong->Add(0, 0, 1, wxCENTRE);
szHyperlinkLong->Add(szHyperlink, 0, wxCENTRE|wxGROW);
const wxString label = m_hyperlink->GetLabel();
const wxString url = m_hyperlink->GetURL();
- wxHyperlinkCtrl *hyp = new wxHyperlinkCtrl(this,
- HyperlinkPage_Ctrl,
- label,
- url);
+ wxGenericHyperlinkCtrl *hyp;
+ if (m_checkGeneric->IsChecked())
+ {
+ hyp = new wxGenericHyperlinkCtrl(this,
+ HyperlinkPage_Ctrl,
+ label,
+ url);
+ }
+ else
+ {
+ hyp = new wxHyperlinkCtrl(this,
+ HyperlinkPage_Ctrl,
+ label,
+ url);
+ }
// update sizer's child window
GetSizer()->Replace(m_hyperlink, hyp, true);
void HyperlinkWidgetsPage::CreateHyperlinkLong(long style)
{
style = (wxHL_DEFAULT_STYLE & ~wxHL_ALIGN_CENTRE)|style;
- wxHyperlinkCtrl *hyp = new wxHyperlinkCtrl(this,
- wxID_ANY,
- wxT("This is a long hyperlink"),
- wxT("www.wxwidgets.org"),
- wxDefaultPosition,
- wxDefaultSize,
- style);
+
+ wxGenericHyperlinkCtrl *hyp;
+ if (m_checkGeneric->IsChecked())
+ {
+ hyp = new wxGenericHyperlinkCtrl(this,
+ wxID_ANY,
+ wxT("This is a long hyperlink"),
+ wxT("www.wxwidgets.org"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ style);
+ }
+ else
+ {
+ hyp = new wxHyperlinkCtrl(this,
+ wxID_ANY,
+ wxT("This is a long hyperlink"),
+ wxT("www.wxwidgets.org"),
+ wxDefaultPosition,
+ wxDefaultSize,
+ style);
+ }
// update sizer's child window
GetSizer()->Replace(m_hyperlinkLong, hyp, true);
CreateHyperlinkLong(addstyle);
}
+void HyperlinkWidgetsPage::OnGeneric(wxCommandEvent& event)
+{
+ CreateHyperlink();
+ OnAlignment(event);
+}
+
#endif // wxUSE_HYPERLINKCTRL
#endif
#include "wx/clipbrd.h"
+#include "wx/renderer.h"
// ============================================================================
// implementation
// with GTK+'s native handling):
Connect( wxEVT_PAINT, wxPaintEventHandler(wxGenericHyperlinkCtrl::OnPaint) );
+ Connect( wxEVT_SET_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) );
+ Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) );
+ Connect( wxEVT_CHAR, wxKeyEventHandler(wxGenericHyperlinkCtrl::OnChar) );
Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeaveWindow) );
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftDown) );
dc.SetTextBackground(GetBackgroundColour());
dc.DrawText(GetLabel(), GetLabelRect().GetTopLeft());
+ if (HasFocus())
+ {
+ wxRendererNative::Get().DrawFocusRect(this, dc, GetClientRect(), wxCONTROL_SELECTED);
+ }
+}
+
+void wxGenericHyperlinkCtrl::OnFocus(wxFocusEvent& event)
+{
+ Refresh();
+ event.Skip();
+}
+
+void wxGenericHyperlinkCtrl::OnChar(wxKeyEvent& event)
+{
+ switch (event.m_keyCode)
+ {
+ default:
+ event.Skip();
+ break;
+ case WXK_SPACE:
+ case WXK_NUMPAD_SPACE:
+ SetForegroundColour(m_visitedColour);
+ m_visited = true;
+ SendEvent();
+ break;
+ }
}
void wxGenericHyperlinkCtrl::OnLeftDown(wxMouseEvent& event)