From 537fcac6334e51912439c2078696f3ab8dbe94f4 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 26 Dec 2015 17:44:28 +0100 Subject: [PATCH] Disable "Use wxDC" menu item if displayed screen requires wxGraphicContext (drawing sample). To display "show alpha" and "show graphics" screens there is necessary to use wxGraphicContext and switching to wxDC should blocked in this case. --- samples/drawing/drawing.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index fe264cfcf2..45babcc1f1 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -257,7 +257,7 @@ public: m_colourBackground; wxBrush m_backgroundBrush; MyCanvas *m_canvas; - + wxMenuItem *m_menuItemUseDC; private: // any class wishing to process wxWidgets events must use this macro wxDECLARE_EVENT_TABLE(); @@ -1901,7 +1901,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) wxMenu *menuFile = new wxMenu; #if wxUSE_GRAPHICS_CONTEXT menuFile->AppendCheckItem(File_GC_Default, "Use default wx&GraphicContext\tCtrl-Y"); - menuFile->AppendRadioItem(File_DC, "Use wx&DC\tShift-Ctrl-Y"); + m_menuItemUseDC = menuFile->AppendRadioItem(File_DC, "Use wx&DC\tShift-Ctrl-Y"); #if wxUSE_CAIRO menuFile->AppendRadioItem(File_GC_Cairo, "Use &Cairo\tCtrl-O"); #endif // wxUSE_CAIRO @@ -2071,6 +2071,12 @@ void MyFrame::OnShow(wxCommandEvent& event) { if ( !m_canvas->HasRenderer() ) m_canvas->UseGraphicRenderer(wxGraphicsRenderer::GetDefaultRenderer()); + // Disable selecting wxDC, if necessary. + m_menuItemUseDC->Enable(!m_canvas->HasRenderer()); + } + else + { + m_menuItemUseDC->Enable(true); } #endif // wxUSE_GRAPHICS_CONTEXT