[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 31048c8 047/156: Make wx_table_generator even
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 31048c8 047/156: Make wx_table_generator even more customizable |
Date: |
Tue, 30 Jan 2018 17:22:07 -0500 (EST) |
branch: master
commit 31048c877067197c3552b4a1e0b62b25688bba4f
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Make wx_table_generator even more customizable
Instead of just disabling separators, add a function for using
"condensed style" which also uses smaller row height and avoids the use
of bold font for the headers.
Finally, allow using right alignment for the table columns: this is done
in a separate function because it isn't really related to whether the
style is condensed or not.
---
wx_table_generator.cpp | 44 ++++++++++++++++++++++++++++++++++++--------
wx_table_generator.hpp | 19 ++++++++++++++++---
2 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 7c8a96f..c8a80e7 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -64,6 +64,18 @@ wx_table_generator::wx_table_generator
dc_.SetPen(pen);
}
+void wx_table_generator::use_condensed_style()
+{
+ row_height_ = char_height_;
+ draw_separators_ = false;
+ use_bold_headers_ = false;
+}
+
+void wx_table_generator::align_right()
+{
+ align_right_ = true;
+}
+
void wx_table_generator::add_column
(std::string const& header
,std::string const& widest_text
@@ -77,7 +89,11 @@ void wx_table_generator::add_column
}
else
{
- wxDCFontChanger set_header_font(dc_, get_header_font());
+ wxDCFontChanger set_header_font(dc_);
+ if(use_bold_headers_)
+ {
+ set_header_font.Set(get_header_font());
+ }
// Set width to the special value of 0 for the variable width columns.
width = widest_text.empty() ? 0 : dc_.GetTextExtent(widest_text).x;
@@ -236,16 +252,24 @@ void wx_table_generator::do_output_values
if(!s.empty())
{
int x_text = x;
- if(ci.is_centered_)
+
+ if(align_right_)
{
- // Centre the text for the columns configured to do it.
- x_text += (width - dc_.GetTextExtent(s).x) / 2;
+ x_text += width - dc_.GetTextExtent(s).x;
}
else
{
- // Otherwise just offset it by ~1 em.
- x_text += dc_.GetTextExtent("M").x;
- }
+ if(ci.is_centered_)
+ {
+ // Centre the text for the columns configured to do it.
+ x_text += (width - dc_.GetTextExtent(s).x) / 2;
+ }
+ else
+ {
+ // Otherwise just offset it by ~1 em.
+ x_text += dc_.GetTextExtent("M").x;
+ }
+ }
dc_.DrawText(s, x_text, y_text);
}
@@ -297,7 +321,11 @@ void wx_table_generator::output_header(int* pos_y)
{
do_compute_column_widths_if_necessary();
- wxDCFontChanger set_header_font(dc_, get_header_font());
+ wxDCFontChanger set_header_font(dc_);
+ if(use_bold_headers_)
+ {
+ set_header_font.Set(get_header_font());
+ }
// Split headers in single lines and fill up the entire columns*lines 2D
// matrix, using empty strings for the headers with less than the maximal
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index 88b2633..e1da312 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -105,8 +105,14 @@ class wx_table_generator
// output a separator after the last column.
void output_vert_separator(std::size_t before_column, int y);
- // Disable separator lines drawn by default.
- void disable_separators() {draw_separators_ = false;}
+ // Use condensed style: don't draw separators between rows and make them
+ // smaller.
+ void use_condensed_style();
+
+ // By default, columns are centered if they have fixed size or left-aligned
+ // otherwise. By calling this method, this alignment auto-detection is
+ // turned off and all columns are right-aligned.
+ void align_right();
private:
// Return the font used for the headers.
@@ -132,7 +138,7 @@ class wx_table_generator
// These values could be recomputed, but cache them for performance.
int const char_height_;
- int const row_height_;
+ int row_height_;
struct column_info
{
@@ -169,6 +175,13 @@ class wx_table_generator
// drawn by calling output_horz_separator() or output_vert_separator()
// explicitly).
bool draw_separators_ = true;
+
+ // If true, headers are drawn in bold.
+ bool use_bold_headers_ = true;
+
+ // If true, force right alignment for all columns instead of centering them
+ // automatically if they have fixed size.
+ bool align_right_ = false;
};
#endif // wx_table_generator_hpp
- [lmi-commits] [lmi] master b72ced6 014/156: Replace ad hoc illustration properties with HTML interpolator, (continued)
- [lmi-commits] [lmi] master b72ced6 014/156: Replace ad hoc illustration properties with HTML interpolator, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e7d763d 066/156: Add company logo display to the PDF illustration header, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f575c94 003/156: Refactor more group_quote_pdf_gen_wx code to allow its reuse, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 5e2fc70 007/156: Make HTML generation utilities more type-safe, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7ed2bbf 027/156: Simplify footer generation code by moving font tag outside, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d7244c1 043/156: Change the colour used for lines and borders, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 41ae40d 089/156: Fix wrong "<br>" tag in the header template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master acb7aae 049/156: Add numbered_page::get_extra_pages_needed() hook, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c0d68e1 122/156: Add rate of return pages of the individual placement illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 875ca7d 039/156: Rename StateIsTX ledger variable to StateIsTexas, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 31048c8 047/156: Make wx_table_generator even more customizable,
Greg Chicares <=
- [lmi-commits] [lmi] master 10dd0a9 051/156: Factor enum_output_mode into a separate header to allow its reuse, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 8fa972e 052/156: Add "Tabular Detail, continued" page to the PDF illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ca6e17c 031/156: Add function generating a standard header and use it, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c378bc5 064/156: Remove unnecessary value_cast inclusion, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 41de2e2 140/156: Add helper expand_template() method, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 3e8e257 017/156: Add pdf_illustration_regular and narrative_summary_page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 614fb47 135/156: Add supplemental reports pages to private placement illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 49cc809 072/156: Remove HTML construction helpers not needed any more, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master efc01fa 046/156: Allow disabling separator lines in wx_table_generator, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e20544f 018/156: Add check for the ledger type, Greg Chicares, 2018/01/30