FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_Scroll.H
1//
2// Fl_Scroll header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2022 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
98class 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
107protected: // (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;
119
121 typedef struct {
122 int x,y,w,h;
123 int pos;
124 int size;
125 int first;
126 int total;
128
145 void recalc_scrollbars(ScrollInfo &si) const;
146
147protected:
148
150 int on_move(int, int) FL_OVERRIDE;
151 void fix_scrollbar_order();
152 void bbox(int&,int&,int&,int&) const;
153 void draw() FL_OVERRIDE;
154
155public:
156
157 Fl_Scrollbar scrollbar;
158 Fl_Scrollbar hscrollbar;
159
160 void resize(int X, int Y, int W, int H) FL_OVERRIDE;
161 int handle(int) FL_OVERRIDE;
162
163 Fl_Scroll(int X, int Y, int W, int H, const char *L = 0);
164 virtual ~Fl_Scroll();
165
166 enum { // values for type()
167 HORIZONTAL = 1,
168 VERTICAL = 2,
169 BOTH = 3,
170 ALWAYS_ON = 4,
171 HORIZONTAL_ALWAYS = 5,
172 VERTICAL_ALWAYS = 6,
173 BOTH_ALWAYS = 7
174 };
175
177 int xposition() const {return xposition_;}
179 int yposition() const {return yposition_;}
180 void scroll_to(int, int);
181 void clear();
182
183 /* delete child n (by index) */
184 int delete_child(int n) FL_OVERRIDE;
185
195 int scrollbar_size() const {
196 return(scrollbar_size_);
197 }
217 void scrollbar_size(int newSize) {
218 if ( newSize != scrollbar_size_ ) redraw();
219 scrollbar_size_ = newSize;
220 }
221};
222
223#endif
Fl_Group and Fl_End classes.
The Fl_Group class is the FLTK container widget.
Definition Fl_Group.H:56
virtual int on_move(int, int)
Allow derived groups to act when a widget is moved within the group.
Definition Fl_Group.cxx:497
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Group.cxx:926
virtual int on_insert(Fl_Widget *, int)
Allow derived groups to act when a widget is added as a child.
Definition Fl_Group.cxx:473
virtual int delete_child(int n)
Removes the widget at index from the group and deletes it.
Definition Fl_Group.cxx:663
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:179
void scrollbar_size(int newSize)
Sets the pixel size of the scrollbars' troughs to newSize, in pixels.
Definition Fl_Scroll.H:217
int xposition() const
Gets the current horizontal scrolling position.
Definition Fl_Scroll.H:177
int scrollbar_size() const
Gets the current size of the scrollbars' troughs, in pixels.
Definition Fl_Scroll.H:195
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:104
int y() const
Gets the widget position in its window.
Definition Fl_Widget.H:358
int h() const
Gets the widget height.
Definition Fl_Widget.H:368
int w() const
Gets the widget width.
Definition Fl_Widget.H:363
void redraw()
Schedules the drawing of the widget.
Definition Fl.cxx:1586
int x() const
Gets the widget position in its window.
Definition Fl_Widget.H:353
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
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