X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ba46d9ea76c22b4db838d755b898decc311ba827..474e9711477a5737b232435525da1c87f7eb72d2:/samples/render/render.cpp diff --git a/samples/render/render.cpp b/samples/render/render.cpp index 2136996b18..0233d24bce 100644 --- a/samples/render/render.cpp +++ b/samples/render/render.cpp @@ -59,7 +59,7 @@ 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, @@ -69,7 +69,8 @@ public: dc.SetBrush(*wxBLUE_BRUSH); dc.SetTextForeground(*wxWHITE); dc.DrawRoundedRectangle(rect, 5); - dc.DrawLabel(_T("MyRenderer"), wxNullBitmap, rect, wxALIGN_CENTER); + dc.DrawLabel(wxT("MyRenderer"), wxNullBitmap, rect, wxALIGN_CENTER); + return rect.width; } }; @@ -129,11 +130,13 @@ public: { wxPaintDC dc(this); - dc.DrawText(_T("Below is the standard header button drawn"), 10, 10); - dc.DrawText(_T("using the current renderer:"), 10, 40); + dc.DrawText(wxT("Below is the standard header button drawn"), 10, 10); + dc.DrawText(wxT("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() @@ -200,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; @@ -214,7 +220,7 @@ bool MyApp::OnInit() MyFrame::MyFrame() : wxFrame(NULL, wxID_ANY, - _T("Render wxWidgets Sample"), + wxT("Render wxWidgets Sample"), wxPoint(50, 50), wxSize(450, 340)) { @@ -225,19 +231,19 @@ MyFrame::MyFrame() // 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")); + menuFile->Append(Render_Load, wxT("&Load renderer...\tCtrl-L")); + menuFile->Append(Render_Unload, wxT("&Unload renderer\tCtrl-U")); #endif // wxUSE_DYNLIB_CLASS - menuFile->Append(Render_Quit, _T("E&xit\tCtrl-Q"), _T("Quit this program")); + menuFile->Append(Render_Quit, wxT("E&xit\tCtrl-Q"), wxT("Quit this program")); // the "About" item should be in the help menu wxMenu *helpMenu = new wxMenu; - helpMenu->Append(Render_About, _T("&About...\tF1"), _T("Show about dialog")); + helpMenu->Append(Render_About, wxT("&About...\tF1"), wxT("Show about dialog")); // now append the freshly created menu to the menu bar... wxMenuBar *menuBar = new wxMenuBar(); - menuBar->Append(menuFile, _T("&File")); - menuBar->Append(helpMenu, _T("&Help")); + menuBar->Append(menuFile, wxT("&File")); + menuBar->Append(helpMenu, wxT("&Help")); // ... and attach this menu bar to the frame SetMenuBar(menuBar); @@ -248,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 wxWidgets!")); + SetStatusText(wxT("Welcome to wxWidgets!")); #endif // wxUSE_STATUSBAR Show(); @@ -266,12 +272,12 @@ MyFrame::~MyFrame() void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event)) { - static wxString s_name = _T("renddll"); + static wxString s_name = wxT("renddll"); wxString name = wxGetTextFromUser ( - _T("Name of the renderer to load:"), - _T("Render wxWidgets Sample"), + wxT("Name of the renderer to load:"), + wxT("Render wxWidgets Sample"), s_name, this ); @@ -286,7 +292,7 @@ void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event)) wxRendererNative *renderer = wxRendererNative::Load(name); if ( !renderer ) { - wxLogError(_T("Failed to load renderer \"%s\"."), name.c_str()); + wxLogError(wxT("Failed to load renderer \"%s\"."), name.c_str()); } else // loaded ok { @@ -294,7 +300,7 @@ void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event)) m_panel->Refresh(); - wxLogStatus(this, _T("Successfully loaded the renderer \"%s\"."), + wxLogStatus(this, wxT("Successfully loaded the renderer \"%s\"."), name.c_str()); } } @@ -308,11 +314,11 @@ void MyFrame::OnUnload(wxCommandEvent& WXUNUSED(event)) m_panel->Refresh(); - wxLogStatus(this, _T("Unloaded the previously loaded renderer.")); + wxLogStatus(this, wxT("Unloaded the previously loaded renderer.")); } else { - wxLogWarning(_T("No renderer to unload.")); + wxLogWarning(wxT("No renderer to unload.")); } } @@ -326,10 +332,10 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox(_T("Render sample shows how to use custom renderers.\n") - _T("\n") - _T("(c) 2003 Vadim Zeitlin"), - _T("About Render wxWidgets Sample"), + wxMessageBox(wxT("Render sample shows how to use custom renderers.\n") + wxT("\n") + wxT("(c) 2003 Vadim Zeitlin"), + wxT("About Render wxWidgets Sample"), wxOK | wxICON_INFORMATION, this); }