Added context menu accessors; context menu now created in constructor.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@62194 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2009-09-29 06:45:04 +00:00
parent f4b53f7128
commit 319cc9f6cb
3 changed files with 29 additions and 15 deletions

View File

@@ -160,6 +160,12 @@ public:
wxCursor GetURLCursor() const { return m_urlCursor; } wxCursor GetURLCursor() const { return m_urlCursor; }
#endif #endif
#if wxABI_VERSION >= 20811
/// Get/set context menu
wxMenu* GetContextMenu() const { return m_contextMenu; }
void SetContextMenu(wxMenu* menu);
#endif
// Operations // Operations
// editing // editing

View File

@@ -297,6 +297,17 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
wxAcceleratorTable accel(6, entries); wxAcceleratorTable accel(6, entries);
SetAcceleratorTable(accel); SetAcceleratorTable(accel);
m_contextMenu = new wxMenu;
m_contextMenu->Append(wxID_UNDO, _("&Undo"));
m_contextMenu->Append(wxID_REDO, _("&Redo"));
m_contextMenu->AppendSeparator();
m_contextMenu->Append(wxID_CUT, _("Cu&t"));
m_contextMenu->Append(wxID_COPY, _("&Copy"));
m_contextMenu->Append(wxID_PASTE, _("&Paste"));
m_contextMenu->Append(wxID_CLEAR, _("&Delete"));
m_contextMenu->AppendSeparator();
m_contextMenu->Append(wxID_SELECTALL, _("Select &All"));
return true; return true;
} }
@@ -2505,6 +2516,13 @@ bool wxRichTextCtrl::CanDeleteSelection() const
// Accessors // Accessors
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxRichTextCtrl::SetContextMenu(wxMenu* menu)
{
if (m_contextMenu && m_contextMenu != menu)
delete m_contextMenu;
m_contextMenu = menu;
}
void wxRichTextCtrl::SetEditable(bool editable) void wxRichTextCtrl::SetEditable(bool editable)
{ {
m_editable = editable; m_editable = editable;
@@ -2809,19 +2827,7 @@ void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& event)
return; return;
} }
if (!m_contextMenu) if (m_contextMenu)
{
m_contextMenu = new wxMenu;
m_contextMenu->Append(wxID_UNDO, _("&Undo"));
m_contextMenu->Append(wxID_REDO, _("&Redo"));
m_contextMenu->AppendSeparator();
m_contextMenu->Append(wxID_CUT, _("Cu&t"));
m_contextMenu->Append(wxID_COPY, _("&Copy"));
m_contextMenu->Append(wxID_PASTE, _("&Paste"));
m_contextMenu->Append(wxID_CLEAR, _("&Delete"));
m_contextMenu->AppendSeparator();
m_contextMenu->Append(wxID_SELECTALL, _("Select &All"));
}
PopupMenu(m_contextMenu); PopupMenu(m_contextMenu);
return; return;
} }

View File

@@ -27,9 +27,11 @@
@WX_VERSION_TAG@.11 { @WX_VERSION_TAG@.11 {
*wxDC*SetDeviceClippingRegion*; *wxDC*SetDeviceClippingRegion*;
*wxGraphicsContext*GetCairoRenderer*; *wxGraphicsContext*GetCairoRenderer*;
*wxIconizeEvent*IsIconized*;
*wxRichTextCtrl*GetContextMenu*;
*wxRichTextCtrl*SetContextMenu*;
*wxShowEvent*IsShown*; *wxShowEvent*IsShown*;
*wxSound*Create*; *wxSound*Create*;
*wxIconizeEvent*IsIconized*;
*wxXmlNode*Attribute*; *wxXmlNode*Attribute*;
}; };