diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2017-08-18 15:16:08 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2017-08-18 15:16:08 +0000 |
| commit | 2828cbde2c2a3dda5b2a4cc550dbf5f5ad12d8a5 (patch) | |
| tree | 70d994a89590ca741755e2a6444bcfabb125642a /src | |
| parent | 638fba602018fe815321e33fa1cd26f1395b3cca (diff) | |
Avoid #include's of unrelated system headers in Fl_Table*.H.
Possible side effect: programs that relied upon inclusion of unrelated
system headers by FL/Fl_Table.H or FL/Fl_Table_Row.H may fail to compile.
Removed include files (some only on certain platforms, list may be incomplete):
#include <FL/Fl.H> // moved to implementation (.cxx)
#include <FL/Fl_Box.H> // moved to implementation (.cxx)
#include <FL/Fl_Scrollbar.H> // moved to implementation (.cxx)
#include <sys/types.h>
#include <string.h> // memcpy
#include <malloc.h> // WINDOWS only: malloc/realloc
#include <stdlib.h> // UNIX: malloc/realloc
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12390 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Table.cxx | 39 | ||||
| -rw-r--r-- | src/Fl_Table_Row.cxx | 43 |
2 files changed, 66 insertions, 16 deletions
diff --git a/src/Fl_Table.cxx b/src/Fl_Table.cxx index a51d8d058..0dc95e135 100644 --- a/src/Fl_Table.cxx +++ b/src/Fl_Table.cxx @@ -17,13 +17,42 @@ // http://www.fltk.org/str.php // -#include <stdio.h> // fprintf -#include <FL/fl_draw.H> #include <FL/Fl_Table.H> -#if defined(USE_UTF8) && ( defined(MICROSOFT) || defined(LINUX) ) -#include <FL/fl_utf8.H> // currently only Windows and Linux -#endif +#include <FL/Fl.H> +#include <FL/fl_draw.H> + +#include <sys/types.h> +#include <string.h> // memcpy +#include <stdio.h> // fprintf + +#ifdef WIN32 +#include <malloc.h> // WINDOWS: malloc/realloc +#else /*WIN32*/ +#include <stdlib.h> // UNIX: malloc/realloc +#endif /*WIN32*/ + + +// An STL-ish vector without templates (private to Fl_Table) + +void Fl_Table::IntVector::copy(int *newarr, unsigned int newsize) { + size(newsize); + memcpy(arr, newarr, newsize * sizeof(int)); +} + +Fl_Table::IntVector::~IntVector() { // DTOR + if (arr) + free(arr); + arr = 0; +} + +void Fl_Table::IntVector::size(unsigned int count) { + if (count != _size) { + arr = (int*)realloc(arr, count * sizeof(int)); + _size = count; + } +} + /** Sets the vertical scroll position so 'row' is at the top, and causes the screen to redraw. diff --git a/src/Fl_Table_Row.cxx b/src/Fl_Table_Row.cxx index fd0e98f7d..1dc132acc 100644 --- a/src/Fl_Table_Row.cxx +++ b/src/Fl_Table_Row.cxx @@ -24,10 +24,40 @@ // o Row headings (only column headings supported currently) // -#include <stdio.h> // for debugging +#include <FL/Fl_Table_Row.H> #include <FL/Fl.H> #include <FL/fl_draw.H> -#include <FL/Fl_Table_Row.H> + +// for debugging... +// #define DEBUG 1 +#ifdef DEBUG +#include <FL/names.h> +#include <stdio.h> // fprintf() +#define PRINTEVENT \ + fprintf(stderr,"TableRow %s: ** Event: %s --\n", (label()?label():"none"), fl_eventnames[event]); +#else +#define PRINTEVENT +#endif + +// An STL-ish vector without templates (private to Fl_Table_Row) + +void Fl_Table_Row::CharVector::copy(char *newarr, int newsize) { + size(newsize); + memcpy(arr, newarr, newsize * sizeof(char)); +} + +Fl_Table_Row::CharVector::~CharVector() { // DTOR + if (arr) free(arr); + arr = 0; +} + +void Fl_Table_Row::CharVector::size(int count) { + if (count != _size) { + arr = (char*)realloc(arr, count * sizeof(char)); + _size = count; + } +} + // Is row selected? int Fl_Table_Row::row_selected(int row) { @@ -155,15 +185,6 @@ void Fl_Table_Row::rows(int val) { while ( val < (int)_rowselect.size() ) { _rowselect.pop_back(); } // shrink } -//#define DEBUG 1 -#ifdef DEBUG -#include <FL/names.h> -#define PRINTEVENT \ - fprintf(stderr,"TableRow %s: ** Event: %s --\n", (label()?label():"none"), fl_eventnames[event]); -#else -#define PRINTEVENT -#endif - // Handle events int Fl_Table_Row::handle(int event) { PRINTEVENT; |
