[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master e30fcc9 01/10: Transplant code that adds bila
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master e30fcc9 01/10: Transplant code that adds bilateral column margins |
Date: |
Fri, 27 Jul 2018 17:03:53 -0400 (EDT) |
branch: master
commit e30fcc9996076118b0f4e4afcf6a00498f02171f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Transplant code that adds bilateral column margins
It's questionable whether presumptive margins should always be added
when they might soon need to be removed. Therefore, moved the code
that adds them into compute_column_widths(), where they are potentially
removed. This improves the separation of concerns and makes a planned
refactoring easier.
---
wx_table_generator.cpp | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index ffaa46d..58de18e 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -477,9 +477,6 @@ LMI_ASSERT(std::size_t(h / lh) == 1u +
count_newlines(z.header));
{
// Greater of header width and 'widest_text' width.
width = std::max(w, dc().GetTextExtent(z.widest_text).x);
- // PDF !! Reconsider whether margin should be added here,
- // because compute_column_widths() may need to remove it.
- width += 2 * column_margin();
}
break;
case oe_elastic:
@@ -515,12 +512,24 @@ LMI_ASSERT(std::size_t(h / lh) == 1u +
count_newlines(z.header));
/// quasi-global data structure mapping symbolic column names
/// to their corresponding headers and maximal widths)
/// - the header width
-/// - the bilateral margins that have already been added
+/// - PDF !! the bilateral margins added as a first step below
/// The margins may be slightly reduced by this function to make
/// everything fit when it otherwise wouldn't.
void wx_table_generator::compute_column_widths()
{
+ // PDF !! Unconditionally add bilateral margins even though they
+ // may conditionally be removed below. This is a questionable
+ // design decision; if it is later reversed, then remove the
+ // comment about it above the implementation.
+ for(auto& i : all_columns_)
+ {
+ if(!i.is_hidden() && !i.is_elastic())
+ {
+ i.col_width_ += 2 * column_margin();
+ }
+ }
+
// Number of non-hidden columns.
int number_of_columns = 0;
- [lmi-commits] [lmi] master updated (da8e769 -> caaecd8), Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master e30fcc9 01/10: Transplant code that adds bilateral column margins,
Greg Chicares <=
- [lmi-commits] [lmi] master 1430c70 03/10: Consolidate documentation, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 521d3c4 04/10: Improve documentation, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 3b4357b 05/10: Consolidate documentation, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 6d64140 02/10: Rename class wx_table_generator::column_info --> table_column_info, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master caaecd8 10/10: Fix defect introduced 20180723T1356Z: passkey not updated, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master a525e18 08/10: Reformat a block comment, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 74183c6 09/10: Augment unit test, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master f89e234 06/10: Replace a member with a free function, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master f950086 07/10: Split some code into new source files, adding an inchoate unit test, Greg Chicares, 2018/07/27