lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 3c9cc09 5/8: Generalize class wx_table_genera


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 3c9cc09 5/8: Generalize class wx_table_generator: row height and boolean flags
Date: Thu, 17 May 2018 19:07:10 -0400 (EDT)

branch: master
commit 3c9cc09e351167f7e2079aa303f59526026cb6f2
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Generalize class wx_table_generator: row height and boolean flags
    
    Chose settings in the ctor, depending on use case. Eliminated two public
    member functions. In using_illustration_table::create_table_generator(),
    constructed a wx_table_generator directly in the return statement.
    
    Every member that had been initialized by a brace-or-equal-initializer
    or a ctor-initializer is still initialized, but perhaps along one of the
    ctor's two execution paths. Although this may be confirmed today, with
    some effort, it's not robust under maintenance.
---
 ledger_pdf_generator_wx.cpp |  7 +------
 wx_table_generator.cpp      | 36 ++++++++++++++----------------------
 wx_table_generator.hpp      |  9 +++------
 3 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 3db5eff..4dfaab0 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -378,18 +378,13 @@ class using_illustration_table
         font.SetPointSize(9);
         pdf_dc.SetFont(font);
 
-        wx_table_generator table_gen
+        return wx_table_generator
             (vc
             ,writer.dc()
             ,writer.get_horz_margin()
             ,writer.get_page_width()
             ,e_illustration_style
             );
-
-        table_gen.use_condensed_style();
-        table_gen.align_right();
-
-        return table_gen;
     }
 };
 
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index c91bdfc..6858ba7 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -112,7 +112,7 @@
 // preferred not to do as part of illustrations work. Maybe now, that this is
 // merged, it's indeed worth changing this.
 //  OTOH, unlike a spreadsheet, this class doesn't have any notion of numeric
-// or text values, so its align_right() method is still useful to globally
+// or text values, so its align_right_ member is still useful to globally
 // configure all columns to be right-aligned. Perhaps we could just add a
 // similar align_centre() method and call it from the group PDF quotes code
 // and continue to handle the variable width columns specially by
@@ -158,7 +158,7 @@
 // The fundamental distinction is really
 // between fixed and variable width columns: the latter ones are always
 // left-aligned and need to be clipped, while the former ones are either
-// centered or right-aligned (if align_right() was called) and not clipped.
+// centered or right-aligned (if align_right_ is true) and not clipped.
 // And I think things are reasonably simple seen from this point of view and
 // this is how you're supposed to see them, because it's how this class is
 // used, while the various accessors discussed above are just its
@@ -241,7 +241,6 @@ wx_table_generator::wx_table_generator
     ,left_margin_(left_margin)
     ,total_width_(total_width)
     ,char_height_(dc_.GetCharHeight())
-    ,row_height_((4 * char_height_ + 2) / 3) // Arbitrarily use 1.333 line 
spacing.
     ,column_margin_(dc_.GetTextExtent("M").x)
     ,max_header_lines_(1)
 {
@@ -255,11 +254,23 @@ wx_table_generator::wx_table_generator
         {
         case e_illustration_style:
             {
+            row_height_ = char_height_;
+            draw_separators_ = false;
+            use_bold_headers_ = false;
+            // For the nonce, columns are centered by default because
+            // that's what group quotes need; this flag forces right
+            // alignment for illustrations.
+            align_right_ = true;
             dc_.SetPen(illustration_rule_color);
             }
             break;
         case e_group_quote_style:
             {
+            // Arbitrarily use 1.333 line spacing.
+            row_height_ = (4 * char_height_ + 2) / 3;
+            draw_separators_ = true;
+            use_bold_headers_ = true;
+            align_right_ = false;
             // Set a pen with zero width to make grid lines thin,
             // and round cap style so that they combine seamlessly.
             wxPen pen(*wxBLACK, 0);
@@ -284,25 +295,6 @@ std::vector<wx_table_generator::column_info> const& 
wx_table_generator::all_colu
     return all_columns_;
 }
 
-/// Use condensed style: don't draw separators between rows and make them
-/// smaller.
-
-void wx_table_generator::use_condensed_style()
-{
-    row_height_ = char_height_;
-    draw_separators_ = false;
-    use_bold_headers_ = false;
-}
-
-/// By default, columns are centered if they have fixed size or left-aligned
-/// otherwise. By calling this method, this alignment auto-detection is
-/// turned off and all columns are right-aligned.
-
-void wx_table_generator::align_right()
-{
-    align_right_ = true;
-}
-
 /// Indicate an intention to include a column by storing its metadata.
 ///
 /// The total number of columns thus enrolled determines the cardinality
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index 755248f..ba5fffb 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -120,9 +120,6 @@ class wx_table_generator
 
     int get_separator_line_height() const;
 
-    void use_condensed_style();
-    void align_right();
-
   private:
     void enroll_column(std::string const& header, std::string const& 
widest_text);
     void compute_column_widths();
@@ -164,14 +161,14 @@ class wx_table_generator
     // If false, separator lines are not drawn automatically (they can still be
     // drawn by calling output_horz_separator() or output_vert_separator()
     // explicitly).
-    bool draw_separators_ = true;
+    bool draw_separators_;
 
     // If true, headers are drawn in bold.
-    bool use_bold_headers_ = true;
+    bool use_bold_headers_;
 
     // If true, force right alignment for all columns instead of centering them
     // automatically if they have fixed size.
-    bool align_right_ = false;
+    bool align_right_;
 };
 
 #endif // wx_table_generator_hpp



reply via email to

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