Make some methods of Fl_Tabs protected and/or virtual (STR #3211).

Patch proposed by Teklad (STR #3211, file #7):
  http://www.fltk.org/strfiles/3211/Fl_Tabs.H.patch
with minor modifications and adjustments for FLTK 1.4.0.

Method which() is now also virtual, as suggested by guyben in comment #24.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12243 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2017-05-22 14:34:38 +00:00
parent 0489d79085
commit c364bb73f6
2 changed files with 25 additions and 10 deletions

View File

@ -48,6 +48,9 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2017
Other Improvements
- (add new items here)
- Some methods of Fl_Tabs are now virtual and/or protected for easier
subclassing without code duplication (STR #3211 and others).
To be continued...
- Separated Fl_Input_Choice.H and Fl_Input_Choice.cxx (STR #2750, #2752).
- Separated Fl_Spinner.H and Fl_Spinner.cxx (STR #2776).
- New method Fl_Spinner::wrap(int) allows to set wrap mode at bounds if

View File

@ -3,7 +3,7 @@
//
// Tab header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2010 by Bill Spitzak and others.
// Copyright 1998-2017 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
@ -199,20 +199,29 @@
such as using the arrow keys while at the left or right end of the tabs.
*/
class FL_EXPORT Fl_Tabs : public Fl_Group {
Fl_Widget *push_;
protected:
int *tab_pos; // array of x-offsets of tabs per child + 1
int *tab_width; // array of widths of tabs per child + 1
int tab_count; // array size
int tab_positions(); // allocate and calculate tab positions
void clear_tab_positions();
int tab_height();
void draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int sel=0);
protected:
Fl_Align tab_align_; // tab label alignment
void redraw_tabs();
virtual void redraw_tabs();
virtual int tab_positions(); // allocate and calculate tab positions
virtual void clear_tab_positions();
virtual void draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int sel=0);
virtual int tab_height();
void draw();
public:
Fl_Tabs(int,int,int,int,const char * = 0);
virtual ~Fl_Tabs();
int handle(int);
Fl_Widget *value();
int value(Fl_Widget *);
@ -228,10 +237,13 @@ public:
*/
Fl_Widget *push() const {return push_;}
int push(Fl_Widget *);
Fl_Tabs(int,int,int,int,const char * = 0);
Fl_Widget *which(int event_x, int event_y);
~Fl_Tabs();
// Returns the widget of the tab the user clicked on at event_x/event_y.
virtual Fl_Widget *which(int event_x, int event_y);
// Returns the position and size available to be used by its children.
void client_area(int &rx, int &ry, int &rw, int &rh, int tabh=0);
/**
Sets the tab label alignment.