From 6ba7b49baf11e526d1ed19aef491db2cd120e55e Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 16 Oct 2023 10:53:18 +0200 Subject: Improve subclassing cababilities of Fl_Tile (STR 2791) - remove static variables and functions - make move_intersection() virtual - add (protected) cursor access methods These changes were inspired by STR 2791 where the user proposing an enhancement was not able to subclass Fl_Tile properly. This commit fixes the mentioned issues and enables subclassing without copying internal code. --- FL/Fl_Tile.H | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'FL') diff --git a/FL/Fl_Tile.H b/FL/Fl_Tile.H index af104a4eb..a7de02fea 100644 --- a/FL/Fl_Tile.H +++ b/FL/Fl_Tile.H @@ -1,7 +1,7 @@ // // Tile header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-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 @@ -29,10 +29,24 @@ public: int handle(int event) FL_OVERRIDE; Fl_Tile(int X, int Y, int W, int H, const char *L=0); void resize(int X, int Y, int W, int H) FL_OVERRIDE; - void move_intersection(int oldx, int oldy, int newx, int newy); + virtual void move_intersection(int oldx, int oldy, int newx, int newy); FL_DEPRECATED("in 1.4.0 - use move_intersection(p) instead", - void position(int oldx, int oldy, int newx, int newy)) { return move_intersection(oldx, oldy, newx, newy); } + void position(int oldx, int oldy, int newx, int newy)) { move_intersection(oldx, oldy, newx, newy); } void position(int x, int y) { Fl_Group::position(x, y); } + +protected: + int cursor_; ///< current cursor index (0..3) + Fl_Cursor *cursors_; ///< points at the array of 4 cursors (may be overridden) + + /** Returns the cursor for cursor index n. + \see Fl_Tile::set_cursor(int) + */ + + Fl_Cursor cursor(int n) { + return cursors_[n]; + } + + void set_cursor(int n); // set one of n (0..3) cursors }; #endif -- cgit v1.2.3