lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 43859a6 053/156: Add support for "measure onl


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 43859a6 053/156: Add support for "measure only" output mode to wx_table_generator
Date: Tue, 30 Jan 2018 17:22:08 -0500 (EST)

branch: master
commit 43859a67a0faf24a4380eba56c5657ef9fa0bfd3
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>

    Add support for "measure only" output mode to wx_table_generator
    
    Allow using some of the methods just to compute the space needed to
    display the contents normally output by them, but without actually
    outputting it.
    
    This is useful when performing page layout calculations.
---
 wx_table_generator.cpp | 23 ++++++++++++++++++-----
 wx_table_generator.hpp | 18 ++++++++++--------
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index a62d215..5952306 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -299,8 +299,17 @@ void wx_table_generator::output_horz_separator
     (std::size_t begin_column
     ,std::size_t end_column
     ,int y
+    ,enum_output_mode output_mode
     )
 {
+    switch(output_mode)
+        {
+        case e_output_normal:
+            break;
+        case e_output_measure_only:
+            return;
+        }
+
     LMI_ASSERT(begin_column < end_column);
     LMI_ASSERT(end_column <= columns_.size());
 
@@ -317,13 +326,17 @@ void wx_table_generator::output_horz_separator
     do_output_horz_separator(x1, x2, y);
 }
 
-int wx_table_generator::get_header_height() const
+void wx_table_generator::output_header(int* pos_y, enum_output_mode 
output_mode)
 {
-    return max_header_lines_*row_height_;
-}
+    switch(output_mode)
+        {
+        case e_output_normal:
+            break;
+        case e_output_measure_only:
+            *pos_y += max_header_lines_ * row_height_;
+            return;
+        }
 
-void wx_table_generator::output_header(int* pos_y)
-{
     do_compute_column_widths_if_necessary();
 
     wxDCFontChanger set_header_font(dc_);
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index c9cbffb..cf17868 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -24,6 +24,8 @@
 
 #include "config.hpp"
 
+#include "output_mode.hpp"
+
 #include <wx/dc.h>
 #include <wx/font.h>
 
@@ -65,7 +67,10 @@ class wx_table_generator
     void add_column(std::string const& header, std::string const& widest_text);
 
     // Render the headers at the given position and update it.
-    void output_header(int* pos_y);
+    void output_header
+        (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
@@ -80,10 +85,6 @@ class wx_table_generator
         ,std::string const& value
         );
 
-    // Compute and return the height of the header without outputting it as
-    // output_header() does.
-    int get_header_height() const;
-
     // Return the height of a single table row.
     int row_height() const {return row_height_;}
 
@@ -99,9 +100,10 @@ class wx_table_generator
     // Output a horizontal separator line across the specified columns,
     // using the usual C++ close/open interval convention.
     void output_horz_separator
-        (std::size_t begin_column
-        ,std::size_t end_column
-        ,int         y
+        (std::size_t      begin_column
+        ,std::size_t      end_column
+        ,int              y
+        ,enum_output_mode output_mode = e_output_normal
         );
 
     // Output a vertical separator line before the given column. Notice that



reply via email to

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