X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/74b31181b345aaaef0c967cc5707bef72ce0a405..1724915f18ca8887521e28cbfdaa05a7fdaa3c04:/samples/mdi/mdi.cpp diff --git a/samples/mdi/mdi.cpp b/samples/mdi/mdi.cpp index d22f58af32..423a2447be 100644 --- a/samples/mdi/mdi.cpp +++ b/samples/mdi/mdi.cpp @@ -80,6 +80,7 @@ END_EVENT_TABLE() BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame) EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit) EVT_MENU(MDI_REFRESH, MyChild::OnRefresh) + EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle) EVT_CLOSE(MyChild::OnClose) END_EVENT_TABLE() @@ -104,6 +105,14 @@ bool MyApp::OnInit() frame = new MyFrame((wxFrame *)NULL, -1, "MDI Demo", wxPoint(-1, -1), wxSize(500, 400), wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL); +#ifdef __WXMSW__ +#if 0 + // Experimental: change the window menu + wxMenu* windowMenu = new wxMenu; + windowMenu->Append(5000, "My menu item!"); + frame->SetWindowMenu(windowMenu); +#endif +#endif // Give it an icon #ifdef __WXMSW__ @@ -115,11 +124,11 @@ bool MyApp::OnInit() // Make a menubar wxMenu *file_menu = new wxMenu; - file_menu->Append(MDI_NEW_WINDOW, "&New window", "Create a new child window"); - file_menu->Append(MDI_QUIT, "&Exit", "Quit the program"); + file_menu->Append(MDI_NEW_WINDOW, "&New window\tCtrl-N", "Create a new child window"); + file_menu->Append(MDI_QUIT, "&Exit\tAlt-X", "Quit the program"); wxMenu *help_menu = new wxMenu; - help_menu->Append(MDI_ABOUT, "&About"); + help_menu->Append(MDI_ABOUT, "&About\tF1"); wxMenuBar *menu_bar = new wxMenuBar; @@ -225,8 +234,8 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) wxMenu *option_menu = new wxMenu; - // Dummy option option_menu->Append(MDI_REFRESH, "&Refresh picture"); + option_menu->Append(MDI_CHANGE_TITLE, "Change &title...\tCtrl-T"); wxMenu *help_menu = new wxMenu; help_menu->Append(MDI_ABOUT, "&About"); @@ -240,6 +249,9 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) // Associate the menu bar with the frame subframe->SetMenuBar(menu_bar); + subframe->CreateStatusBar(); + subframe->SetStatusText(title); + int width, height; subframe->GetClientSize(&width, &height); MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height)); @@ -249,9 +261,6 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) // Give it scrollbars canvas->SetScrollbars(20, 20, 50, 50); - subframe->CreateStatusBar(); - subframe->SetStatusText(title); - subframe->Show(TRUE); } @@ -349,7 +358,9 @@ void MyCanvas::OnDraw(wxDC& dc) dc.DrawRoundedRectangle(150, 150, 100, 50, 20); dc.DrawEllipse(250, 250, 100, 50); +#if wxUSE_SPLINES dc.DrawSpline(50, 200, 50, 100, 200, 10); +#endif // wxUSE_SPLINES dc.DrawLine(50, 230, 200, 230); dc.DrawText("This is a test string", 50, 230); @@ -405,9 +416,25 @@ void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event)) Close(TRUE); } -void MyChild::OnRefresh(wxCommandEvent& event) +void MyChild::OnRefresh(wxCommandEvent& WXUNUSED(event)) { - Refresh(); + if ( canvas ) + canvas->Refresh(); +} + +void MyChild::OnChangeTitle(wxCommandEvent& WXUNUSED(event)) +{ + static wxString s_title = _T("Canvas Frame"); + + wxString title = wxGetTextFromUser(_T("Enter the new title for MDI child"), + _T("MDI sample question"), + s_title, + GetParent()->GetParent()); + if ( !title ) + return; + + s_title = title; + SetTitle(s_title); } void MyChild::OnActivate(wxActivateEvent& event)