]> git.saurik.com Git - wxWidgets.git/commitdiff
Restore wxPreviewFrame::Initialize(void) and add InitializeWithModality().
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 22 Jun 2011 22:58:07 +0000 (22:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 22 Jun 2011 22:58:07 +0000 (22:58 +0000)
The changes of r67619 changed the signature of the virtual Initialize() method
and in doing so broke the existing code overriding it. Avoid this problem by
restoring the old method signature and adding a function with a different name
providing the new functionality.

Also notice in the documentation that there is no real need to override
Initialize() in any case (but this doesn't change the fact that there is
existing code that does do it).

See #13108.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68026 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/prntbase.h
interface/wx/print.h
src/common/prntbase.cpp

index c6bdc8c00f5aaac02ef8fd8344b7efb432ccf871..ac78189a42b535ea97722219e9a3b50bfc51f385 100644 (file)
@@ -398,9 +398,26 @@ public:
                    const wxString& name = wxFrameNameStr);
     virtual ~wxPreviewFrame();
 
+    // Either Initialize() or InitializeWithModality() must be called before
+    // showing the preview frame, the former being just a particular case of
+    // the latter initializing the frame for being showing app-modally.
+
+    // Notice that we must keep Initialize() with its existing signature to
+    // avoid breaking the old code that overrides it and we can't reuse the
+    // same name for the other functions to avoid virtual function hiding
+    // problem and the associated warnings given by some compilers (e.g. from
+    // g++ with -Woverloaded-virtual).
+    virtual void Initialize()
+    {
+        InitializeWithModality(wxPreviewFrame_AppModal);
+    }
+
+    // Also note that this method is not virtual as it doesn't need to be
+    // overridden: it's never called by wxWidgets (of course, the same is true
+    // for Initialize() but, again, it must remain virtual for compatibility).
+    void InitializeWithModality(wxPreviewFrameModalityKind kind);
+
     void OnCloseWindow(wxCloseEvent& event);
-    virtual void Initialize(wxPreviewFrameModalityKind kind
-                                = wxPreviewFrame_AppModal);
     virtual void CreateCanvas();
     virtual void CreateControlBar();
 
index 8eb1e3764ba9502138559b57377ae1c4e84702bf..4713bf32eb80fb136ad9b66126a5489058189d48 100644 (file)
@@ -195,21 +195,44 @@ public:
     virtual void CreateControlBar();
 
     /**
-        Creates the preview canvas and control bar.
+        Initializes the frame elements and prepares for showing it.
 
-        By default also disables the other existing top level windows to
-        prepare for showing the preview frame modally. Since wxWidgets 2.9.2
-        this can be changed by specifying either wxPreviewFrame_WindowModal --
-        to disable just the parent window -- or wxPreviewFrame_NonModal -- to
-        not disable any windows at all -- as @a kind parameter.
+        Calling this method is equivalent to calling InitializeWithModality()
+        with wxPreviewFrame_AppModal argument, please see its documentation for
+        more details.
 
-        This function must be called by the application prior to showing the frame.
+        Please notice that this function is virtual mostly for backwards
+        compatibility only, there is no real need to override it as it's never
+        called by wxWidgets itself.
+     */
+    virtual void Initialize();
+
+    /**
+        Initializes the frame elements and prepares for showing it with the
+        given modality kind.
+
+        This method creates the frame elements by calling CreateCanvas() and
+        CreateControlBar() methods (which may be overridden to customize them)
+        and prepares to show the frame according to the value of @a kind
+        parameter:
+            - If it is wxPreviewFrame_AppModal, all the other application
+            windows will be disabled when this frame is shown. This is the same
+            behaviour as that of simple Initialize().
+            - If it is wxPreviewFrame_WindowModal, only the parent window of
+            the preview frame will be disabled when it is shown.
+            - And if it is wxPreviewFrame_NonModal, no windows at all will be
+            disabled while the preview is shown.
+
+        Notice that this function (or Initialize()) must be called by the
+        application prior to showing the frame but you still must call @c
+        Show(true) to actually show it afterwards.
 
         @param kind
-            The modality kind of preview frame. @since 2.9.2
+            The modality kind of preview frame.
+
+        @since 2.9.2
     */
-    virtual void Initialize(wxPreviewFrameModalityKind kind
-                                = wxPreviewFrame_AppModal);
+    virtual void InitializeWithModality(wxPreviewFrameModalityKind kind);
 
     /**
         Enables any disabled frames in the application, and deletes the print preview
index afc15eec5c674c48f394a213093aabff6c25ac1a..4aebfb1b5165056d35f279a8e0e98c9ad43e4e55 100644 (file)
@@ -1667,7 +1667,7 @@ void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
     Destroy();
 }
 
-void wxPreviewFrame::Initialize(wxPreviewFrameModalityKind kind)
+void wxPreviewFrame::InitializeWithModality(wxPreviewFrameModalityKind kind)
 {
 #if wxUSE_STATUSBAR
     CreateStatusBar();