lmi-commits
[Top][All Lists]
Advanced

[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;
 



reply via email to

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