FLTK
Fl_Scroll.H
1 //
2 // Scroll header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2015 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 
85 class FL_EXPORT Fl_Scroll : public Fl_Group {
86 
87  int xposition_, yposition_;
88  int oldx, oldy;
89  int scrollbar_size_;
90  static void hscrollbar_cb(Fl_Widget*, void*);
91  static void scrollbar_cb(Fl_Widget*, void*);
92  void fix_scrollbar_order();
93  static void draw_clip(void*,int,int,int,int);
94 
95 protected: // (STR#1895)
102  typedef struct {
104  typedef struct { int x,y,w,h; } Fl_Region_XYWH;
106  typedef struct {
107  int l;
108  int r;
109  int t;
110  int b;
111  } Fl_Region_LRTB;
113  typedef struct {
114  int x,y,w,h;
115  int pos;
116  int size;
117  int first;
118  int total;
124  int hneeded;
125  int vneeded;
128  } ScrollInfo;
129  void recalc_scrollbars(ScrollInfo &si);
130 
131 protected:
132 
133  void bbox(int&,int&,int&,int&);
134  void draw();
135 
136 public:
137 
138  Fl_Scrollbar scrollbar;
139  Fl_Scrollbar hscrollbar;
140 
141  void resize(int X, int Y, int W, int H);
142  int handle(int);
143 
144  Fl_Scroll(int X,int Y,int W,int H,const char*l=0);
145 
146  enum { // values for type()
147  HORIZONTAL = 1,
148  VERTICAL = 2,
149  BOTH = 3,
150  ALWAYS_ON = 4,
151  HORIZONTAL_ALWAYS = 5,
152  VERTICAL_ALWAYS = 6,
153  BOTH_ALWAYS = 7
154  };
155 
157  int xposition() const {return xposition_;}
159  int yposition() const {return yposition_;}
160  void scroll_to(int, int);
161  void clear();
171  int scrollbar_size() const {
172  return(scrollbar_size_);
173  }
193  void scrollbar_size(int newSize) {
194  if ( newSize != scrollbar_size_ ) redraw();
195  scrollbar_size_ = newSize;
196  }
197 };
198 
199 #endif
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
Fl_Region_LRTB child
child bounding box: left/right/top/bottom
Definition: Fl_Scroll.H:123
int h() const
Gets the widget height.
Definition: Fl_Widget.H:286
A local struct to manage a region defined by left/right/top/bottom.
Definition: Fl_Scroll.H:106
void redraw()
Schedules the drawing of the widget.
Definition: Fl.cxx:1480
Fl_Scrollbar_Data hscroll
horizontal scrollbar region + values
Definition: Fl_Scroll.H:126
Structure to manage scrollbar and widget interior sizes.
Definition: Fl_Scroll.H:102
Fl_Region_XYWH innerbox
widget's inner box, excluding scrollbars
Definition: Fl_Scroll.H:121
void draw()
Draws the widget.
Definition: Fl_Group.cxx:817
void clear()
Deletes all child widgets from memory recursively.
Definition: Fl_Group.cxx:388
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:42
int pos
scrollbar tab's "position of first line displayed"
Definition: Fl_Scroll.H:115
int handle(int)
Handles the specified event.
Definition: Fl_Group.cxx:144
A local struct to manage a region defined by xywh.
Definition: Fl_Scroll.H:104
int r
(r)ight "x" position, aka x2
Definition: Fl_Scroll.H:108
int yposition() const
Gets the current vertical scrolling position.
Definition: Fl_Scroll.H:159
int xposition() const
Gets the current horizontal scrolling position.
Definition: Fl_Scroll.H:157
int y() const
Gets the widget position in its window.
Definition: Fl_Widget.H:276
int first
scrollbar tab's "number of first line"
Definition: Fl_Scroll.H:117
int size
scrollbar tab's "size of window in lines"
Definition: Fl_Scroll.H:116
int scrollbar_size() const
Gets the current size of the scrollbars' troughs, in pixels.
Definition: Fl_Scroll.H:171
void resize(int, int, int, int)
Resizes the Fl_Group widget and all of its children.
Definition: Fl_Group.cxx:700
Fl_Region_XYWH innerchild
widget's inner box, including scrollbars
Definition: Fl_Scroll.H:122
int t
(t)op "y" position, aka y1
Definition: Fl_Scroll.H:109
This container widget lets you maneuver around a set of widgets much larger than your window...
Definition: Fl_Scroll.H:85
int x() const
Gets the widget position in its window.
Definition: Fl_Widget.H:271
int l
(l)eft "x" position, aka x1
Definition: Fl_Scroll.H:107
int hneeded
horizontal scrollbar visibility
Definition: Fl_Scroll.H:124
int vneeded
vertical scrollbar visibility
Definition: Fl_Scroll.H:125
A local struct to manage a scrollbar's xywh region and tab values.
Definition: Fl_Scroll.H:113
int scrollsize
the effective scrollbar thickness (local or global)
Definition: Fl_Scroll.H:120
Fl_Scrollbar_Data vscroll
vertical scrollbar region + values
Definition: Fl_Scroll.H:127
int b
(b)ottom "y" position, aka y2
Definition: Fl_Scroll.H:110
void scrollbar_size(int newSize)
Sets the pixel size of the scrollbars' troughs to newSize, in pixels.
Definition: Fl_Scroll.H:193
int w() const
Gets the widget width.
Definition: Fl_Widget.H:281
int total
scrollbar tab's "total number of lines"
Definition: Fl_Scroll.H:118
The Fl_Scrollbar widget displays a slider with arrow buttons at the ends of the scrollbar.
Definition: Fl_Scrollbar.H:41