- if (!singleWindowMode)
- {
- // Multiple windows
- frame = wxGetApp().CreateChildFrame(doc, this, TRUE);
- frame->SetTitle("DrawingView");
-
- canvas = GetMainFrame()->CreateCanvas(this, frame);
-#ifdef __X__
- // X seems to require a forced resize
- int x, y;
- frame->GetSize(&x, &y);
- frame->SetSize(x, y);
-#endif
- frame->Show(TRUE);
- }
- else
- {
- // Single-window mode
- frame = GetMainFrame();
- canvas = GetMainFrame()->canvas;
- canvas->view = this;
-
- // Associate the appropriate frame with this view.
- SetFrame(frame);
-
- // Make sure the document manager knows that this is the
- // current view.
- Activate(TRUE);
-
- // Initialize the edit menu Undo and Redo items
- doc->GetCommandProcessor()->SetEditMenu(((MyFrame *)frame)->editMenu);
- doc->GetCommandProcessor()->Initialize();
- }
-
- return TRUE;
+ MyApp& app = wxGetApp();
+ if ( app.GetMode() != MyApp::Mode_Single )
+ {
+ // create a new window and canvas inside it
+ m_frame = app.CreateChildFrame(doc, this, true);
+ m_frame->SetTitle("Drawing View");
+
+ m_canvas = new MyCanvas(this, m_frame);
+ m_frame->Show(true);
+ }
+ else // single document mode
+ {
+ // reuse the existing window and canvas
+ m_frame = wxStaticCast(app.GetTopWindow(), wxFrame);
+ m_canvas = app.GetMainWindowCanvas();
+ m_canvas->SetView(this);
+
+ // Associate the appropriate frame with this view.
+ SetFrame(m_frame);
+
+ // Make sure the document manager knows that this is the
+ // current view.
+ Activate(true);
+
+ // Initialize the edit menu Undo and Redo items
+ doc->GetCommandProcessor()->SetEditMenu(app.GetMainWindowEditMenu());
+ doc->GetCommandProcessor()->Initialize();
+ }
+
+ return true;