X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9c743a7c783b9c21e049fd88445d4051c99ce2db..0e32e86acd2334356ab2bb7cb57e13e682ce35f7:/samples/render/render.cpp diff --git a/samples/render/render.cpp b/samples/render/render.cpp index b14b0ffc18..782bd03f70 100644 --- a/samples/render/render.cpp +++ b/samples/render/render.cpp @@ -1,11 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// // Name: render.cpp -// Purpose: Render wxWindows sample +// Purpose: Render wxWidgets sample // Author: Vadim Zeitlin // Modified by: // Created: 04.08.03 // RCS-ID: $Id$ -// Copyright: (c) 2003 Vadim Zeitlin +// Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -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; } }; @@ -78,7 +82,7 @@ class MyTraits : public wxGUIAppTraits { virtual wxRendererNative *CreateRenderer() { - // it will be deleted on program shutdown by wxWindows itself + // it will be deleted on program shutdown by wxWidgets itself return new MyRenderer; } }; @@ -102,15 +106,17 @@ 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); private: wxPanel *m_panel; - // any class wishing to process wxWindows events must use this macro + // any class wishing to process wxWidgets events must use this macro DECLARE_EVENT_TABLE() }; @@ -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, @@ -159,21 +169,23 @@ enum }; // ---------------------------------------------------------------------------- -// event tables and other macros for wxWindows +// event tables and other macros for wxWidgets // ---------------------------------------------------------------------------- -// the event tables connect the wxWindows events with the functions (event +// the event tables connect the wxWidgets events with the functions (event // 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) END_EVENT_TABLE() -// Create a new application object: this macro will allow wxWindows to create +// Create a new application object: this macro will allow wxWidgets to create // the application object during program execution (it's better than using a // static object for many reasons) and also implements the accessor function // wxGetApp() which will return the reference of the right type (i.e. MyApp and @@ -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,8 +219,8 @@ bool MyApp::OnInit() // frame constructor MyFrame::MyFrame() : wxFrame(NULL, - -1, - _T("Render wxWindows Sample"), + 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 @@ -237,7 +254,7 @@ MyFrame::MyFrame() #if wxUSE_STATUSBAR // create a status bar just for fun (by default with 1 pane only) CreateStatusBar(2); - SetStatusText(_T("Welcome to wxWindows!")); + SetStatusText(_T("Welcome to wxWidgets!")); #endif // wxUSE_STATUSBAR Show(); @@ -251,6 +268,8 @@ MyFrame::~MyFrame() // event handlers +#if wxUSE_DYNLIB_CLASS + void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event)) { static wxString s_name = _T("renddll"); @@ -258,7 +277,7 @@ void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event)) wxString name = wxGetTextFromUser ( _T("Name of the renderer to load:"), - _T("Render wxWindows Sample"), + _T("Render wxWidgets Sample"), s_name, this ); @@ -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,8 +334,8 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxMessageBox(_T("Render sample shows how to use custom renderers.\n") _T("\n") - _T("© 2003 Vadim Zeitlin"), - _T("About Render wxWindows Sample"), + _T("(c) 2003 Vadim Zeitlin"), + _T("About Render wxWidgets Sample"), wxOK | wxICON_INFORMATION, this); }