lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 449e56f 3/5: Always use default (1em) margins


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 449e56f 3/5: Always use default (1em) margins for clipped columns
Date: Mon, 30 Jul 2018 07:23:16 -0400 (EDT)

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

    Always use default (1em) margins for clipped columns
    
    In practice, these margins are always one em in production, and there
    is no need for the code to do anything more complex.
---
 wx_table_generator.cpp | 16 +++++++++-------
 wx_table_generator.hpp |  1 +
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 31abaf4..e00e8c7 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -44,7 +44,8 @@ wx_table_generator::wx_table_generator
     ,char_height_      (dc_.GetCharHeight())
     // Arbitrarily use 1.333 line spacing.
     ,row_height_       ((4 * char_height_ + 2) / 3)
-    ,column_margin_    (dc_.GetTextExtent("M").x)
+    ,one_em_           (dc_.GetTextExtent("M").x)
+    ,column_margin_    (one_em_)
     ,max_header_lines_ (1)
     ,draw_separators_  (true)
     ,use_bold_headers_ (true)
@@ -74,7 +75,8 @@ wx_table_generator::wx_table_generator
     ,total_width_      (total_width)
     ,char_height_      (dc_.GetCharHeight())
     ,row_height_       (char_height_)
-    ,column_margin_    (dc_.GetTextExtent("M").x)
+    ,one_em_           (dc_.GetTextExtent("M").x)
+    ,column_margin_    (one_em_)
     ,max_header_lines_ (1)
     ,draw_separators_  (false)
     ,use_bold_headers_ (false)
@@ -467,17 +469,17 @@ void wx_table_generator::do_output_single_row
             if(ci.is_clipped())
                 {
                 // Write clipped text with bilateral column margins:
-                //  - aligned left, indented for a left margin; and
-                //  - clipped on the right to width minus margin.
-                LMI_ASSERT(0 <= ci.col_width() - column_margin());
+                //  - aligned left, indented 1em for a left margin; and
+                //  - clipped on the right to width minus a 1em margin.
+                LMI_ASSERT(0 <= ci.col_width() - one_em_);
                 wxDCClipper clip
                     (dc_
                     ,wxRect
                         {wxPoint{pos_x, y_top}
-                        ,wxSize{ci.col_width() - column_margin(), row_height_}
+                        ,wxSize{ci.col_width() - one_em_, row_height_}
                         }
                     );
-                dc_.DrawText(s, x_text + column_margin(), y_text);
+                dc_.DrawText(s, x_text + one_em_, y_text);
                 }
             else
                 {
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index 9d0046d..84d7f21 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -157,6 +157,7 @@ class wx_table_generator
     // These values could be recomputed, but cache them for performance.
     int const char_height_;
     int const row_height_;
+    int const one_em_;
     int column_margin_;
 
     std::vector<table_column_info> all_columns_;



reply via email to

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