X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be5a51fb592f3fa2ba38ac6cd1e488d6d806058c..3a33127542b111cf41a0c7b17d1316ef0855e9fe:/samples/render/render.cpp?ds=sidebyside diff --git a/samples/render/render.cpp b/samples/render/render.cpp index 5d8a38081f..782bd03f70 100644 --- a/samples/render/render.cpp +++ b/samples/render/render.cpp @@ -34,6 +34,7 @@ #include "wx/textdlg.h" #include "wx/log.h" #include "wx/msgdlg.h" + #include "wx/icon.h" #endif #include "wx/apptrait.h" @@ -58,15 +59,18 @@ class MyRenderer : public wxDelegateRendererNative public: MyRenderer() : wxDelegateRendererNative(wxRendererNative::GetDefault()) { } - virtual void DrawHeaderButton(wxWindow * WXUNUSED(win), + virtual int DrawHeaderButton(wxWindow *WXUNUSED(win), wxDC& dc, const wxRect& rect, - int WXUNUSED(flags) = 0) + int WXUNUSED(flags) = 0, + wxHeaderSortIconType WXUNUSED(sortArrow) = wxHDR_SORT_ICON_NONE, + wxHeaderButtonParams* WXUNUSED(params) = NULL) { dc.SetBrush(*wxBLUE_BRUSH); dc.SetTextForeground(*wxWHITE); dc.DrawRoundedRectangle(rect, 5); dc.DrawLabel(_T("MyRenderer"), wxNullBitmap, rect, wxALIGN_CENTER); + return rect.width; } }; @@ -102,8 +106,10 @@ public: virtual ~MyFrame(); // event handlers (these functions should _not_ be virtual) +#if wxUSE_DYNLIB_CLASS void OnLoad(wxCommandEvent& event); void OnUnload(wxCommandEvent& event); +#endif // wxUSE_DYNLIB_CLASS void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); @@ -127,8 +133,10 @@ public: dc.DrawText(_T("Below is the standard header button drawn"), 10, 10); dc.DrawText(_T("using the current renderer:"), 10, 40); - wxRendererNative::Get().DrawHeaderButton(this, dc, - wxRect(20, 70, 100, 60)); + wxRendererNative& renderer = wxRendererNative::Get(); + const wxCoord height = renderer.GetHeaderButtonHeight(this); + + renderer.DrawHeaderButton(this, dc, wxRect(20, 70, 100, height)); } DECLARE_EVENT_TABLE() @@ -146,8 +154,10 @@ END_EVENT_TABLE() enum { // our menu items +#if wxUSE_DYNLIB_CLASS Render_Load = 100, Render_Unload, +#endif // wxUSE_DYNLIB_CLASS // standard menu items Render_Quit = wxID_EXIT, @@ -166,8 +176,10 @@ enum // handlers) which process them. It can be also done at run-time, but for the // simple menu events like this the static method is much simpler. BEGIN_EVENT_TABLE(MyFrame, wxFrame) +#if wxUSE_DYNLIB_CLASS EVT_MENU(Render_Load, MyFrame::OnLoad) EVT_MENU(Render_Unload,MyFrame::OnUnload) +#endif // wxUSE_DYNLIB_CLASS EVT_MENU(Render_Quit, MyFrame::OnQuit) EVT_MENU(Render_About, MyFrame::OnAbout) @@ -191,6 +203,9 @@ IMPLEMENT_APP(MyApp) // 'Main program' equivalent: the program execution "starts" here bool MyApp::OnInit() { + if ( !wxApp::OnInit() ) + return false; + // create the main application window new MyFrame; @@ -204,7 +219,7 @@ bool MyApp::OnInit() // frame constructor MyFrame::MyFrame() : wxFrame(NULL, - -1, + wxID_ANY, _T("Render wxWidgets Sample"), wxPoint(50, 50), wxSize(450, 340)) @@ -215,8 +230,10 @@ MyFrame::MyFrame() #if wxUSE_MENUS // create a menu bar wxMenu *menuFile = new wxMenu; +#if wxUSE_DYNLIB_CLASS menuFile->Append(Render_Load, _T("&Load renderer...\tCtrl-L")); menuFile->Append(Render_Unload, _T("&Unload renderer\tCtrl-U")); +#endif // wxUSE_DYNLIB_CLASS menuFile->Append(Render_Quit, _T("E&xit\tCtrl-Q"), _T("Quit this program")); // the "About" item should be in the help menu @@ -251,6 +268,8 @@ MyFrame::~MyFrame() // event handlers +#if wxUSE_DYNLIB_CLASS + void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event)) { static wxString s_name = _T("renddll"); @@ -303,6 +322,8 @@ void MyFrame::OnUnload(wxCommandEvent& WXUNUSED(event)) } } +#endif // wxUSE_DYNLIB_CLASS + void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { // true is to force the frame to close @@ -313,7 +334,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxMessageBox(_T("Render sample shows how to use custom renderers.\n") _T("\n") - _T("© 2003 Vadim Zeitlin"), + _T("(c) 2003 Vadim Zeitlin"), _T("About Render wxWidgets Sample"), wxOK | wxICON_INFORMATION, this); }