[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_;
- [lmi-commits] [lmi] master updated (246f754 -> 76bcb28), Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 2c2145d 3/9: Fix closing brace indentation in wx_table_generator.cpp, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 4b75c18 5/9: Add a comment explaining why column_info::width_ is not const, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 11da7b5 1/9: Extract get_needed_pages_count() from PDF generation code, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 58c87b5 7/9: Make column_info::is_variable_width_ field private, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 76bcb28 9/9: Avoid passing an enum by const value, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master ce0f83e 8/9: Clip variable-width columns in wx_table_generator, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 8c1e124 2/9: Add simple unit test for get_needed_pages_count(), Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 79144a7 4/9: Make unchangeable wx_table_generator::column_info fields const, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 2b0c1fd 6/9: Replace column_info::is_centered_ with is_centered(),
Greg Chicares <=