lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master b232274 02/12: Make column elasticity enumera


From: Greg Chicares
Subject: [lmi-commits] [lmi] master b232274 02/12: Make column elasticity enumerative rather than boolean
Date: Tue, 22 May 2018 17:09:21 -0400 (EDT)

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

    Make column elasticity enumerative rather than boolean
    
    "Elasticity" means the property the group-quote "Participant" column
    has and other columns lack: it grows or shrinks to consume any page
    width that other columns don't claim, and its contents are clipped.
---
 group_quote_pdf_gen_wx.cpp  |  5 ++++-
 ledger_pdf_generator_wx.cpp |  1 +
 wx_table_generator.cpp      | 17 ++++++++++++++---
 wx_table_generator.hpp      |  1 +
 4 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index 812e73a..2d19be2 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -675,6 +675,9 @@ void group_quote_pdf_generator_wx::save(std::string const& 
output_filename)
         column_definition const& cd = column_definitions[col];
         std::string header;
         oenum_visibility visibility = oe_shown;
+        oenum_elasticity elasticity = oe_inelastic;
+        // PDF !! This doesn't fit into the switch logic below.
+        if(e_col_name == col) {elasticity = oe_elastic;}
 
         // The cast is only used to ensure that if any new elements are added
         // to the enum, the compiler would warn about their values not being
@@ -714,7 +717,7 @@ void group_quote_pdf_generator_wx::save(std::string const& 
output_filename)
                 break;
             }
 
-        vc.push_back({header, cd.widest_text_, visibility});
+        vc.push_back({header, cd.widest_text_, visibility, elasticity});
         }
 
     wx_table_generator table_gen
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 71cc32a..b9b781e 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -366,6 +366,7 @@ class using_illustration_table
                 ({i.header
                  ,i.widest_text
                  ,should_hide_column(ledger, column++) ? oe_hidden : oe_shown
+                 ,oe_inelastic
                 });
             }
         // Arguably, should_hide_column() should return an enumerator--see:
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 6212012..650b2cf 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -166,12 +166,20 @@ class wx_table_generator::column_info
         (std::string               const& header
         ,int                              width
         ,oenum_visibility          const  visibility
+        ,oenum_elasticity          const  elasticity
         )
         :col_header_       (header)
         ,col_width_        (width)
-        ,is_hidden_        (oe_hidden == visibility)
-        ,is_variable_width_(0 == width)
+        ,is_hidden_        (oe_hidden  == visibility)
+        ,is_variable_width_(oe_elastic == elasticity)
         {
+// Without the 'is_hidden_' condition, this assertion would fire.
+// But is_variable_width_ was initialized as (0 == width) before
+// this commit, so its meaning has changed. Formerly, all hidden
+// columns had is_variable_width_ set, even though their widest_text
+// was not empty, because enroll_column() sets the width of all
+// hidden columns to zero.
+LMI_ASSERT(is_hidden_ || is_variable_width_ == (0 == width));
         }
 
     bool is_hidden()         const {return  is_hidden_;}
@@ -351,7 +359,10 @@ LMI_ASSERT(w == dc_.GetMultiLineTextExtent(z.header).x);
             }
         }
 
-    all_columns_.push_back(column_info(z.header, width, z.visibility));
+    all_columns_.push_back
+        (column_info
+            (z.header, width, z.visibility, z.elasticity)
+        );
 }
 
 /// Return the font used for the headers.
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index b89ac1d..7209ed0 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -40,6 +40,7 @@ struct column_parameters
     std::string                const header;
     std::string                const widest_text;
     oenum_visibility           const visibility;
+    oenum_elasticity           const elasticity;
 };
 
 /// Specialized styles for first wx_table_generator ctor argument.



reply via email to

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