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,2006 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.15 2006/01/22 17:58:09 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 button (normal scrolling), by the
00051 * middle mouse button (same as the left mouse only the scroll position can jump to the
00052 * place where the click is made), or by the right mouse button (vernier- or fine-scrolling).
00053 * Holding down the control key while scrolling with the left or middle mouse button also
00054 * enables vernier-scrolling mode.  The vernier-scrolling mode is very useful for accurate
00055 * positioning in large documents.
00056 * Finally, if the mouse sports a wheel, the scroll bar can be manipulated by means
00057 * of the mouse wheel as well.  Holding down the Control-key during wheel motion
00058 * will cause the scrolling to go faster than normal.
00059 * While moving the scroll bar, a message of type SEL_CHANGED will be sent to the
00060 * target, and the message data will reflect the current position of type FXint.
00061 * At the end of the interaction, the scroll bar will send a message of type
00062 * SEL_COMMAND to notify the target of the final position.
00063 */
00064 class FXAPI FXScrollBar : public FXWindow {
00065   FXDECLARE(FXScrollBar)
00066 protected:
00067   FXint      range;           // Scrollable range
00068   FXint      page;            // Page size
00069   FXint      line;            // Line size
00070   FXint      pos;             // Position
00071   FXint      barsize;         // Bar size
00072   FXint      thumbsize;       // Thumb size
00073   FXint      thumbpos;        // Thumb position
00074   FXColor    hiliteColor;     // Hightlight color
00075   FXColor    shadowColor;     // Shadow color
00076   FXColor    borderColor;     // Border color
00077   FXColor    arrowColor;      // Arrow color
00078   FXint      dragpoint;       // Point where grabbed
00079   FXuchar    mode;            // Current mode of control
00080 protected:
00081   FXScrollBar();
00082   void drawButton(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00083   void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00084   void drawRightArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00085   void drawUpArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00086   void drawDownArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
00087 protected:
00088   enum {
00089     MODE_NONE,
00090     MODE_INC,
00091     MODE_DEC,
00092     MODE_PAGE_INC,
00093     MODE_PAGE_DEC,
00094     MODE_DRAG,
00095     MODE_FINE_DRAG
00096     };
00097 private:
00098   FXScrollBar(const FXScrollBar&);
00099   FXScrollBar &operator=(const FXScrollBar&);
00100 public:
00101   long onPaint(FXObject*,FXSelector,void*);
00102   long onMotion(FXObject*,FXSelector,void*);
00103   long onMouseWheel(FXObject*,FXSelector,void*);
00104   long onLeftBtnPress(FXObject*,FXSelector,void*);
00105   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00106   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00107   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00108   long onRightBtnPress(FXObject*,FXSelector,void*);
00109   long onRightBtnRelease(FXObject*,FXSelector,void*);
00110   long onUngrabbed(FXObject*,FXSelector,void*);
00111   long onTimeWheel(FXObject*,FXSelector,void*);
00112   long onAutoScroll(FXObject*,FXSelector,void*);
00113   long onCmdSetValue(FXObject*,FXSelector,void*);
00114   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00115   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00116   long onCmdSetIntRange(FXObject*,FXSelector,void*);
00117   long onCmdGetIntRange(FXObject*,FXSelector,void*);
00118 public:
00119   enum{
00120     ID_TIMEWHEEL=FXWindow::ID_LAST,
00121     ID_AUTOSCROLL,
00122     ID_LAST
00123     };
00124 public:
00125 
00126   /// Construct scroll bar
00127   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);
00128 
00129   /// Return default width
00130   virtual FXint getDefaultWidth();
00131 
00132   /// Return default height
00133   virtual FXint getDefaultHeight();
00134 
00135   /// Perform layout
00136   virtual void layout();
00137 
00138   /// Set content size range
00139   void setRange(FXint r);
00140 
00141   /// Return content size range
00142   FXint getRange() const { return range; }
00143 
00144   /// Set viewport page size
00145   void setPage(FXint p);
00146 
00147   /// Return page size
00148   FXint getPage() const { return page; }
00149 
00150   /// Set scoll increment for line
00151   void setLine(FXint l);
00152 
00153   /// Return line increment
00154   FXint getLine() const { return line; }
00155 
00156   /// Change scroll position
00157   void setPosition(FXint p);
00158 
00159   /// Return current scroll position
00160   FXint getPosition() const { return pos; }
00161 
00162   /// Change highlight color
00163   void setHiliteColor(FXColor clr);
00164 
00165   /// Return highlight color
00166   FXColor getHiliteColor() const { return hiliteColor; }
00167 
00168   /// Change the shadow color
00169   void setShadowColor(FXColor clr);
00170 
00171   /// Return the shadow color
00172   FXColor getShadowColor() const { return shadowColor; }
00173 
00174   /// Change the border color
00175   void setBorderColor(FXColor clr);
00176 
00177   /// Return the border color
00178   FXColor getBorderColor() const { return borderColor; }
00179 
00180   /// Change the arrow color
00181   void setArrowColor(FXColor clr);
00182 
00183   /// Return the arrow color
00184   FXColor getArrowColor() const { return arrowColor; }
00185 
00186   /// Change the scrollbar style
00187   void setScrollBarStyle(FXuint style);
00188 
00189   /// Return the scrollbar style
00190   FXuint getScrollBarStyle() const;
00191 
00192   /// Change the bar size
00193   void setBarSize(FXint size);
00194 
00195   /// Return the bar size
00196   FXint getBarSize() const { return barsize; }
00197 
00198   /// Save to stream
00199   virtual void save(FXStream& store) const;
00200 
00201   /// Load from stream
00202   virtual void load(FXStream& store);
00203 
00204   /// Destructor
00205   virtual ~FXScrollBar();
00206   };
00207 
00208 
00209 /// Corner between scroll bars
00210 class FXAPI FXScrollCorner : public FXWindow {
00211   FXDECLARE(FXScrollCorner)
00212 protected:
00213   FXScrollCorner();
00214 private:
00215   FXScrollCorner(const FXScrollCorner&);
00216   FXScrollCorner &operator=(const FXScrollCorner&);
00217 public:
00218   long onPaint(FXObject*,FXSelector,void*);
00219 public:
00220 
00221   /// Constructor
00222   FXScrollCorner(FXComposite* p);
00223 
00224   /// Can not be enabled
00225   virtual void enable();
00226 
00227   /// Can not be disabled
00228   virtual void disable();
00229   };
00230 
00231 }
00232 
00233 #endif

Copyright © 1997-2005 Jeroen van der Zijp