lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 3cf5a1c 056/156: Add wx_table_generator::outp


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 3cf5a1c 056/156: Add wx_table_generator::output_super_header()
Date: Tue, 30 Jan 2018 17:22:09 -0500 (EST)

branch: master
commit 3cf5a1cdb0f06d94ed6e2ac5fe36d38cb46ce22e
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>

    Add wx_table_generator::output_super_header()
    
    Add support for super headers spanning several columns in addition to
    the normal per-column headers.
---
 wx_table_generator.cpp | 29 +++++++++++++++++++++++++++++
 wx_table_generator.hpp | 10 ++++++++++
 2 files changed, 39 insertions(+)

diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 5952306..5720f5d 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -388,6 +388,35 @@ void wx_table_generator::output_header(int* pos_y, 
enum_output_mode output_mode)
         }
 }
 
+void wx_table_generator::output_super_header
+        (std::string const& header
+        ,std::size_t        begin_column
+        ,std::size_t        end_column
+        ,int*               pos_y
+        ,enum_output_mode   output_mode
+        )
+{
+    switch(output_mode)
+        {
+        case e_output_normal:
+            break;
+        case e_output_measure_only:
+            *pos_y += row_height_;
+            return;
+        }
+
+    // We don't have a function for getting the rectangle of a span of columns,
+    // but we can reuse the existing text_rect() if we just increase its width
+    // by the width of all the extra (i.e. not counting the starting one)
+    // columns in this span.
+    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);
+
+    *pos_y += row_height_;
+}
+
 void wx_table_generator::output_row
     (int* pos_y
     ,std::string const* values
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index cf17868..a71717c 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -72,6 +72,16 @@ class wx_table_generator
         ,enum_output_mode output_mode = e_output_normal
         );
 
+    // 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++.
+    void output_super_header
+        (std::string const& header
+        ,std::size_t        begin_column
+        ,std::size_t        end_column
+        ,int*               pos_y
+        ,enum_output_mode   output_mode = e_output_normal
+        );
+
     // Render a row with the given values at the given position and update it.
     // The values here can be single-line only and there must be exactly the
     // same number of them as the number of columns.



reply via email to

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