lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master a95ec51 4/8: Separate public and private inte


From: Greg Chicares
Subject: [lmi-commits] [lmi] master a95ec51 4/8: Separate public and private interfaces
Date: Mon, 6 Aug 2018 18:36:24 -0400 (EDT)

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

    Separate public and private interfaces
    
    Made the public and private interfaces of class wx_table_generator
    disjoint (except for the trivial row_height() accessor). In particular,
    column numbers now enter wx_table_generator only through the public
    interface, which is never used in the implementation. Establishing this
    chokepoint for column numbers makes a larger refactoring possible, to
    address various concerns noted inline, e.g.:
    
        // PDF !! This derived class and its siblings each contain an enum
        // like the following. Most of the enumerators are unused. They
        // index the container returned by get_table_columns(), and must
        // be maintained in parallel with it so that the two lists match
        // perfectly.
    
        // PDF !! Most overrides have exactly this function body:
        //    {
        //    // Don't show AttainedAge on a composite.
        //    return ledger.is_composite() && column == column_end_of_y...
        //    }
        // However, that cannot be written here, once and only once,
        // because 'column_end_of_year_age' is an enumerator whose value
        // may differ in each derived class.
    
    /// PDF !! Instead of retaining hidden columns, and explicitly skipping
    /// them here and repeatedly later (and also in set_column_widths()),
    /// consider removing them from the vector.
    ///   ... PDF !! In those instances, hidden columns
    ///   are skipped implicitly rather than explicitly; this is a further
    ///   argument against trafficking in hidden columns.
---
 group_quote_pdf_gen_wx.cpp | 12 +++++++-----
 wx_table_generator.cpp     |  5 +++++
 wx_table_generator.hpp     |  6 +++++-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index beb806e..6546fc5 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -1038,9 +1038,9 @@ void group_quote_pdf_generator_wx::output_document_header
 }
 
 void group_quote_pdf_generator_wx::output_aggregate_values
-    (pdf_writer_wx& pdf_writer
+    (pdf_writer_wx     & pdf_writer
     ,wx_table_generator& table_gen
-    ,int* pos_y
+    ,int               * pos_y // PDF !! Use reference, not pointer.
     )
 {
     int& y = *pos_y;
@@ -1058,10 +1058,12 @@ void 
group_quote_pdf_generator_wx::output_aggregate_values
     auto& pdf_dc = pdf_writer.dc();
 
     // Render "Census" in bold.
+    // PDF !! Instead, consider using output_highlighted_cell(), with extra
+    // arguments to specify font, brush, and pen.
     wxDCFontChanger set_bold_font(pdf_dc, pdf_dc.GetFont().Bold());
     pdf_dc.DrawLabel
         ("Census"
-        ,table_gen.text_rect(e_col_name, y)
+        ,table_gen.external_text_rect(e_col_name, y)
         ,wxALIGN_LEFT
         );
 
@@ -1073,13 +1075,13 @@ void 
group_quote_pdf_generator_wx::output_aggregate_values
     LMI_ASSERT(0 < e_first_totalled_column);
     pdf_dc.DrawLabel
         ("Totals:"
-        ,table_gen.text_rect(e_first_totalled_column - 1, y)
+        ,table_gen.external_text_rect(e_first_totalled_column - 1, y)
         ,wxALIGN_RIGHT
         );
 
     pdf_dc.DrawLabel
         ("Average Cost per $1000:"
-        ,table_gen.text_rect(e_first_totalled_column - 1, y_next)
+        ,table_gen.external_text_rect(e_first_totalled_column - 1, y_next)
         ,wxALIGN_RIGHT
         );
 
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 19509df..3726aed 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -328,6 +328,11 @@ int wx_table_generator::separator_line_height() const
     return row_height() / 2;
 }
 
+wxRect wx_table_generator::external_text_rect(std::size_t column, int y) const
+{
+    return text_rect(column, y);
+}
+
 /// Rectangle corresponding to a cell's text contents.
 ///
 /// This is narrower than the full cell rectangle to leave a small
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index 079a63e..a5304e3 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -123,7 +123,10 @@ class wx_table_generator
     int row_height() const;
     int separator_line_height() const;
 
-    wxRect text_rect(std::size_t column, int y) const;
+    // Used only by group_quote_pdf_generator_wx::output_aggregate_values(),
+    // in a context where something like output_highlighted_cell() should
+    // probably be used instead. PDF !! revisit this later
+    wxRect external_text_rect(std::size_t column, int y) const;
 
   private:
     void enroll_column(column_parameters const&);
@@ -139,6 +142,7 @@ class wx_table_generator
 
     int cell_pos_x(std::size_t column) const;
 
+    wxRect text_rect(std::size_t column, int y) const;
     wxRect cell_rect(std::size_t column, int y) const;
 
     wxFont header_font() const;



reply via email to

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