]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/docview.cpp
Moved Get/SetToolBar down into frame.h/cpp
[wxWidgets.git] / src / common / docview.cpp
index e22c78dd1421d27ef19b9fc53c6299415d674080..80ad3550d6ed0cb05a4cca0f65f00797e45b6065 100644 (file)
@@ -44,7 +44,7 @@
 #include "wx/generic/printps.h"
 
 /*
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
 #include "wx/mdi.h"
 #endif
 */
@@ -491,7 +491,7 @@ void wxView::OnChangeFilename(void)
     // If the frame is an MDI child, just set the title
     // to the name.
     // Otherwise, append the document name to the name of the application
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
     if (GetFrame()->IsKindOf(CLASSINFO(wxMDIChildFrame)))
 #else
     if (FALSE)
@@ -753,7 +753,7 @@ void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
   {
     // TODO: trouble about this is that it pulls in the postscript
     // code unecessarily
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
     if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS )
     {
       wxWindowsPrinter printer;
@@ -779,7 +779,7 @@ void wxDocManager::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
 
   wxPrintData data;
 
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
   if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS )
   {
     wxPrintDialog printerDialog(parentWin, & data);
@@ -806,7 +806,7 @@ void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
   {
     // Pass two printout objects: for preview, and possible printing.
     wxPrintPreviewBase *preview = NULL;
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
     if ( wxTheApp->GetPrintMode() == wxPRINT_WINDOWS )
         preview = new wxWindowsPrintPreview(printout, view->OnCreatePrintout());
     else
@@ -839,6 +839,30 @@ void wxDocManager::OnRedo(wxCommandEvent& WXUNUSED(event))
     doc->GetCommandProcessor()->Redo();
 }
 
+wxView *wxDocManager::GetCurrentView(void) const
+{
+    if (m_currentView)
+        return m_currentView;
+    if (m_docs.Number() == 1)
+    {
+        wxDocument* doc = (wxDocument*) m_docs.First()->Data();
+        return doc->GetFirstView();
+    }
+    return NULL;
+}
+
+// Extend event processing to search the view's event table
+bool wxDocManager::ProcessEvent(wxEvent& event)
+{
+    wxView* view = GetCurrentView();
+    if (view)
+    {
+        if (view->ProcessEvent(event))
+            return TRUE;
+    }
+    return wxEvtHandler::ProcessEvent(event);
+}
+
 wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags)
 {
   wxDocTemplate **templates = new wxDocTemplate *[m_templates.Number()];
@@ -1126,7 +1150,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
     int noTemplates, wxString& path, long WXUNUSED(flags), bool WXUNUSED(save))
 {
   // We can only have multiple filters in Windows
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
   char *descrBuf = new char[1000];
   descrBuf[0] = 0;
   int i;
@@ -1308,7 +1332,7 @@ BEGIN_EVENT_TABLE(wxDocChildFrame, wxFrame)
 END_EVENT_TABLE()
 
 wxDocChildFrame::wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, const wxString& title,
-  const wxPoint& pos, const wxSize& size, const long style, const wxString& name):
+  const wxPoint& pos, const wxSize& size, long style, const wxString& name):
     wxFrame(frame, -1, title, pos, size, style, name)
 {
   m_childDocument = doc;
@@ -1339,18 +1363,6 @@ bool wxDocChildFrame::ProcessEvent(wxEvent& event)
                return TRUE;
 }
 
-/*
-// Intercept menu commands
-void wxDocChildFrame::OldOnMenuCommand(int id)
-{
-  if (m_childView)
-    m_childView->Activate(TRUE);
-
-  if (GetParent())
-    ((wxFrame *)GetParent())->OldOnMenuCommand(id);
-}
-*/
-
 void wxDocChildFrame::OnActivate(wxActivateEvent& event)
 {
   wxFrame::OnActivate(event);
@@ -1389,7 +1401,7 @@ BEGIN_EVENT_TABLE(wxDocParentFrame, wxFrame)
 END_EVENT_TABLE()
 
 wxDocParentFrame::wxDocParentFrame(wxDocManager *manager, wxFrame *frame, const wxString& title,
-  const wxPoint& pos, const wxSize& size, const long style, const wxString& name):
+  const wxPoint& pos, const wxSize& size, long style, const wxString& name):
   wxFrame(frame, -1, title, pos, size, style, name)
 {
   m_docManager = manager;
@@ -1417,40 +1429,6 @@ bool wxDocParentFrame::ProcessEvent(wxEvent& event)
         return TRUE;
 }
 
-/*
-// Intercept menu commands
-void wxDocParentFrame::OldOnMenuCommand(int id)
-{
-  switch (id)
-  {
-    case wxID_EXIT:
-    {
-      Close();
-      break;
-    }
-    case wxID_FILE1:
-    case wxID_FILE2:
-    case wxID_FILE3:
-    case wxID_FILE4:
-    case wxID_FILE5:
-    case wxID_FILE6:
-    case wxID_FILE7:
-    case wxID_FILE8:
-    case wxID_FILE9:
-    {
-      wxString f(m_docManager->GetHistoryFile(id-wxID_FILE1));
-      if (f != "")
-        (void)m_docManager->CreateDocument(f, wxDOC_SILENT);
-      break;
-    }
-    default:
-    {
-      m_docManager->OldOnMenuCommand(id);
-    }
-  }
-}
-*/
-
 // Define the behaviour for the frame closing
 // - must delete all frames except for the main one.
 bool wxDocParentFrame::OnClose(void)