[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();
}
}
- [lmi-commits] [lmi] master updated (a738b9f -> d31fa0f), Greg Chicares, 2018/05/17
- [lmi-commits] [lmi] master 2fd74af 3/8: Generalize class wx_table_generator, Greg Chicares, 2018/05/17
- [lmi-commits] [lmi] master 02b3f47 4/8: Generalize class wx_table_generator: pen variations, Greg Chicares, 2018/05/17
- [lmi-commits] [lmi] master d31fa0f 8/8: Calculate header dimensions OAOO,
Greg Chicares <=
- [lmi-commits] [lmi] master 6d8e0ea 1/8: Move most members from derived to base class, Greg Chicares, 2018/05/17
- [lmi-commits] [lmi] master 5ad29f9 6/8: Generalize class wx_table_generator more robustly, Greg Chicares, 2018/05/17
- [lmi-commits] [lmi] master 8d75fd0 2/8: Eradicate unneeded class illustration_table_generator, Greg Chicares, 2018/05/17
- [lmi-commits] [lmi] master 3c9cc09 5/8: Generalize class wx_table_generator: row height and boolean flags, Greg Chicares, 2018/05/17
- [lmi-commits] [lmi] master d270b21 7/8: Generally avoid regex /, $/, Greg Chicares, 2018/05/17