From 1209e9dcd7e1e97bedc747d06ba4eea837562158 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sun, 22 Oct 2023 19:30:37 +0200 Subject: Make Fl_String and Fl_Int_Vector private (#789) - add CMake option 'OPTION_USE_STD' - add configure option '--enable-use_std' - move FL/Fl_String.H to src/Fl_String.H - move FL/Fl_Int_Vector.H to src/Fl_Int_Vector.H - remove Fl_String from demo program examples/callbacks.cxx - remove Fl_Int_Vector from public header FL/Fl_Table.H - some methods of Fl_Table are no longer inline - add CMake option OPTION_USE_STD to allow std::string in some selected functions and methods Experimental, may be removed before release: - use either Fl_Int_Vector or std::vector in Fl_Table depending on CMake OPTION_USE_STD or configure --enable-use_std Move all fl_filename* functions that use Fl_String to fluid Main changes in fluid: - add fluid_filename.h and .cxx - include "fluid_filename.h" rather than Update fl_input(), fl_password() and test/ask - add maxchar parameter to fl_input() and fl_password() - fl_input_str() and fl_password_str() are optional and return std::string if enabled (FLTK_USE_STD) --- FL/Fl_Table.H | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'FL/Fl_Table.H') diff --git a/FL/Fl_Table.H b/FL/Fl_Table.H index 9f31fa020..1adc29255 100644 --- a/FL/Fl_Table.H +++ b/FL/Fl_Table.H @@ -3,6 +3,7 @@ // // Copyright 2002 by Greg Ercolano. // Copyright (c) 2004 O'ksi'D +// Copyright 2023 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -20,7 +21,18 @@ #include #include -#include + +// EXPERIMENTAL +// We use either std::vector or the private class Fl_Int_Vector +// depending on the build option OPTION_USE_STD or --enable-use_std. +// This option allows to use std::string and std::vector in FLTK 1.4.x + +#if (FLTK_USE_STD) +#include +typedef std::vector Fl_Int_Vector; +#else +class Fl_Int_Vector; // private class declared in src/Fl_Int_Vector.H +#endif /** A table of widgets or other content. @@ -155,8 +167,12 @@ private: }; unsigned int flags_; - Fl_Int_Vector _colwidths; // column widths in pixels - Fl_Int_Vector _rowheights; // row heights in pixels + Fl_Int_Vector *_colwidths; // column widths in pixels + Fl_Int_Vector *_rowheights; // row heights in pixels + + // number of columns and rows == size of corresponding vectors + int col_size(); // size of the column widths vector + int row_size(); // size of the row heights vector Fl_Cursor _last_cursor; // last mouse cursor before changed to 'resize' cursor @@ -433,7 +449,7 @@ public: return(table->box()); } - virtual void rows(int val); // set/get number of rows + virtual void rows(int val); // set number of rows /** Returns the number of rows in the table. @@ -442,7 +458,7 @@ public: return(_rows); } - virtual void cols(int val); // set/get number of columns + virtual void cols(int val); // set number of columns /** Get the number of columns in the table. @@ -656,23 +672,15 @@ public: return(_col_header_color); } - void row_height(int row, int height); // set/get row height + void row_height(int row, int height); // set row height in pixels - /** - Returns the current height of the specified row as a value in pixels. - */ - inline int row_height(int row) { - return((row<0 || row>=(int)_rowheights.size()) ? 0 : _rowheights[row]); - } + // Returns the current height of the specified row as a value in pixels. + int row_height(int row); - void col_width(int col, int width); // set/get a column's width + void col_width(int col, int width); // set a column's width in pixels - /** - Returns the current width of the specified column in pixels. - */ - inline int col_width(int col) { - return((col<0 || col>=(int)_colwidths.size()) ? 0 : _colwidths[col]); - } + // Returns the current width of the specified column in pixels. + int col_width(int col); /** Convenience method to set the height of all rows to the -- cgit v1.2.3