X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/81d66cf39f810503baed79213bc3122fda0ccc7b..1144d24d25ebf729407db27594dd51778f77cec4:/samples/mdi/mdi.cpp diff --git a/samples/mdi/mdi.cpp b/samples/mdi/mdi.cpp index 24d2650b56..d47b5f2ac1 100644 --- a/samples/mdi/mdi.cpp +++ b/samples/mdi/mdi.cpp @@ -23,13 +23,22 @@ #include -#ifdef __WXGTK__ -#include "folder.xpm" +#if defined(__WXGTK__) || defined(__WXMOTIF__) +#include "mondrian.xpm" +#include "bitmaps/new.xpm" +#include "bitmaps/open.xpm" +#include "bitmaps/save.xpm" +#include "bitmaps/copy.xpm" +#include "bitmaps/cut.xpm" +#include "bitmaps/paste.xpm" +#include "bitmaps/print.xpm" +#include "bitmaps/help.xpm" #endif + #include "mdi.h" -MyFrame *frame = NULL; +MyFrame *frame = (MyFrame *) NULL; wxList my_children; IMPLEMENT_APP(MyApp) @@ -45,15 +54,14 @@ bool MyApp::OnInit(void) { // Create the main frame window - frame = new MyFrame(NULL, -1, "MDI Demo", wxPoint(0, 0), wxSize(500, 400), - wxDEFAULT_FRAME | wxHSCROLL | wxVSCROLL); + frame = new MyFrame((wxFrame *) NULL, -1, (char *) "MDI Demo", wxPoint(-1, -1), wxSize(500, 400), + wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL); - // Give it an icon (this is ignored in MDI mode: uses resources) + // Give it an icon #ifdef __WXMSW__ frame->SetIcon(wxIcon("mdi_icn")); -#endif -#ifdef __X__ - frame->SetIcon(wxIcon("aiai.xbm")); +#else + frame->SetIcon(wxIcon( mondrian_xpm )); #endif // Make a menubar @@ -100,39 +108,43 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c CreateToolBar(wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL); InitToolBar(GetToolBar()); + + // Accelerators + wxAcceleratorEntry entries[3]; + entries[0].Set(wxACCEL_CTRL, (int) 'N', MDI_NEW_WINDOW); + entries[1].Set(wxACCEL_CTRL, (int) 'X', MDI_QUIT); + entries[2].Set(wxACCEL_CTRL, (int) 'A', MDI_ABOUT); + wxAcceleratorTable accel(3, entries); + SetAcceleratorTable(accel); } -void MyFrame::OnQuit(wxCommandEvent& event) +void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) { Close(TRUE); } -void MyFrame::OnAbout(wxCommandEvent& event) +void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) { (void)wxMessageBox("wxWindows 2.0 MDI Demo\nAuthor: Julian Smart (c) 1997\nUsage: mdi.exe", "About MDI Demo"); } -void MyFrame::OnNewWindow(wxCommandEvent& event) +void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) { // Make another frame, containing a canvas - MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(10, 10), wxSize(300, 300), + MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(-1, -1), wxSize(-1, -1), wxDEFAULT_FRAME); - char titleBuf[100]; - sprintf(titleBuf, "Canvas Frame %d", winNumber); - subframe->SetTitle(titleBuf); + wxString title; + title.Printf("Canvas Frame %d", winNumber); + subframe->SetTitle(title); winNumber ++; - // Give it an icon (this is ignored in MDI mode: uses resources) + // Give it an icon #ifdef __WXMSW__ subframe->SetIcon(wxIcon("chrt_icn")); +#else + subframe->SetIcon(wxIcon( mondrian_xpm )); #endif -#ifdef __X__ - subframe->SetIcon(wxIcon("aiai.xbm")); -#endif - - // Give it a status line - subframe->CreateStatusBar(); // Make a menubar wxMenu *file_menu = new wxMenu; @@ -176,8 +188,9 @@ END_EVENT_TABLE() // Define a constructor for my canvas MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size): - wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER) + wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL) { + SetBackgroundColour(wxColour("WHITE")); } // Define the repainting behaviour @@ -241,12 +254,10 @@ bool MyFrame::OnClose(void) return TRUE; } -void MyFrame::OnSize(wxSizeEvent& event) +void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event) ) { int w, h; GetClientSize(&w, &h); - int tw = 0; - int th = 0; textWindow->SetSize(0, 0, 200, h); GetClientWindow()->SetSize(200, 0, w - 200, h); @@ -264,7 +275,7 @@ MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& const long style): wxMDIChildFrame(parent, -1, title, pos, size, style) { - canvas = NULL; + canvas = (MyCanvas *) NULL; my_children.Append(this); } @@ -303,14 +314,14 @@ void MyFrame::InitToolBar(wxToolBar* toolBar) bitmaps[6] = new wxBitmap("icon7", wxBITMAP_TYPE_RESOURCE); bitmaps[7] = new wxBitmap("icon8", wxBITMAP_TYPE_RESOURCE); #else - bitmaps[0] = new wxBitmap( folder_xpm ); - bitmaps[1] = new wxBitmap( folder_xpm ); - bitmaps[2] = new wxBitmap( folder_xpm ); - bitmaps[3] = new wxBitmap( folder_xpm ); - bitmaps[4] = new wxBitmap( folder_xpm ); - bitmaps[5] = new wxBitmap( folder_xpm ); - bitmaps[6] = new wxBitmap( folder_xpm ); - bitmaps[7] = new wxBitmap( folder_xpm ); + bitmaps[0] = new wxBitmap( new_xpm ); + bitmaps[1] = new wxBitmap( open_xpm ); + bitmaps[2] = new wxBitmap( save_xpm ); + bitmaps[3] = new wxBitmap( copy_xpm ); + bitmaps[4] = new wxBitmap( cut_xpm ); + bitmaps[5] = new wxBitmap( paste_xpm ); + bitmaps[6] = new wxBitmap( print_xpm ); + bitmaps[7] = new wxBitmap( help_xpm ); #endif #ifdef __WXMSW__ @@ -318,27 +329,26 @@ void MyFrame::InitToolBar(wxToolBar* toolBar) #else int width = 16; #endif - int offX = 5; int currentX = 5; - toolBar->AddTool(0, *bitmaps[0], wxNullBitmap, FALSE, currentX, -1, NULL, "New file"); + toolBar->AddTool( MDI_NEW_WINDOW, *(bitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New file"); currentX += width + 5; - toolBar->AddTool(1, *bitmaps[1], wxNullBitmap, FALSE, currentX, -1, NULL, "Open file"); + toolBar->AddTool(1, *bitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file"); currentX += width + 5; - toolBar->AddTool(2, *bitmaps[2], wxNullBitmap, FALSE, currentX, -1, NULL, "Save file"); + toolBar->AddTool(2, *bitmaps[2], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Save file"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(3, *bitmaps[3], wxNullBitmap, FALSE, currentX, -1, NULL, "Copy"); + toolBar->AddTool(3, *bitmaps[3], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Copy"); currentX += width + 5; - toolBar->AddTool(4, *bitmaps[4], wxNullBitmap, FALSE, currentX, -1, NULL, "Cut"); + toolBar->AddTool(4, *bitmaps[4], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Cut"); currentX += width + 5; - toolBar->AddTool(5, *bitmaps[5], wxNullBitmap, FALSE, currentX, -1, NULL, "Paste"); + toolBar->AddTool(5, *bitmaps[5], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(6, *bitmaps[6], wxNullBitmap, FALSE, currentX, -1, NULL, "Print"); + toolBar->AddTool(6, *bitmaps[6], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(7, *bitmaps[7], wxNullBitmap, TRUE, currentX, -1, NULL, "Help"); + toolBar->AddTool(7, *bitmaps[7], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Help"); toolBar->Realize();