lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 89b4674 120/156: Add automatic support for mu


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 89b4674 120/156: Add automatic support for multiline super-headers
Date: Tue, 30 Jan 2018 17:22:27 -0500 (EST)

branch: master
commit 89b467466ea31475e694e6d10525d3257749209e
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>

    Add automatic support for multiline super-headers
    
    Handle line feeds in wx_table_generator::output_super_header() as
    expected.
    
    This makes it unnecessary to do it manually in the illustration
    generation code.
---
 ledger_pdf_generator_wx.cpp | 23 ++++++++++-------------
 wx_table_generator.cpp      | 12 +++++++++---
 wx_table_generator.hpp      |  1 +
 3 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index ba0dd6e..bc98f9b 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -37,7 +37,7 @@
 #include "ledger_evaluator.hpp"
 #include "ledger_invariant.hpp"
 #include "ledger_variant.hpp"
-#include "miscellany.hpp"               // lmi_tolower(), split_into_lines()
+#include "miscellany.hpp"               // lmi_tolower()
 #include "pdf_writer_wx.hpp"
 #include "version.hpp"
 #include "wx_table_generator.hpp"
@@ -2082,19 +2082,16 @@ class page_with_basic_tabular_report : public 
page_with_tabular_report
                     ;
 
 
-                auto const header_lines = split_into_lines
-                    (get_two_column_header(suffix_full, suffix_short)
+                auto const header =
+                    get_two_column_header(suffix_full, suffix_short)
+                    ;
+                table.output_super_header
+                    (interpolate_html(header).as_html()
+                    ,begin_column
+                    ,end_column
+                    ,&y
+                    ,output_mode
                     );
-                for(auto const& line : header_lines)
-                    {
-                    table.output_super_header
-                        (interpolate_html(line).as_html()
-                        ,begin_column
-                        ,end_column
-                        ,&y
-                        ,output_mode
-                        );
-                    }
 
                 y += table.get_separator_line_height();
                 table.output_horz_separator
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 078c4be..79d57f3 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -431,12 +431,14 @@ void wx_table_generator::output_super_header
         ,enum_output_mode   output_mode
         )
 {
+    std::vector<std::string> const lines(split_into_lines(header));
+
     switch(output_mode)
         {
         case e_output_normal:
             break;
         case e_output_measure_only:
-            *pos_y += row_height_;
+            *pos_y += row_height_*lines.size();
             return;
         }
 
@@ -447,9 +449,13 @@ void wx_table_generator::output_super_header
     auto rect = text_rect(begin_column, *pos_y);
     rect.width += do_get_cell_x(end_column) - do_get_cell_x(begin_column + 1);
 
-    dc_.DrawLabel(header, rect, wxALIGN_CENTER_HORIZONTAL);
+    for(auto const& line : lines)
+        {
+        dc_.DrawLabel(line, rect, wxALIGN_CENTER_HORIZONTAL);
 
-    *pos_y += row_height_;
+        rect.y += row_height_;
+        *pos_y += row_height_;
+        }
 }
 
 void wx_table_generator::output_row
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index 5b9b19b..1ba0e58 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -74,6 +74,7 @@ class wx_table_generator
 
     // Render a super-header, i.e. a header spanning over several columns. The
     // columns range is specified as a close/open interval, as usual in C++.
+    // The header string may be multiline, just as with normal headers.
     void output_super_header
         (std::string const& header
         ,std::size_t        begin_column



reply via email to

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