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

FXScrollBar.h

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

Copyright © 1997-2009 Jeroen van der Zijp