[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 0921e0c 1/5: Simplify
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 0921e0c 1/5: Simplify |
Date: |
Mon, 30 Jul 2018 07:23:15 -0400 (EDT) |
branch: master
commit 0921e0c6b6fbce3ce18129a488b852fcbae4ad95
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Simplify
Unified the logic for writing a value in a clipped column, which had
been split into two pieces, with apparently different conditions:
- indenting for a left-hand margin (iff left-aligned); and
- clipping with a right-hand margin (iff elastic).
Thus, it had been assumed that a column would be marked as left-aligned
iff it was elastic--but now the related bits of code are combined in one
place, under a single condition.
For example, with a monospace font and a one-space margin, to write the
string "ABCDEFG" in a clipped field five spaces wide:
- skip the first position (indenting one space for a left margin);
- set a clipper to truncate after the fourth position (leaving one
space as a right margin); and, therefore, in effect,
- write " ABC ".
---
wx_table_generator.cpp | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 5b7fa14..31abaf4 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -449,12 +449,7 @@ void wx_table_generator::do_output_single_row
{
case oe_left:
{
- // PDF !! 'x_text += 0;' here would parallel the other
- // cases. The implicit assumption here is that alignment
- // is oe_left iff elasticity is oe_elastic; col_width()
- // has been augmented by twice the margin for oe_inelastic
- // columns only, and this adjustment compensates for that.
- x_text += column_margin();
+ x_text += 0;
}
break;
case oe_center:
@@ -471,13 +466,9 @@ void wx_table_generator::do_output_single_row
if(ci.is_clipped())
{
- // It is assumed that the width of the "Participant" column
- // on a group quote was initially zero, and then was expanded
- // by some positive amount, and then incremented by one times
- // the margin (not two times the margin as for other columns,
- // because this column has only a left-hand unlateral margin).
- // Make sure that any failure in this chain of assumptions
- // doesn't result in (undefined) negative clipping.
+ // 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());
wxDCClipper clip
(dc_
@@ -486,7 +477,7 @@ void wx_table_generator::do_output_single_row
,wxSize{ci.col_width() - column_margin(), row_height_}
}
);
- dc_.DrawText(s, x_text, y_text);
+ dc_.DrawText(s, x_text + column_margin(), y_text);
}
else
{