FLTK 1.3.0
Fl_Scroll.H
00001 //
00002 // "$Id: Fl_Scroll.H 7981 2010-12-08 23:53:04Z greg.ercolano $"
00003 //
00004 // Scroll header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 //
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Library General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2 of the License, or (at your option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021 // USA.
00022 //
00023 // Please report all bugs and problems on the following page:
00024 //
00025 //     http://www.fltk.org/str.php
00026 //
00027 
00028 /* \file
00029    Fl_Scroll widget . */
00030 
00031 #ifndef Fl_Scroll_H
00032 #define Fl_Scroll_H
00033 
00034 #include "Fl_Group.H"
00035 #include "Fl_Scrollbar.H"
00036 
00096 class FL_EXPORT Fl_Scroll : public Fl_Group {
00097 
00098   int xposition_, yposition_;
00099   int oldx, oldy;
00100   int scrollbar_size_;
00101   static void hscrollbar_cb(Fl_Widget*, void*);
00102   static void scrollbar_cb(Fl_Widget*, void*);
00103   void fix_scrollbar_order();
00104   static void draw_clip(void*,int,int,int,int);
00105 
00106 private:
00107 
00108   //
00109   //  Structure to manage scrollbar and widget interior sizes.
00110   //
00111   //  Private for now -- we'd like to expose some of this at 
00112   //  some point to solve STR#1895.)
00113   //
00114   typedef struct {
00115       int scrollsize;                                                   // the scrollsize (global|local)
00116       int innerbox_x, innerbox_y, innerbox_w, innerbox_h;               // widget's inner box (excludes scrollbars)
00117       int innerchild_x, innerchild_y, innerchild_w, innerchild_h;       // widget's inner box including scrollbars
00118       int child_l, child_r, child_b, child_t;                           // child bounding box: left/right/bottom/top
00119       int hneeded, vneeded;                                             // hor + ver scrollbar visibility
00120       int hscroll_x, hscroll_y, hscroll_w, hscroll_h;                   // hor scrollbar size/position
00121       int vscroll_x, vscroll_y, vscroll_w, vscroll_h;                   // ver scrollbar size/position
00122       int hpos, hsize, hfirst, htotal;                                  // hor scrollbar values (pos/size/first/total)
00123       int vpos, vsize, vfirst, vtotal;                                  // ver scrollbar values (pos/size/first/total)
00124   } ScrollInfo;
00125   void recalc_scrollbars(ScrollInfo &si);
00126 
00127 protected:
00128 
00129   void bbox(int&,int&,int&,int&);
00130   void draw();
00131 
00132 public:
00133 
00134   Fl_Scrollbar scrollbar;
00135   Fl_Scrollbar hscrollbar;
00136 
00137   void resize(int,int,int,int);
00138   int handle(int);
00139 
00140   Fl_Scroll(int X,int Y,int W,int H,const char*l=0);
00141 
00142   enum { // values for type()
00143     HORIZONTAL = 1,
00144     VERTICAL = 2,
00145     BOTH = 3,
00146     ALWAYS_ON = 4,
00147     HORIZONTAL_ALWAYS = 5,
00148     VERTICAL_ALWAYS = 6,
00149     BOTH_ALWAYS = 7
00150   };
00151 
00153   int xposition() const {return xposition_;}
00155   int yposition() const {return yposition_;}
00156   void scroll_to(int, int);
00157   void clear();
00167   int scrollbar_size() const {
00168       return(scrollbar_size_);
00169   }
00189   void scrollbar_size(int size) {
00190       if ( size != scrollbar_size_ ) redraw();
00191       scrollbar_size_ = size;
00192   }   
00193 };
00194 
00195 #endif
00196 
00197 //
00198 // End of "$Id: Fl_Scroll.H 7981 2010-12-08 23:53:04Z greg.ercolano $".
00199 //