lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [6547] Refactor, eliminating protected virtuals


From: Greg Chicares
Subject: [lmi-commits] [6547] Refactor, eliminating protected virtuals
Date: Fri, 08 Apr 2016 01:25:24 +0000

Revision: 6547
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6547
Author:   chicares
Date:     2016-04-08 01:25:23 +0000 (Fri, 08 Apr 2016)
Log Message:
-----------
Refactor, eliminating protected virtuals

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/gpt_view.cpp
    lmi/trunk/illustration_view.cpp
    lmi/trunk/mec_view.cpp
    lmi/trunk/view_ex.cpp
    lmi/trunk/view_ex.hpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2016-04-07 23:10:11 UTC (rev 6546)
+++ lmi/trunk/ChangeLog 2016-04-08 01:25:23 UTC (rev 6547)
@@ -38870,3 +38870,36 @@
 Remove a superfluous cast (VZ). See:
   http://lists.nongnu.org/archive/html/lmi/2016-03/msg00057.html
 
+20160407T2310Z <address@hidden> [453]
+
+  census_view.cpp
+  census_view.hpp
+  database_view.cpp
+  database_view.hpp
+  gpt_view.cpp
+  gpt_view.hpp
+  illustration_view.cpp
+  illustration_view.hpp
+  mec_view.cpp
+  mec_view.hpp
+  policy_view.cpp
+  policy_view.hpp
+  rounding_view.cpp
+  rounding_view.hpp
+  text_view.hpp
+  text_view.cpp
+  tier_view.cpp
+  tier_view.hpp
+  view_ex.cpp
+  view_ex.hpp
+Refactor, eliminating public virtuals.
+
+20160408T0125Z <address@hidden> [451]
+
+  gpt_view.cpp
+  illustration_view.cpp
+  mec_view.cpp
+  view_ex.cpp
+  view_ex.hpp
+Refactor, eliminating protected virtuals.
+

Modified: lmi/trunk/gpt_view.cpp
===================================================================
--- lmi/trunk/gpt_view.cpp      2016-04-07 23:10:11 UTC (rev 6546)
+++ lmi/trunk/gpt_view.cpp      2016-04-08 01:25:23 UTC (rev 6547)
@@ -134,7 +134,7 @@
     return "gpt_view_menu";
 }
 
-/// This virtual function calls its base-class namesake explicitly.
+/// Pop up an input dialog; iff it's not cancelled, create a view.
 ///
 /// Trap exceptions to ensure that this function returns 'false' on
 /// failure, lest wx's doc-view framework create a zombie view. See:
@@ -150,7 +150,7 @@
             return has_view_been_created;
             }
 
-        has_view_been_created = ViewEx::OnCreate(doc, flags);
+        has_view_been_created = ViewEx::DoOnCreate(doc, flags);
         if(!has_view_been_created)
             {
             return has_view_been_created;

Modified: lmi/trunk/illustration_view.cpp
===================================================================
--- lmi/trunk/illustration_view.cpp     2016-04-07 23:10:11 UTC (rev 6546)
+++ lmi/trunk/illustration_view.cpp     2016-04-08 01:25:23 UTC (rev 6547)
@@ -158,7 +158,7 @@
     return "illustration_view_menu";
 }
 
-/// This virtual function calls its base-class namesake explicitly.
+/// Pop up an input dialog; iff it's not cancelled, create a view.
 ///
 /// Trap exceptions to ensure that this function returns 'false' on
 /// failure, lest wx's doc-view framework create a zombie view. See:
@@ -173,7 +173,7 @@
         if(flags & LMI_WX_CHILD_DOCUMENT)
             {
             is_phony_ = true;
-            has_view_been_created = ViewEx::OnCreate(doc, flags);
+            has_view_been_created = ViewEx::DoOnCreate(doc, flags);
             return has_view_been_created;
             }
 
@@ -182,7 +182,7 @@
             return has_view_been_created;
             }
 
-        has_view_been_created = ViewEx::OnCreate(doc, flags);
+        has_view_been_created = ViewEx::DoOnCreate(doc, flags);
         if(!has_view_been_created)
             {
             return has_view_been_created;

Modified: lmi/trunk/mec_view.cpp
===================================================================
--- lmi/trunk/mec_view.cpp      2016-04-07 23:10:11 UTC (rev 6546)
+++ lmi/trunk/mec_view.cpp      2016-04-08 01:25:23 UTC (rev 6547)
@@ -134,7 +134,7 @@
     return "mec_view_menu";
 }
 
-/// This virtual function calls its base-class namesake explicitly.
+/// Pop up an input dialog; iff it's not cancelled, create a view.
 ///
 /// Trap exceptions to ensure that this function returns 'false' on
 /// failure, lest wx's doc-view framework create a zombie view. See:
