From: Francesco Montorsi Date: Thu, 4 Dec 2008 20:49:30 +0000 (+0000) Subject: add a 'Paint background' check menu item in the MyImageFrame class X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8b6264b43e53f4ad652645a66933bdacf0802caa add a 'Paint background' check menu item in the MyImageFrame class git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57111 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 14c1c82d47..01af647f11 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -152,9 +152,10 @@ private: enum { - ID_ROTATE_LEFT = 100, + ID_ROTATE_LEFT = wxID_HIGHEST+1, ID_ROTATE_RIGHT, - ID_RESIZE + ID_RESIZE, + ID_PAINT_BG }; class MyImageFrame : public wxFrame @@ -170,6 +171,8 @@ public: wxMenu *menu = new wxMenu; menu->Append(wxID_SAVE); menu->AppendSeparator(); + m_pClearBgMenu = menu->AppendCheckItem(ID_PAINT_BG, _T("&Paint background")); + menu->AppendSeparator(); menu->Append(ID_RESIZE, _T("&Fit to window\tCtrl-F")); menu->AppendSeparator(); menu->Append(ID_ROTATE_LEFT, _T("Rotate &left\tCtrl-L")); @@ -184,8 +187,8 @@ public: SetClientSize(bitmap.GetWidth(), bitmap.GetHeight()); UpdateStatusBar(); - - SetBackgroundColour(*wxWHITE); + +// SetBackgroundColour(*wxWHITE); } void OnEraseBackground(wxEraseEvent& WXUNUSED(event)) @@ -196,9 +199,10 @@ public: void OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); - - ClearBackground(); - + + if (m_pClearBgMenu->IsChecked()) + ClearBackground(); + const wxSize size = GetClientSize(); dc.DrawBitmap(m_bitmap, (size.x - m_bitmap.GetWidth())/2, @@ -373,6 +377,7 @@ private: } wxBitmap m_bitmap; + wxMenuItem* m_pClearBgMenu; DECLARE_EVENT_TABLE() };