lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 6d8e0ea 1/8: Move most members from derived t


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 6d8e0ea 1/8: Move most members from derived to base class
Date: Thu, 17 May 2018 19:07:09 -0400 (EDT)

branch: master
commit 6d8e0ea40e3c0a1a4de157748b12398c831e1b18
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Move most members from derived to base class
    
    Historically, base class wx_table_generator was written to support group
    premium quotes, and the later derived class illustration_table_generator
    was "slightly specialized" to support illustration PDFs. In a textbook
    design, the base class might provide only what's common between the two
    use cases, each of which might then have its own derived class for
    specializations:
    
                 B (base)
                 |
          +------+------+
          |             |
         DQ (quotes)    DI (illustrations)
    
    For historical reasons, operations like output_highlighted_cell() that
    are used only for group quotes were added to class wx_table_generator,
    which was the only table-generator class at that time, before the idea
    of reusing the code for illustrations was discussed. Therefore, that
    class may seem to be B because it's used as a base of DI, but really it
    performs the job of DQ--and deriving DI from DQ seems weird.
    
    It would be possible to refactor class wx_table_generator into B and DQ,
    but the differences are too small to justify an elaborate hierarchy, so
    instead
     - this commit merges the differences DI-B into B, and
     - the next commit will eliminate DI (illustration_table_generator),
    so that a single class will be used for all purposes.
    
    This is only an initial top-level step. The historical context pervades
    the design--e.g., the notional DQ centers all columns but one, and DI
    overrides that to right-align all its columns, but there's solid B code
    in wx_table_generator that is capable of handling alignment flexibly, if
    only class wx_table_generator::column_info realized that.
    
    This commit is mostly a copy-paste move, and
      git diff --ignore-all-space --color-moved=plain
    makes that easier to see.
---
 ledger_pdf_generator_wx.cpp | 11 -----------
 wx_table_generator.cpp      |  9 +++++++++
 wx_table_generator.hpp      |  4 ++++
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 74ff28c..96b9938 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -320,8 +320,6 @@ class html_interpolator
 class illustration_table_generator : public wx_table_generator
 {
   public:
-    static int const rows_per_group = 5;
-
     illustration_table_generator
         (std::vector<column_parameters> const& vc
         ,wxDC&                                 dc
@@ -333,15 +331,6 @@ class illustration_table_generator : public 
wx_table_generator
         use_condensed_style();
         align_right();
     }
-
-    // Return the amount of vertical space taken by separator lines in the
-    // table headers.
-    int get_separator_line_height() const
-    {
-        // This is completely arbitrary and chosen just because it seems to
-        // look well.
-        return row_height() / 2;
-    }
 };
 
 // A helper mix-in class for pages using tables which is also reused by the
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 72cb4fd..0ccc57c 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -766,6 +766,15 @@ void wx_table_generator::output_horz_separator
     do_output_horz_separator(x1, x2, y);
 }
 
+// Return the amount of vertical space taken by separator lines in the
+// table headers.
+int wx_table_generator::get_separator_line_height() const
+{
+    // This is completely arbitrary and chosen just because it seems to
+    // look well.
+    return row_height() / 2;
+}
+
 /// Render the headers at the given position and update it.
 
 void wx_table_generator::output_header
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index dd35ed8..4219217 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -56,6 +56,8 @@ class wx_table_generator
     class column_info;
 
   public:
+    static int const rows_per_group = 5;
+
     wx_table_generator
         (std::vector<column_parameters> const& vc
         ,wxDC&                                 dc
@@ -102,6 +104,8 @@ class wx_table_generator
 
     void output_vert_separator(std::size_t before_column, int y);
 
+    int get_separator_line_height() const;
+
     void use_condensed_style();
     void align_right();
 



reply via email to

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