[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master eb8cff1 5/8: Generally prefer 'int' to other
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master eb8cff1 5/8: Generally prefer 'int' to other integer types |
Date: |
Mon, 6 Aug 2018 18:36:24 -0400 (EDT) |
branch: master
commit eb8cff118efb9f16e5170bd11f831accf9882cd7
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Generally prefer 'int' to other integer types
Replaced 'std::size_t' with 'int' in the private member functions of
class wx_table_generator. Eventually, it may be replaced by a class type
or a scoped enumeration in the public interface, with the noteworthy
advantage that (unlike std::size_t) such types are not implicitly
intraconvertible with 'int'.
---
wx_table_generator.cpp | 15 ++++++++-------
wx_table_generator.hpp | 6 +++---
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 3726aed..02911db 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -25,6 +25,7 @@
#include "assert_lmi.hpp"
#include "miscellany.hpp" // count_newlines(), split_into_lines()
+#include "ssize_lmi.hpp"
#include <algorithm> // max()
@@ -338,9 +339,9 @@ wxRect wx_table_generator::external_text_rect(std::size_t
column, int y) const
/// This is narrower than the full cell rectangle to leave a small
/// margin. Its vertical position is adjusted to center the text vertically.
-wxRect wx_table_generator::text_rect(std::size_t column, int y) const
+wxRect wx_table_generator::text_rect(int column, int y) const
{
- LMI_ASSERT(column <= all_columns().size());
+ LMI_ASSERT(column <= lmi::ssize(all_columns()));
wxRect z = cell_rect(column, y).Deflate(dc().GetCharWidth(), 0);
z.Offset(0, (row_height_ - char_height_)/2);
return z;
@@ -515,11 +516,11 @@ void wx_table_generator::do_output_horz_separator(int x1,
int x2, int y)
dc_.DrawLine(x1, y, x2, y);
}
-int wx_table_generator::cell_pos_x(std::size_t column) const
+int wx_table_generator::cell_pos_x(int column) const
{
- LMI_ASSERT(column <= all_columns().size());
+ LMI_ASSERT(column <= lmi::ssize(all_columns()));
int x = left_margin_;
- for(std::size_t i = 0; i < column; ++i)
+ for(int i = 0; i < column; ++i)
{
x += all_columns().at(i).col_width();
}
@@ -529,9 +530,9 @@ int wx_table_generator::cell_pos_x(std::size_t column) const
/// Rectangle corresponding to a cell.
-wxRect wx_table_generator::cell_rect(std::size_t column, int y) const
+wxRect wx_table_generator::cell_rect(int column, int y) const
{
- LMI_ASSERT(column < all_columns().size());
+ LMI_ASSERT(column < lmi::ssize(all_columns()));
return wxRect
(cell_pos_x(column)
,y
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index a5304e3..ea93e92 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -140,10 +140,10 @@ class wx_table_generator
void do_output_vert_separator(int x , int y1, int y2);
void do_output_horz_separator(int x1, int x2, int y );
- int cell_pos_x(std::size_t column) const;
+ int cell_pos_x(int column) const;
- wxRect text_rect(std::size_t column, int y) const;
- wxRect cell_rect(std::size_t column, int y) const;
+ wxRect text_rect(int column, int y) const;
+ wxRect cell_rect(int column, int y) const;
wxFont header_font() const;
- [lmi-commits] [lmi] master updated (12a9a3b -> 9b94a39), Greg Chicares, 2018/08/06
- [lmi-commits] [lmi] master 78fe48b 1/8: Assert a precondition, Greg Chicares, 2018/08/06
- [lmi-commits] [lmi] master a889ef0 2/8: Assert some preconditions, Greg Chicares, 2018/08/06
- [lmi-commits] [lmi] master 1e8b575 3/8: Use private interface in implementation, Greg Chicares, 2018/08/06
- [lmi-commits] [lmi] master eb8cff1 5/8: Generally prefer 'int' to other integer types,
Greg Chicares <=
- [lmi-commits] [lmi] master f36110a 6/8: Record visibility in various internal data structures, Greg Chicares, 2018/08/06
- [lmi-commits] [lmi] master a95ec51 4/8: Separate public and private interfaces, Greg Chicares, 2018/08/06
- [lmi-commits] [lmi] master 9b94a39 8/8: Don't pass "hidden" columns into class wx_table_generator, Greg Chicares, 2018/08/06
- [lmi-commits] [lmi] master 4cf72c4 7/8: Establish a mapping from potential to actual (non-hidden) columns, Greg Chicares, 2018/08/06