FLTK 1.3.2
Fl_Scroll.H
1 //
2 // "$Id: Fl_Scroll.H 9126 2011-10-04 13:10:55Z manolo $"
3 //
4 // Scroll header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18 
19 /* \file
20  Fl_Scroll widget . */
21 
22 #ifndef Fl_Scroll_H
23 #define Fl_Scroll_H
24 
25 #include "Fl_Group.H"
26 #include "Fl_Scrollbar.H"
27 
87 class FL_EXPORT Fl_Scroll : public Fl_Group {
88 
89  int xposition_, yposition_;
90  int oldx, oldy;
91  int scrollbar_size_;
92  static void hscrollbar_cb(Fl_Widget*, void*);
93  static void scrollbar_cb(Fl_Widget*, void*);
94  void fix_scrollbar_order();
95  static void draw_clip(void*,int,int,int,int);
96 
97 private:
98 
99  //
100  // Structure to manage scrollbar and widget interior sizes.
101  //
102  // Private for now -- we'd like to expose some of this at
103  // some point to solve STR#1895.)
104  //
105  typedef struct {
106  int scrollsize; // the scrollsize (global|local)
107  int innerbox_x, innerbox_y, innerbox_w, innerbox_h; // widget's inner box (excludes scrollbars)
108  int innerchild_x, innerchild_y, innerchild_w, innerchild_h; // widget's inner box including scrollbars
109  int child_l, child_r, child_b, child_t; // child bounding box: left/right/bottom/top
110  int hneeded, vneeded; // hor + ver scrollbar visibility
111  int hscroll_x, hscroll_y, hscroll_w, hscroll_h; // hor scrollbar size/position
112  int vscroll_x, vscroll_y, vscroll_w, vscroll_h; // ver scrollbar size/position
113  int hpos, hsize, hfirst, htotal; // hor scrollbar values (pos/size/first/total)
114  int vpos, vsize, vfirst, vtotal; // ver scrollbar values (pos/size/first/total)
115  } ScrollInfo;
116  void recalc_scrollbars(ScrollInfo &si);
117 
118 protected:
119 
120  void bbox(int&,int&,int&,int&);
121  void draw();
122 
123 public:
124 
125  Fl_Scrollbar scrollbar;
126  Fl_Scrollbar hscrollbar;
127 
128  void resize(int,int,int,int);
129  int handle(int);
130 
131  Fl_Scroll(int X,int Y,int W,int H,const char*l=0);
132 
133  enum { // values for type()
134  HORIZONTAL = 1,
135  VERTICAL = 2,
136  BOTH = 3,
137  ALWAYS_ON = 4,
138  HORIZONTAL_ALWAYS = 5,
139  VERTICAL_ALWAYS = 6,
140  BOTH_ALWAYS = 7
141  };
142 
144  int xposition() const {return xposition_;}
146  int yposition() const {return yposition_;}
147  void scroll_to(int, int);
148  void clear();
158  int scrollbar_size() const {
159  return(scrollbar_size_);
160  }
180  void scrollbar_size(int newSize) {
181  if ( newSize != scrollbar_size_ ) redraw();
182  scrollbar_size_ = newSize;
183  }
184 };
185 
186 #endif
187 
188 //
189 // End of "$Id: Fl_Scroll.H 9126 2011-10-04 13:10:55Z manolo $".
190 //
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:100
void redraw()
Schedules the drawing of the widget.
Definition: Fl.cxx:1627
int yposition() const
Gets the current vertical scrolling position.
Definition: Fl_Scroll.H:146
void draw()
Draws the widget.
Definition: Fl_Group.cxx:736
void clear()
Deletes all child widgets from memory recursively.
Definition: Fl_Group.cxx:381
int scrollbar_size() const
Gets the current size of the scrollbars' troughs, in pixels.
Definition: Fl_Scroll.H:158
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:36
int handle(int)
Handles the specified event.
Definition: Fl_Group.cxx:145
void resize(int, int, int, int)
Resizes the Fl_Group widget and all of its children.
Definition: Fl_Group.cxx:632
int xposition() const
Gets the current horizontal scrolling position.
Definition: Fl_Scroll.H:144
This container widget lets you maneuver around a set of widgets much larger than your window...
Definition: Fl_Scroll.H:87
void scrollbar_size(int newSize)
Sets the pixel size of the scrollbars' troughs to newSize, in pixels.
Definition: Fl_Scroll.H:180
The Fl_Scrollbar widget displays a slider with arrow buttons at the ends of the scrollbar.
Definition: Fl_Scrollbar.H:43