FLTK 1.4.4: Fl_Scroll.H Source File

FLTK 1.4.4

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
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
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;
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;
127 } Fl_Scrollbar_Data;
128
135 typedef struct {
136 int scrollsize;
137 Fl_Region_XYWH innerbox;
138 Fl_Region_XYWH innerchild;
139 Fl_Region_LRTB child;
140 int hneeded;
141 int vneeded;
142 Fl_Scrollbar_Data hscroll;
143 Fl_Scrollbar_Data vscroll;
144 } ScrollInfo;
145 void recalc_scrollbars(ScrollInfo &si) const;
146
147protected:
148
149 int on_insert(Fl_Widget*, int) FL_OVERRIDE;
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 }
198
217 void scrollbar_size(int newSize) {
218 if ( newSize != scrollbar_size_ ) redraw();
219 scrollbar_size_ = newSize;
220 }
221};
222
223#endif
Fl_Group.H
Fl_Group and Fl_End classes.
Fl_Group::on_move
virtual int on_move(int, int)
Allow derived groups to act when a widget is moved within the group.
Definition Fl_Group.cxx:499
Fl_Group::draw
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Group.cxx:943
Fl_Group::on_insert
virtual int on_insert(Fl_Widget *, int)
Allow derived groups to act when a widget is added as a child.
Definition Fl_Group.cxx:475
Fl_Group::delete_child
virtual int delete_child(int n)
Removes the widget at index from the group and deletes it.
Definition Fl_Group.cxx:665
Fl_Group::clear
void clear()
Deletes all child widgets from memory recursively.
Definition Fl_Group.cxx:381
Fl_Scroll::resize
void resize(int X, int Y, int W, int H) FL_OVERRIDE
Resizes the Fl_Scroll widget and moves its children if necessary.
Definition Fl_Scroll.cxx:466
Fl_Scroll::yposition
int yposition() const
Gets the current vertical scrolling position.
Definition Fl_Scroll.H:179
Fl_Scroll::handle
int handle(int) FL_OVERRIDE
Handles the specified event.
Definition Fl_Scroll.cxx:557
Fl_Scroll::fix_scrollbar_order
void fix_scrollbar_order()
Ensure the scrollbars are the last children.
Definition Fl_Scroll.cxx:62
Fl_Scroll::recalc_scrollbars
void recalc_scrollbars(ScrollInfo &si) const
Calculate visibility/size/position of scrollbars, find children's bounding box.
Definition Fl_Scroll.cxx:212
Fl_Scroll::scrollbar_size
void scrollbar_size(int newSize)
Sets the pixel size of the scrollbars' troughs to newSize, in pixels.
Definition Fl_Scroll.H:217
Fl_Scroll::Fl_Scroll
Fl_Scroll(int X, int Y, int W, int H, const char *L=0)
Creates a new Fl_Scroll widget using the given position, size, and label string.
Definition Fl_Scroll.cxx:542
Fl_Scroll::xposition
int xposition() const
Gets the current horizontal scrolling position.
Definition Fl_Scroll.H:177
Fl_Scroll::bbox
void bbox(int &, int &, int &, int &) const
Returns the bounding box for the interior of the scrolling area, inside the scrollbars.
Definition Fl_Scroll.cxx:338
Fl_Scroll::scrollbar_size
int scrollbar_size() const
Gets the current size of the scrollbars' troughs, in pixels.
Definition Fl_Scroll.H:195
Fl_Scrollbar
The Fl_Scrollbar widget displays a slider with arrow buttons at the ends of the scrollbar.
Definition Fl_Scrollbar.H:41
Fl_Widget::redraw
void redraw()
Schedules the drawing of the widget.
Definition Fl.cxx:1668
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
Fl_Scroll::Fl_Region_LRTB
A local struct to manage a region defined by left/right/top/bottom.
Definition Fl_Scroll.H:113
Fl_Scroll::Fl_Region_LRTB::r
int r
(r)ight "x" position, aka x2
Definition Fl_Scroll.H:115
Fl_Scroll::Fl_Region_LRTB::b
int b
(b)ottom "y" position, aka y2
Definition Fl_Scroll.H:117
Fl_Scroll::Fl_Region_LRTB::l
int l
(l)eft "x" position, aka x1
Definition Fl_Scroll.H:114
Fl_Scroll::Fl_Region_LRTB::t
int t
(t)op "y" position, aka y1
Definition Fl_Scroll.H:116
Fl_Scroll::Fl_Region_XYWH
A local struct to manage a region defined by xywh.
Definition Fl_Scroll.H:110
Fl_Scroll::Fl_Scrollbar_Data
A local struct to manage a scrollbar's xywh region and tab values.
Definition Fl_Scroll.H:121
Fl_Scroll::Fl_Scrollbar_Data::pos
int pos
scrollbar tab's "position of first line displayed"
Definition Fl_Scroll.H:123
Fl_Scroll::Fl_Scrollbar_Data::total
int total
scrollbar tab's "total number of lines"
Definition Fl_Scroll.H:126
Fl_Scroll::Fl_Scrollbar_Data::size
int size
scrollbar tab's "size of window in lines"
Definition Fl_Scroll.H:124
Fl_Scroll::Fl_Scrollbar_Data::first
int first
scrollbar tab's "number of first line"
Definition Fl_Scroll.H:125
Fl_Scroll::ScrollInfo
Structure to manage scrollbar and widget interior sizes.
Definition Fl_Scroll.H:135
Fl_Scroll::ScrollInfo::child
Fl_Region_LRTB child
child bounding box: left/right/top/bottom
Definition Fl_Scroll.H:139
Fl_Scroll::ScrollInfo::scrollsize
int scrollsize
the effective scrollbar thickness (local or global)
Definition Fl_Scroll.H:136
Fl_Scroll::ScrollInfo::hneeded
int hneeded
horizontal scrollbar visibility
Definition Fl_Scroll.H:140
Fl_Scroll::ScrollInfo::vneeded
int vneeded
vertical scrollbar visibility
Definition Fl_Scroll.H:141
Fl_Scroll::ScrollInfo::innerbox
Fl_Region_XYWH innerbox
widget's inner box, excluding scrollbars
Definition Fl_Scroll.H:137
Fl_Scroll::ScrollInfo::hscroll
Fl_Scrollbar_Data hscroll
horizontal scrollbar region + values
Definition Fl_Scroll.H:142
Fl_Scroll::ScrollInfo::innerchild
Fl_Region_XYWH innerchild
widget's inner box, including scrollbars
Definition Fl_Scroll.H:138
Fl_Scroll::ScrollInfo::vscroll
Fl_Scrollbar_Data vscroll
vertical scrollbar region + values
Definition Fl_Scroll.H:143