FLTK 1.3.0
Fl_Scroll.H
1 //
2 // "$Id: Fl_Scroll.H 7981 2010-12-08 23:53:04Z greg.ercolano $"
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; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 // USA.
22 //
23 // Please report all bugs and problems on the following page:
24 //
25 // http://www.fltk.org/str.php
26 //
27 
28 /* \file
29  Fl_Scroll widget . */
30 
31 #ifndef Fl_Scroll_H
32 #define Fl_Scroll_H
33 
34 #include "Fl_Group.H"
35 #include "Fl_Scrollbar.H"
36 
96 class FL_EXPORT Fl_Scroll : public Fl_Group {
97 
98  int xposition_, yposition_;
99  int oldx, oldy;
100  int scrollbar_size_;
101  static void hscrollbar_cb(Fl_Widget*, void*);
102  static void scrollbar_cb(Fl_Widget*, void*);
103  void fix_scrollbar_order();
104  static void draw_clip(void*,int,int,int,int);
105 
106 private:
107 
108  //
109  // Structure to manage scrollbar and widget interior sizes.
110  //
111  // Private for now -- we'd like to expose some of this at
112  // some point to solve STR#1895.)
113  //
114  typedef struct {
115  int scrollsize; // the scrollsize (global|local)
116  int innerbox_x, innerbox_y, innerbox_w, innerbox_h; // widget's inner box (excludes scrollbars)
117  int innerchild_x, innerchild_y, innerchild_w, innerchild_h; // widget's inner box including scrollbars
118  int child_l, child_r, child_b, child_t; // child bounding box: left/right/bottom/top
119  int hneeded, vneeded; // hor + ver scrollbar visibility
120  int hscroll_x, hscroll_y, hscroll_w, hscroll_h; // hor scrollbar size/position
121  int vscroll_x, vscroll_y, vscroll_w, vscroll_h; // ver scrollbar size/position
122  int hpos, hsize, hfirst, htotal; // hor scrollbar values (pos/size/first/total)
123  int vpos, vsize, vfirst, vtotal; // ver scrollbar values (pos/size/first/total)
124  } ScrollInfo;
125  void recalc_scrollbars(ScrollInfo &si);
126 
127 protected:
128 
129  void bbox(int&,int&,int&,int&);
130  void draw();
131 
132 public:
133 
134  Fl_Scrollbar scrollbar;
135  Fl_Scrollbar hscrollbar;
136 
137  void resize(int,int,int,int);
138  int handle(int);
139 
140  Fl_Scroll(int X,int Y,int W,int H,const char*l=0);
141 
142  enum { // values for type()
143  HORIZONTAL = 1,
144  VERTICAL = 2,
145  BOTH = 3,
146  ALWAYS_ON = 4,
147  HORIZONTAL_ALWAYS = 5,
148  VERTICAL_ALWAYS = 6,
149  BOTH_ALWAYS = 7
150  };
151 
153  int xposition() const {return xposition_;}
155  int yposition() const {return yposition_;}
156  void scroll_to(int, int);
157  void clear();
167  int scrollbar_size() const {
168  return(scrollbar_size_);
169  }
189  void scrollbar_size(int size) {
190  if ( size != scrollbar_size_ ) redraw();
191  scrollbar_size_ = size;
192  }
193 };
194 
195 #endif
196 
197 //
198 // End of "$Id: Fl_Scroll.H 7981 2010-12-08 23:53:04Z greg.ercolano $".
199 //