From 52170c5b4419c63d6e0083df411aad420395ec98 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 27 Oct 2007 16:59:24 +0000 Subject: [PATCH] Fixed context menu in wxRichTextCtrl Added colour change event handler to wxRichTextCtrl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49488 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/richtext/richtextctrl.h | 1 + src/richtext/richtextctrl.cpp | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/wx/richtext/richtextctrl.h b/include/wx/richtext/richtextctrl.h index 8d0b6b9fe0..bd07bee8bf 100644 --- a/include/wx/richtext/richtextctrl.h +++ b/include/wx/richtext/richtextctrl.h @@ -582,6 +582,7 @@ public: void Command(wxCommandEvent& event); void OnDropFiles(wxDropFilesEvent& event); void OnCaptureLost(wxMouseCaptureLostEvent& event); + void OnSysColourChanged(wxSysColourChangedEvent& event); void OnCut(wxCommandEvent& event); void OnCopy(wxCommandEvent& event); diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index bf1f301f10..cf1c8532dd 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -76,6 +76,7 @@ BEGIN_EVENT_TABLE( wxRichTextCtrl, wxControl ) EVT_KILL_FOCUS(wxRichTextCtrl::OnKillFocus) EVT_MOUSE_CAPTURE_LOST(wxRichTextCtrl::OnCaptureLost) EVT_CONTEXT_MENU(wxRichTextCtrl::OnContextMenu) + EVT_SYS_COLOUR_CHANGED(wxRichTextCtrl::OnSysColourChanged) EVT_MENU(wxID_UNDO, wxRichTextCtrl::OnUndo) EVT_UPDATE_UI(wxID_UNDO, wxRichTextCtrl::OnUpdateUndo) @@ -506,7 +507,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) } /// Right-click -void wxRichTextCtrl::OnRightClick(wxMouseEvent& WXUNUSED(event)) +void wxRichTextCtrl::OnRightClick(wxMouseEvent& event) { SetFocus(); @@ -516,7 +517,8 @@ void wxRichTextCtrl::OnRightClick(wxMouseEvent& WXUNUSED(event)) cmdEvent.SetEventObject(this); cmdEvent.SetPosition(m_caretPosition+1); - GetEventHandler()->ProcessEvent(cmdEvent); + if (!GetEventHandler()->ProcessEvent(cmdEvent)) + event.Skip(); } /// Left-double-click @@ -3111,5 +3113,17 @@ void wxRichTextCtrl::ClearAvailableFontNames() sm_availableFontNames.Clear(); } +void wxRichTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& event) +{ + //wxLogDebug(wxT("wxRichTextCtrl::OnSysColourChanged")); + + wxTextAttrEx basicStyle = GetBasicStyle(); + basicStyle.SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); + SetBasicStyle(basicStyle); + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + + Refresh(); +} + #endif // wxUSE_RICHTEXT