void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) { // Make another frame, containing a canvas MyChild *subframe = new MyChild(frame, _T("Canvas Frame")); wxString title; title.Printf(_T("Canvas Frame %d"), ++gs_nFrames); subframe->SetTitle(title); // Give it an icon #ifdef __WXMSW__ subframe->SetIcon(wxIcon(_T("chrt_icn"))); #else subframe->SetIcon(wxIcon( mondrian_xpm )); #endif // Make a menubar wxMenu *file_menu = new wxMenu; file_menu->Append(MDI_NEW_WINDOW, _T("&New window")); file_menu->Append(MDI_CHILD_QUIT, _T("&Close child"), _T("Close this window")); file_menu->Append(MDI_QUIT, _T("&Exit")); wxMenu *option_menu = new wxMenu; option_menu->Append(MDI_REFRESH, _T("&Refresh picture")); option_menu->Append(MDI_CHANGE_TITLE, _T("Change &title...\tCtrl-T")); option_menu->AppendSeparator(); option_menu->Append(MDI_CHANGE_POSITION, _T("Move frame\tCtrl-M")); option_menu->Append(MDI_CHANGE_SIZE, _T("Resize frame\tCtrl-S")); wxMenu *help_menu = new wxMenu; help_menu->Append(MDI_ABOUT, _T("&About")); wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(file_menu, _T("&File")); menu_bar->Append(option_menu, _T("&Child")); menu_bar->Append(help_menu, _T("&Help")); // Associate the menu bar with the frame subframe->SetMenuBar(menu_bar); #if wxUSE_STATUSBAR subframe->CreateStatusBar(); subframe->SetStatusText(title); #endif // wxUSE_STATUSBAR int width, height; subframe->GetClientSize(&width, &height); MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height)); canvas->SetCursor(wxCursor(wxCURSOR_PENCIL)); subframe->canvas = canvas; // Give it scrollbars canvas->SetScrollbars(20, 20, 50, 50); subframe->Show(true); }
wxFrame *MyApp::CreateFrame() { MyChild *subframe = new MyChild(NULL, _T("Canvas Frame"), wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE); subframe->SetTitle(_T("wxWidgets canvas frame")); // Give it a status line subframe->CreateStatusBar(); // Make a menubar wxMenu *file_menu = new wxMenu; file_menu->Append(HELLO_NEW, _T("&New MFC Window")); file_menu->Append(HELLO_QUIT, _T("&Close")); wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(file_menu, _T("&File")); // Associate the menu bar with the frame subframe->SetMenuBar(menu_bar); int width, height; subframe->GetClientSize(&width, &height); MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height)); canvas->SetCursor(wxCursor(wxCURSOR_PENCIL)); subframe->canvas = canvas; subframe->Show(true); // Return the main frame window return subframe; }
void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event)) { // Make another frame, containing a canvas MyChild *subframe = new MyChild(frame, wxT("Canvas Frame"), wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); subframe->SetTitle(wxString::Format(wxT("Canvas Frame %d"), winNumber)); winNumber ++; // Give it an icon (this is ignored in MDI mode: uses resources) #ifdef __WXMSW__ subframe->SetIcon(wxIcon(wxT("sashtest_icn"))); #endif #if wxUSE_STATUSBAR // Give it a status line subframe->CreateStatusBar(); #endif // wxUSE_STATUSBAR // Make a menubar wxMenu *file_menu = new wxMenu; file_menu->Append(SASHTEST_NEW_WINDOW, wxT("&New window")); file_menu->Append(SASHTEST_CHILD_QUIT, wxT("&Close child")); file_menu->Append(SASHTEST_QUIT, wxT("&Exit")); wxMenu *option_menu = new wxMenu; // Dummy option option_menu->Append(SASHTEST_REFRESH, wxT("&Refresh picture")); wxMenu *help_menu = new wxMenu; help_menu->Append(SASHTEST_ABOUT, wxT("&About")); wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(file_menu, wxT("&File")); menu_bar->Append(option_menu, wxT("&Options")); menu_bar->Append(help_menu, wxT("&Help")); // Associate the menu bar with the frame subframe->SetMenuBar(menu_bar); int width, height; subframe->GetClientSize(&width, &height); MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height)); canvas->SetCursor(wxCursor(wxCURSOR_PENCIL)); subframe->canvas = canvas; // Give it scrollbars canvas->SetScrollbars(20, 20, 50, 50); subframe->Show(true); }
void MyFrame::OnNewWindow(wxCommandEvent& event) {//============================================= SpectSeq *spectseq; wxString leaf; wxString pathload; int width, height; if(event.GetId() == MENU_SPECTRUM) pathload = path_spectload; else pathload = path_spectload2; wxString filename = wxFileSelector(_T("Read spectrum or praat data"),pathload, _T(""),_T(""),_T("*"),wxOPEN); if(filename.IsEmpty()) { return; } // create SpectSeq and import data spectseq = new SpectSeq; if(spectseq == NULL) { wxLogError(_T("Failed to create SpectSeq")); return; } wxFileInputStream stream(filename); if(stream.Ok() == FALSE) { wxLogError(_T("Failed to open '%s'"),filename.c_str()); return; } wxFileName path = wxFileName(filename); leaf = path.GetName(); setlocale(LC_NUMERIC,"C"); // read numbers in the form 1.23456 spectseq->Load(stream); spectseq->name = leaf; spectseq->MakePitchenv(spectseq->pitchenv,0,spectseq->numframes-1); if(event.GetId() == MENU_SPECTRUM) path_spectload = path.GetPath(); else path_spectload2 = path.GetPath(); // Make another frame, containing a canvas GetClientSize(&width, &height); MyChild *subframe = new MyChild(myframe, _T("Spectrum"), wxPoint(10, 0), wxSize(500, height), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); subframe->SetTitle(leaf); // Give it a status line subframe->CreateStatusBar(); subframe->GetClientSize(&width, &height); SpectDisplay *canvas = new SpectDisplay(subframe, wxPoint(0, 0), wxSize(width, height), spectseq); canvas->savepath = filename; currentcanvas = canvas; // Associate the menu bar with the frame subframe->SetMenuBar(MakeMenu(1,translator->dictionary_name)); subframe->canvas = canvas; subframe->Show(TRUE); }