lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master d31fa0f 8/8: Calculate header dimensions OAOO


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d31fa0f 8/8: Calculate header dimensions OAOO
Date: Thu, 17 May 2018 19:07:10 -0400 (EDT)

branch: master
commit d31fa0f233ace47df82c82b91e3496f2de5f269b
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Calculate header dimensions OAOO
    
    GetMultiLineTextExtent() is called anyway, and it calculates both height
    and width, so it doesn't make sense to calculate height a different way.
---
 wx_table_generator.cpp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 5a4880a..5f0bdc3 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -347,13 +347,23 @@ void wx_table_generator::enroll_column
         // the number of lines used for all of them. This is one plus the 
number of
         // newlines in the anticipated case where there is no newline 
character at
         // the beginning or end of the header's string representation.
-        increase_to_if_smaller(max_header_lines_, 1u + count_newlines(header));
+        wxCoord w, h, lh;
+        dc_.GetMultiLineTextExtent(header, &w, &h, &lh, &dc_.GetFont());
+        LMI_ASSERT(0 != lh);
+        LMI_ASSERT(0 == h % lh);
+// Temporarily assert that this does the same as the code it replaced:
+LMI_ASSERT(h / lh == int(1u + count_newlines(header)));
+// Check it again because of the unfortunate mixed-mode arithmetic:
+LMI_ASSERT(std::size_t(h / lh) == 1u + count_newlines(header));
+        increase_to_if_smaller(max_header_lines_, std::size_t(h / lh));
 
         // Also increase the column width to be sufficiently wide to fit
         // this header line if it has fixed width.
         if(0 != width)
             {
-            increase_to_if_smaller(width, 
dc_.GetMultiLineTextExtent(header).x);
+// Temporarily assert that this does the same as the code it replaced:
+LMI_ASSERT(w == dc_.GetMultiLineTextExtent(header).x);
+            increase_to_if_smaller(width, w);
             width += 2 * column_margin();
             }
         }



reply via email to

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