#include <wx/toolbar.h>
-#ifdef __WXGTK__
+#if defined(__WXGTK__) || defined(__WXMOTIF__)
#include "mondrian.xpm"
#include "bitmaps/new.xpm"
#include "bitmaps/open.xpm"
{
// Create the main frame window
- frame = new MyFrame((wxFrame *) NULL, -1, (char *) "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"));
#else
CreateToolBar(wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL);
InitToolBar(GetToolBar());
-#ifdef __WXMSW__
// Accelerators
wxAcceleratorEntry entries[3];
entries[0].Set(wxACCEL_CTRL, (int) 'N', MDI_NEW_WINDOW);
entries[2].Set(wxACCEL_CTRL, (int) 'A', MDI_ABOUT);
wxAcceleratorTable accel(3, entries);
SetAcceleratorTable(accel);
-#endif
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
{
// Make another frame, containing a canvas
MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(-1, -1), wxSize(-1, -1),
- wxDEFAULT_FRAME);
+ wxDEFAULT_FRAME_STYLE);
wxString title;
title.Printf("Canvas Frame %d", winNumber);
// Give it an icon
#ifdef __WXMSW__
subframe->SetIcon(wxIcon("chrt_icn"));
+#else
+ subframe->SetIcon(wxIcon( mondrian_xpm ));
#endif
// Make a menubar
// 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
ypos = pt.y;
}
-// Define the behaviour for the frame closing
-// - must delete all frames except for the main one.
-bool MyFrame::OnClose(void)
-{
- // Must delete children
- wxNode *node = my_children.First();
- while (node)
- {
- MyChild *child = (MyChild *)node->Data();
- wxNode *next = node->Next();
- child->OnClose();
- delete child;
- node = next;
- }
- return TRUE;
-}
-
void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event) )
{
int w, h;
canvas->SetFocus();
}
-bool MyChild::OnClose(void)
-{
- return TRUE;
-}
-
void MyFrame::InitToolBar(wxToolBar* toolBar)
{
wxBitmap* bitmaps[8];
#endif
int currentX = 5;
- toolBar->AddTool(0, *(bitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) 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, (wxObject *) NULL, "Open file");
currentX += width + 5;