FLTK 1.4.0
Fl_Scroll.H
1 //
2 // Scroll header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2021 by Bill Spitzak and others.
5 //
6 // This library is free software. Distribution and use rights are outlined in
7 // the file "COPYING" which should have been included with this file. If this
8 // file is missing or damaged, see the license at:
9 //
10 // https://www.fltk.org/COPYING.php
11 //
12 // Please see the following page on how to report bugs and issues:
13 //
14 // https://www.fltk.org/bugs.php
15 //
16 
17 /* \file
18  Fl_Scroll widget . */
19 
20 #ifndef Fl_Scroll_H
21 #define Fl_Scroll_H
22 
23 #include "Fl_Group.H"
24 #include "Fl_Scrollbar.H"
25 
98 class FL_EXPORT Fl_Scroll : public Fl_Group {
99 
100  int xposition_, yposition_;
101  int oldx, oldy;
102  int scrollbar_size_;
103  static void hscrollbar_cb(Fl_Widget*, void*);
104  static void scrollbar_cb(Fl_Widget*, void*);
105  static void draw_clip(void*,int,int,int,int);
106 
107 protected: // (STR#1895)
108 
110  typedef struct { int x,y,w,h; } Fl_Region_XYWH;
111 
113  typedef struct {
114  int l;
115  int r;
116  int t;
117  int b;
118  } Fl_Region_LRTB;
119 
121  typedef struct {
122  int x,y,w,h;
123  int pos;
124  int size;
125  int first;
126  int total;
128 
135  typedef struct {
140  int hneeded;
141  int vneeded;
144  } ScrollInfo;
145  void recalc_scrollbars(ScrollInfo &si) const;
146 
147 protected:
148 
149  void fix_scrollbar_order();
150  void bbox(int&,int&,int&,int&) const;
151  void draw();
152 
153 public:
154 
155  Fl_Scrollbar scrollbar;
156  Fl_Scrollbar hscrollbar;
157 
158  void resize(int X, int Y, int W, int H);
159  int handle(int);
160 
161  Fl_Scroll(int X,int Y,int W,int H,const char*l=0);
162 
163  enum { // values for type()
164  HORIZONTAL = 1,
165  VERTICAL = 2,
166  BOTH = 3,
167  ALWAYS_ON = 4,
168  HORIZONTAL_ALWAYS = 5,
169  VERTICAL_ALWAYS = 6,
170  BOTH_ALWAYS = 7
171  };
172 
174  int xposition() const {return xposition_;}
176  int yposition() const {return yposition_;}
177  void scroll_to(int, int);
178  void clear();
179 
180  /* delete child n (by index) */
181  virtual int delete_child(int n);
182 
192  int scrollbar_size() const {
193  return(scrollbar_size_);
194  }
214  void scrollbar_size(int newSize) {
215  if ( newSize != scrollbar_size_ ) redraw();
216  scrollbar_size_ = newSize;
217  }
218 };
219 
220 #endif
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:42
int handle(int)
Handles the specified event.
Definition: Fl_Group.cxx:145
void draw()
Draws the widget.
Definition: Fl_Group.cxx:840
virtual int delete_child(int n)
Removes the widget at index from the group and deletes it.
Definition: Fl_Group.cxx:577
void resize(int, int, int, int)
Resizes the Fl_Group widget and all of its children.
Definition: Fl_Group.cxx:737
void clear()
Deletes all child widgets from memory recursively.
Definition: Fl_Group.cxx:379
This container widget lets you maneuver around a set of widgets much larger than your window.
Definition: Fl_Scroll.H:98
int yposition() const
Gets the current vertical scrolling position.
Definition: Fl_Scroll.H:176
void scrollbar_size(int newSize)
Sets the pixel size of the scrollbars' troughs to newSize, in pixels.
Definition: Fl_Scroll.H:214
int xposition() const
Gets the current horizontal scrolling position.
Definition: Fl_Scroll.H:174
int scrollbar_size() const
Gets the current size of the scrollbars' troughs, in pixels.
Definition: Fl_Scroll.H:192
The Fl_Scrollbar widget displays a slider with arrow buttons at the ends of the scrollbar.
Definition: Fl_Scrollbar.H:41
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
int y() const
Gets the widget position in its window.
Definition: Fl_Widget.H:295
int h() const
Gets the widget height.
Definition: Fl_Widget.H:305
int w() const
Gets the widget width.
Definition: Fl_Widget.H:300
void redraw()
Schedules the drawing of the widget.
Definition: Fl.cxx:1430
int x() const
Gets the widget position in its window.
Definition: Fl_Widget.H:290
A local struct to manage a region defined by left/right/top/bottom.
Definition: Fl_Scroll.H:113
int r
(r)ight "x" position, aka x2
Definition: Fl_Scroll.H:115
int b
(b)ottom "y" position, aka y2
Definition: Fl_Scroll.H:117
int l
(l)eft "x" position, aka x1
Definition: Fl_Scroll.H:114
int t
(t)op "y" position, aka y1
Definition: Fl_Scroll.H:116
A local struct to manage a region defined by xywh.
Definition: Fl_Scroll.H:110
A local struct to manage a scrollbar's xywh region and tab values.
Definition: Fl_Scroll.H:121
int pos
scrollbar tab's "position of first line displayed"
Definition: Fl_Scroll.H:123
int total
scrollbar tab's "total number of lines"
Definition: Fl_Scroll.H:126
int size
scrollbar tab's "size of window in lines"
Definition: Fl_Scroll.H:124
int first
scrollbar tab's "number of first line"
Definition: Fl_Scroll.H:125
Structure to manage scrollbar and widget interior sizes.
Definition: Fl_Scroll.H:135
Fl_Region_LRTB child
child bounding box: left/right/top/bottom
Definition: Fl_Scroll.H:139
int scrollsize
the effective scrollbar thickness (local or global)
Definition: Fl_Scroll.H:136
int hneeded
horizontal scrollbar visibility
Definition: Fl_Scroll.H:140
int vneeded
vertical scrollbar visibility
Definition: Fl_Scroll.H:141
Fl_Region_XYWH innerbox
widget's inner box, excluding scrollbars
Definition: Fl_Scroll.H:137
Fl_Scrollbar_Data hscroll
horizontal scrollbar region + values
Definition: Fl_Scroll.H:142
Fl_Region_XYWH innerchild
widget's inner box, including scrollbars
Definition: Fl_Scroll.H:138
Fl_Scrollbar_Data vscroll
vertical scrollbar region + values
Definition: Fl_Scroll.H:143