]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/prntbase.cpp
fixing osx_cocoa
[wxWidgets.git] / src / common / prntbase.cpp
index 0f4559e759c0f296e703711023173861a4edd5fb..4aebfb1b5165056d35f279a8e0e98c9ad43e4e55 100644 (file)
@@ -1619,6 +1619,7 @@ wxFrame(parent, wxID_ANY, title, pos, size, style, name)
     m_controlBar = NULL;
     m_previewCanvas = NULL;
     m_windowDisabler = NULL;
+    m_modalityKind = wxPreviewFrame_NonModal;
 
     // Give the application icon
 #ifdef __WXMSW__
@@ -1630,14 +1631,6 @@ wxFrame(parent, wxID_ANY, title, pos, size, style, name)
 
 wxPreviewFrame::~wxPreviewFrame()
 {
-}
-
-void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
-{
-    if (m_windowDisabler)
-        delete m_windowDisabler;
-
-    // Need to delete the printout and the print preview
     wxPrintout *printout = m_printPreview->GetPrintout();
     if (printout)
     {
@@ -1648,12 +1641,33 @@ void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
     }
 
     m_previewCanvas->SetPreview(NULL);
-    wxDELETE(m_printPreview);
+    delete m_printPreview;
+}
+
+void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
+{
+    // Reenable any windows we disabled by undoing whatever we did in our
+    // Initialize().
+    switch ( m_modalityKind )
+    {
+        case wxPreviewFrame_AppModal:
+            delete m_windowDisabler;
+            m_windowDisabler = NULL;
+            break;
+
+        case wxPreviewFrame_WindowModal:
+            if ( GetParent() )
+                GetParent()->Enable();
+            break;
+
+        case wxPreviewFrame_NonModal:
+            break;
+    }
 
     Destroy();
 }
 
-void wxPreviewFrame::Initialize()
+void wxPreviewFrame::InitializeWithModality(wxPreviewFrameModalityKind kind)
 {
 #if wxUSE_STATUSBAR
     CreateStatusBar();
@@ -1672,7 +1686,25 @@ void wxPreviewFrame::Initialize()
     SetAutoLayout( true );
     SetSizer( item0 );
 
-    m_windowDisabler = new wxWindowDisabler(this);
+    m_modalityKind = kind;
+    switch ( m_modalityKind )
+    {
+        case wxPreviewFrame_AppModal:
+            // Disable everything.
+            m_windowDisabler = new wxWindowDisabler( this );
+            break;
+
+        case wxPreviewFrame_WindowModal:
+            // Disable our parent if we have one.
+            if ( GetParent() )
+                GetParent()->Disable();
+            break;
+
+        case wxPreviewFrame_NonModal:
+            // Nothing to do, we don't need to disable any windows.
+            break;
+    }
+
 
     Layout();
 
@@ -1957,7 +1989,7 @@ bool wxPrintPreviewBase::RenderPage(int pageNum)
     {
         m_previewBitmap = new wxBitmap(pageRect.width, pageRect.height);
 
-        if (!m_previewBitmap || !m_previewBitmap->Ok())
+        if (!m_previewBitmap || !m_previewBitmap->IsOk())
         {
             InvalidatePreviewBitmap();
             wxMessageBox(_("Sorry, not enough memory to create a preview."), _("Print Preview Failure"), wxOK);
@@ -2178,7 +2210,7 @@ int wxPrintPreview::GetMinPage() const
 
 bool wxPrintPreview::IsOk() const
 {
-    return m_pimpl->Ok();
+    return m_pimpl->IsOk();
 }
 
 void wxPrintPreview::SetOk(bool ok)