[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [6587] Refactor: add wx_table_generator::text_rect() helpe
From: |
gchicares |
Subject: |
[lmi-commits] [6587] Refactor: add wx_table_generator::text_rect() helper (VZ) |
Date: |
Fri, 13 May 2016 13:59:23 +0000 (UTC) |
Revision: 6587
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6587
Author: chicares
Date: 2016-05-13 13:59:23 +0000 (Fri, 13 May 2016)
Log Message:
-----------
Refactor: add wx_table_generator::text_rect() helper (VZ)
Modified Paths:
--------------
lmi/trunk/group_quote_pdf_gen_wx.cpp
lmi/trunk/wx_table_generator.cpp
lmi/trunk/wx_table_generator.hpp
Modified: lmi/trunk/group_quote_pdf_gen_wx.cpp
===================================================================
--- lmi/trunk/group_quote_pdf_gen_wx.cpp 2016-05-13 13:56:15 UTC (rev
6586)
+++ lmi/trunk/group_quote_pdf_gen_wx.cpp 2016-05-13 13:59:23 UTC (rev
6587)
@@ -1324,14 +1324,11 @@
table_gen.output_vert_separator(e_col_number, y);
- int const cell_margin_x = pdf_dc.GetCharWidth();
- int const y_text = y + pdf_dc.GetCharHeight();
-
// Render "Census" in bold.
wxDCFontChanger set_bold_font(pdf_dc, pdf_dc.GetFont().Bold());
pdf_dc.DrawLabel
("Census"
- ,table_gen.cell_rect(e_col_name, y_text).Deflate(cell_margin_x, 0)
+ ,table_gen.text_rect(e_col_name, y)
,wxALIGN_LEFT
);
@@ -1343,7 +1340,7 @@
LMI_ASSERT(0 < e_first_totalled_column);
pdf_dc.DrawLabel
("Totals:"
- ,table_gen.cell_rect(e_first_totalled_column - 1,
y_text).Deflate(cell_margin_x, 0)
+ ,table_gen.text_rect(e_first_totalled_column - 1, y)
,wxALIGN_RIGHT
);
Modified: lmi/trunk/wx_table_generator.cpp
===================================================================
--- lmi/trunk/wx_table_generator.cpp 2016-05-13 13:56:15 UTC (rev 6586)
+++ lmi/trunk/wx_table_generator.cpp 2016-05-13 13:59:23 UTC (rev 6587)
@@ -148,6 +148,13 @@
return wxRect(x, y, columns_.at(column).width_, row_height_);
}
+wxRect wx_table_generator::text_rect(std::size_t column, int y)
+{
+ wxRect text_rect = cell_rect(column, y).Deflate(dc_.GetCharWidth(), 0);
+ text_rect.Offset(0, char_height_);
+ return text_rect;
+}
+
void wx_table_generator::do_compute_column_widths_if_necessary()
{
if(has_column_widths_)
@@ -356,26 +363,15 @@
return;
}
- wxRect const total_rect = cell_rect(column, y);
{
wxDCPenChanger set_transparent_pen(dc_, *wxTRANSPARENT_PEN);
wxDCBrushChanger set_grey_brush(dc_, *wxLIGHT_GREY_BRUSH);
- dc_.DrawRectangle(total_rect);
+ dc_.DrawRectangle(cell_rect(column, y));
}
- wxRect text_rect = total_rect.Deflate(dc_.GetCharWidth(), 0);
- text_rect.Offset(0, char_height_);
+ wxRect const r = text_rect(column, y);
+ dc_.DrawLabel(lhs, r, wxALIGN_LEFT);
+ dc_.DrawLabel(rhs, r, wxALIGN_RIGHT);
- dc_.DrawLabel
- (lhs
- ,text_rect
- ,wxALIGN_LEFT
- );
- dc_.DrawLabel
- (rhs
- ,text_rect
- ,wxALIGN_RIGHT
- );
-
output_vert_separator(column, y);
}
Modified: lmi/trunk/wx_table_generator.hpp
===================================================================
--- lmi/trunk/wx_table_generator.hpp 2016-05-13 13:56:15 UTC (rev 6586)
+++ lmi/trunk/wx_table_generator.hpp 2016-05-13 13:59:23 UTC (rev 6587)
@@ -90,6 +90,12 @@
// Return the rectangle containing the cell area.
wxRect cell_rect(std::size_t column, int y);
+ // Return the rectangle adjusted for the text contents of the cell: it is
+ // more narrow than the full cell rectangle to leave margins around the
+ // text and its vertical position is adjusted so that it can be directly
+ // passed to wxDC::DrawLabel().
+ wxRect text_rect(std::size_t column, int y);
+
// Output a horizontal separator line across the specified columns,
// using the usual C++ close/open interval convention.
void output_horz_separator
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [6587] Refactor: add wx_table_generator::text_rect() helper (VZ),
gchicares <=