lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 2b0c1fd 6/9: Replace column_info::is_centered


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 2b0c1fd 6/9: Replace column_info::is_centered_ with is_centered()
Date: Fri, 9 Feb 2018 17:39:16 -0500 (EST)

branch: master
commit 2b0c1fd9ad19446af12750fa209a536f98b3aa1b
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Replace column_info::is_centered_ with is_centered()
    
    This is more consistent with is_hidden() and hides (without changing it
    for now) the assumption that only fixed-width columns are centered.
    
    There are still no changes in behaviour, this is a pure refactoring.
---
 wx_table_generator.cpp |  2 +-
 wx_table_generator.hpp | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 53f5047..e4e7b6e 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -295,7 +295,7 @@ void wx_table_generator::do_output_values
                 }
             else
                 {
-                if(ci.is_centered_)
+                if(ci.is_centered())
                     {
                     // Centre the text for the columns configured to do it.
                     x_text += (width - dc_.GetTextExtent(s).x) / 2;
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index e1e931e..4ef36dc 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -166,10 +166,7 @@ class wx_table_generator
         column_info(std::string const& header, int width)
             :header_(header)
             ,width_(width)
-            // Fixed width columns are centered by default, variable width ones
-            // are not as long strings look better with the default left
-            // alignment.
-            ,is_centered_(width != 0)
+            ,is_variable_width_(width == 0)
             {
             }
 
@@ -177,13 +174,24 @@ class wx_table_generator
         // doesn't appear in the output at all.
         bool is_hidden() const { return header_.empty(); }
 
+        // Return true if this column should be centered, rather than
+        // left-aligned. Notice that this is ignored for globally right-aligned
+        // tables.
+        bool is_centered() const
+        {
+            // Fixed width columns are centered by default, variable width ones
+            // are not as long strings look better with the default left
+            // alignment.
+            return !is_variable_width_;
+        }
+
         std::string const header_;
 
         // Note that this field is modified directly by wx_table_generator code
         // and hence is non-const.
         int width_;
 
-        bool const is_centered_;
+        bool const is_variable_width_;
     };
 
     std::vector<column_info> columns_;



reply via email to

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