[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master c902746 1/6: Add and use is_variable_width()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master c902746 1/6: Add and use is_variable_width() const accessor |
Date: |
Sun, 22 Apr 2018 14:56:58 -0400 (EDT) |
branch: master
commit c902746128ef0ed862df4e0fdb23c40392e7cc7b
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Add and use is_variable_width() const accessor
See:
https://lists.nongnu.org/archive/html/lmi/2018-04/msg00089.html
---
wx_table_generator.cpp | 22 ++++++----------------
wx_table_generator.hpp | 5 +++++
2 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 845bc04..27839e7 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -208,12 +208,7 @@ void wx_table_generator::do_compute_column_widths()
// Number of non-hidden columns.
int num_columns = 0;
- // Number of non-hidden columns whose width at this moment is
- // zero. That's not the same as counting columns for which
- // is_variable_width_ is true, which means their width was zero
- // at the moment of construction. At the present moment, each
- // column's width is at least its header width (plus margins),
- // so can the number of columns in this category ever be nonzero?
+ // Number of non-hidden columns with variable width.
//
// In practice, only the "Participant" column on group quotes has
// this property.
@@ -232,8 +227,7 @@ void wx_table_generator::do_compute_column_widths()
// Total width of all non-hidden columns, reflecting header width
// and the "999,999" mask for column contents, and including the
// margins that have already been added in (but may be removed
- // later). "Variable-width" columns are apparently excluded--or
- // maybe not?
+ // later).
int total_fixed = 0;
for(auto const& i : columns_)
@@ -247,16 +241,12 @@ void wx_table_generator::do_compute_column_widths()
num_columns++;
- if(0 == i.width_)
+ if(i.is_variable_width())
{
num_expand++;
}
-// It seems odd to put this in an 'else' clause--to save the work of
-// adding zero, even though that would do nothing? Or should the
-// 'if' condition actually be
-// if(i.is_variable_width_)
-// ? IOW, if the collection includes one "variable-width" column,
-// should that column's header width be counted here, or excluded?
+// If the collection includes one "variable-width" column, should
+// that column's header width be counted here, or excluded?
else
{
total_fixed += i.width_;
@@ -390,7 +380,7 @@ void wx_table_generator::do_compute_column_widths()
continue;
}
- if(0 == i.width_)
+ if(i.is_variable_width())
{
i.width_ = per_expand;
}
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index 5c0b52b..d63bdb2 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -323,6 +323,11 @@ class wx_table_generator
return !is_variable_width_;
}
+ bool is_variable_width() const
+ {
+ return is_variable_width_;
+ }
+
// Return true if the contents of this column needs to be clipped when
// outputting it.
bool needs_clipping() const
- [lmi-commits] [lmi] master updated (132fcb2 -> 7146202), Greg Chicares, 2018/04/22
- [lmi-commits] [lmi] master fffcb59 2/6: Consolidate documentation, Greg Chicares, 2018/04/22
- [lmi-commits] [lmi] master 7146202 6/6: Explain the connection between "variable" and "expand", Greg Chicares, 2018/04/22
- [lmi-commits] [lmi] master da9e57d 4/6: Improve documentation, resolving a question or two, Greg Chicares, 2018/04/22
- [lmi-commits] [lmi] master 5c0c360 5/6: Resolve several questions, Greg Chicares, 2018/04/22
- [lmi-commits] [lmi] master c902746 1/6: Add and use is_variable_width() const accessor,
Greg Chicares <=
- [lmi-commits] [lmi] master 24dacaa 3/6: Consolidate 'total_width_' commentary, Greg Chicares, 2018/04/22