Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXScrollBar.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                       S c r o l l   B a r   W i d g e t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2004 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 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 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser 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  USA.    *
00021 *********************************************************************************
00022 * $Id: FXScrollBar.h,v 1.11 2004/02/08 17:17:34 fox Exp $                        *
00023 ********************************************************************************/
00024 #ifndef FXSCROLLBAR_H
00025 #define FXSCROLLBAR_H
00026 
00027 #ifndef FXWINDOW_H
00028 #include "FXWindow.h"
00029 #endif
00030 
00031 
00032 namespace FX {
00033 
00034 
00035 
00036 /// ScrollBar styles
00037 enum {
00038   SCROLLBAR_VERTICAL   = 0,             /// Vertically oriented
00039   SCROLLBAR_HORIZONTAL = 0x00020000,    /// Horizontally oriented
00040   SCROLLBAR_WHEELJUMP  = 0x00040000     /// Mouse wheel jumps instead of sliding smoothly
00041   };
00042 
00043 
00044 
00045 /**
00046 * The scroll bar is used when a document has a larger content than may be made
00047 * visible.  The range is the total size of the document, the page is the part
00048 * of the document which is visible.  The size of the scrollbar thumb is adjusted
00049 * to give feedback of the relative sizes of each.
00050 * The scroll bar may be manipulated by the left mouse (normal scrolling), right
00051 * mouse (vernier or fine-scrolling), or middle mouse (same as the left mouse only
00052 * the scroll position can hop to the place where the click is made).
00053 * Finally, if the mouse sports a wheel, the scroll bar can be manipulated by means
00054 * of the mouse wheel as well.  Holding down the Control-key during wheel motion
00055 * will cause the scrolling to go faster than normal.
00056 * While moving the scroll bar, a message of type SEL_CHANGED will be sent to the
00057 * target, and the message data will reflect the current position of type FXint.
00058 * At the end of the interaction, the scroll bar will send a message of type
00059 * SEL_COMMAND to notify the target of the final position.
00060 */
00061 class FXAPI FXScrollBar : public FXWindow {
00062   FXDECLARE(FXScrollBar)
00063 protected:
00064   FXint      range;           // Scrollable range
00065   FXint      page;            // Page size
00066   FXint      line;            // Line size
00067   FXint      pos;             // Position
00068   FXint      thumbsize;       // Thumb size
00069   FXint      thumbpos;        // Thumb position
00070   FXColor    hiliteColor;     // Hightlight color
00071   FXColor    shadowColor;     // Shadow color
00072   FXColor    borderColor;     // Border color
00073   FXColor    arrowColor;      // Arrow color
00074   FXint      dragpoint;       // Point where grabbed
00075   FXuchar    mode;            // Current mode of control
00076 protected:
00077   FXScrollBar();
00078   void drawButton(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00079   void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00080   void drawRightArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00081   void drawUpArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00082   void drawDownArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00083 protected:
00084   enum {
00085     MODE_NONE,
00086     MODE_INC,
00087     MODE_DEC,
00088     MODE_PAGE_INC,
00089     MODE_PAGE_DEC,
00090     MODE_DRAG,
00091     MODE_FINE_DRAG
00092     };
00093 private:
00094   FXScrollBar(const FXScrollBar&);
00095   FXScrollBar &operator=(const FXScrollBar&);
00096 public:
00097   long onPaint(FXObject*,FXSelector,void*);
00098   long onMotion(FXObject*,FXSelector,void*);
00099   long onMouseWheel(FXObject*,FXSelector,void*);
00100   long onLeftBtnPress(FXObject*,FXSelector,void*);
00101   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00102   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00103   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00104   long onRightBtnPress(FXObject*,FXSelector,void*);
00105   long onRightBtnRelease(FXObject*,FXSelector,void*);
00106   long onUngrabbed(FXObject*,FXSelector,void*);
00107   long onTimeWheel(FXObject*,FXSelector,void*);
00108   long onAutoScroll(FXObject*,FXSelector,void*);
00109   long onCmdSetValue(FXObject*,FXSelector,void*);
00110   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00111   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00112   long onCmdSetIntRange(FXObject*,FXSelector,void*);
00113   long onCmdGetIntRange(FXObject*,FXSelector,void*);
00114 public:
00115   enum{
00116     ID_TIMEWHEEL=FXWindow::ID_LAST,
00117     ID_AUTOSCROLL,
00118     ID_LAST
00119     };
00120 public:
00121 
00122   /// Construct scroll bar
00123   FXScrollBar(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=SCROLLBAR_VERTICAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00124 
00125   /// Return default width
00126   virtual FXint getDefaultWidth();
00127 
00128   /// Return default height
00129   virtual FXint getDefaultHeight();
00130 
00131   /// Perform layout
00132   virtual void layout();
00133 
00134   /// Set content size range
00135   void setRange(FXint r);
00136 
00137   /// Return content size range
00138   FXint getRange() const { return range; }
00139 
00140   /// Set viewport page size
00141   void setPage(FXint p);
00142 
00143   /// Return page size
00144   FXint getPage() const { return page; }
00145 
00146   /// Set scoll increment for line
00147   void setLine(FXint l);
00148 
00149   /// Return line increment
00150   FXint getLine() const { return line; }
00151 
00152   /// Change current scroll position
00153   void setPosition(FXint p);
00154 
00155   /// return scroll position
00156   FXint getPosition() const { return pos; }
00157 
00158   /// Change highlight color
00159   void setHiliteColor(FXColor clr);
00160 
00161   /// Return highlight color
00162   FXColor getHiliteColor() const { return hiliteColor; }
00163 
00164   /// Change shadow color
00165   void setShadowColor(FXColor clr);
00166 
00167   /// Return shadow color
00168   FXColor getShadowColor() const { return shadowColor; }
00169 
00170   /// Return border color
00171   void setBorderColor(FXColor clr);
00172 
00173   /// Change border color
00174   FXColor getBorderColor() const { return borderColor; }
00175 
00176   /// Return arrow color
00177   void setArrowColor(FXColor clr);
00178 
00179   /// Return arrow color
00180   FXColor getArrowColor() const { return arrowColor; }
00181 
00182   /// Change the scrollbar style
00183   FXuint getScrollbarStyle() const;
00184 
00185   /// Get the current scrollbar style
00186   void setScrollbarStyle(FXuint style);
00187 
00188   /// Save to stream
00189   virtual void save(FXStream& store) const;
00190 
00191   /// Load from stream
00192   virtual void load(FXStream& store);
00193 
00194   /// Destructor
00195   virtual ~FXScrollBar();
00196   };
00197 
00198 
00199 /// Corner between scroll bars
00200 class FXAPI FXScrollCorner : public FXWindow {
00201   FXDECLARE(FXScrollCorner)
00202 protected:
00203   FXScrollCorner();
00204 private:
00205   FXScrollCorner(const FXScrollCorner&);
00206   FXScrollCorner &operator=(const FXScrollCorner&);
00207 public:
00208   long onPaint(FXObject*,FXSelector,void*);
00209 public:
00210 
00211   /// Constructor
00212   FXScrollCorner(FXComposite* p);
00213 
00214   /// Can not be enabled
00215   virtual void enable();
00216 
00217   /// Can not be disabled
00218   virtual void disable();
00219   };
00220 
00221 }
00222 
00223 #endif

Copyright © 1997-2004 Jeroen van der Zijp