@@ -150,7 +150,7 @@
             return has_view_been_created;
             }
 
-        has_view_been_created = ViewEx::OnCreate(doc, flags);
+        has_view_been_created = ViewEx::DoOnCreate(doc, flags);
         if(!has_view_been_created)
             {
             return has_view_been_created;

Modified: lmi/trunk/view_ex.cpp
===================================================================
--- lmi/trunk/view_ex.cpp       2016-04-07 23:10:11 UTC (rev 6546)
+++ lmi/trunk/view_ex.cpp       2016-04-08 01:25:23 UTC (rev 6547)
@@ -152,17 +152,35 @@
     return true;
 }
 
-// WX !! The wx documentation for wxDocMDIChildFrame::OnActivate() says
-//   "You may need to override (but still call) this function in order
-//   to set the keyboard focus for your subwindow."
-// At least for msw, creation does not trigger 'activation': more
-// precisely, WM_MDICREATE does not send WM_MDIACTIVATE, and
-// OnActivate() doesn't get called when the window is created, so the
-// documented method doesn't work--whereas setting the focus upon
-// creation here does work.
-//
-bool ViewEx::OnCreate(wxDocument* doc, long int)
+/// Initialize a document view in an MDI window.
+///
+/// Completely replaces wxView::OnCreate(), whose implementation is
+/// merely {return true;} as of wx-3.1 .
+///
+/// This default implementation simply forwards to DoOnCreate().
+///
+/// WX !! The documentation for wxDocMDIChildFrame::OnActivate() says
+///   "You may need to override (but still call) this function in
+///   order to set the keyboard focus for your subwindow."
+/// At least for msw, creation does not trigger 'activation': more
+/// precisely, WM_MDICREATE does not send WM_MDIACTIVATE, and
+/// OnActivate() doesn't get called when the window is created, so the
+/// documented method doesn't work--whereas setting the focus upon
+/// creation here does work.
+
+bool ViewEx::OnCreate(wxDocument* doc, long int flags)
 {
+    return DoOnCreate(doc, flags);
+}
+
+/// Default implementation for OnCreate().
+///
+/// Some derived classes call this function in an OnCreate() override,
+/// e.g. to pop up an input dialog and create a view only if the
+/// dialog is not cancelled.
+
+bool ViewEx::DoOnCreate(wxDocument* doc, long int)
+{
     Skeleton& app = safely_dereference_as<Skeleton>(wxApp::GetInstance());
     app.CreateChildFrame(doc, this);
 

Modified: lmi/trunk/view_ex.hpp
===================================================================
--- lmi/trunk/view_ex.hpp       2016-04-07 23:10:11 UTC (rev 6546)
+++ lmi/trunk/view_ex.hpp       2016-04-08 01:25:23 UTC (rev 6547)
@@ -51,12 +51,13 @@
 // read from an XRC resource. SOMEDAY !! Should these public functions
 // cache XRC resources in a static variable for better responsiveness?
 
-// OnCreate() and OnClose() are implemented here because it is not
-// anticipated that their essential behavior would differ in client
-// classes. Small differences can be factored into pure functions:
-// for instance, OnCreate() calls CreateChildWindow().
+// OnClose() is implemented here because it is not anticipated that
+// its essential behavior would differ in client classes.
 
-// TODO ?? Revise the preceding comment.
+// OnCreate() has a default implementation, in DoOnCreate(), which is
+// suitable for many client classes; others call DoOnCreate() in their
+// implementations. DoOnCreate() calls CreateChildWindow(), which is a
+// pure function because clients create different window types.
 
 // OnDraw() is pure in base class wxView. An (empty) implementation is
 // supplied here because no view class in the application this is
@@ -101,13 +102,7 @@
 
     std::string base_filename() const;
 
-    // TODO ?? Probably better to provide the implementation in
-    // separate functions that can be called by derived classes.
-    //
-    // wxView overrides.
-    virtual bool OnClose(bool delete_window);
-    virtual bool OnCreate(wxDocument* doc, long int flags);
-    virtual void OnDraw(wxDC*);
+    bool DoOnCreate(wxDocument* doc, long int flags);
 
   private:
     // Pure virtuals.
@@ -115,6 +110,11 @@
     virtual char const* icon_xrc_resource   () const = 0;
     virtual char const* menubar_xrc_resource() const = 0;
 
+    // wxView overrides.
+    virtual bool OnClose(bool delete_window);
+    virtual bool OnCreate(wxDocument* doc, long int flags);
+    virtual void OnDraw(wxDC*);
+
     wxIcon     IconFromXmlResource   (char const*) const;
     wxMenuBar* MenuBarFromXmlResource(char const*) const;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]