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

FXScrollArea.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                       S c r o l l A r e a   W i d g e t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2002 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: FXScrollArea.h,v 1.15 2002/01/18 22:42:54 jeroen Exp $                   *
00023 ********************************************************************************/
00024 #ifndef FXSCROLLAREA_H
00025 #define FXSCROLLAREA_H
00026 
00027 #ifndef FXCOMPOSITE_H
00028 #include "FXComposite.h"
00029 #endif
00030 
00031 
00032 /// Scrollbar options
00033 enum {
00034   SCROLLERS_NORMAL     = 0,                                 /// Show the scrollbars when needed
00035   HSCROLLER_ALWAYS     = 0x00008000,                        /// Always show horizontal scrollers
00036   HSCROLLER_NEVER      = 0x00010000,                        /// Never show horizontal scrollers
00037   VSCROLLER_ALWAYS     = 0x00020000,                        /// Always show vertical scrollers
00038   VSCROLLER_NEVER      = 0x00040000,                        /// Never show vertical scrollers
00039   HSCROLLING_ON        = 0,                                 /// Horizontal scrolling turned on (default)
00040   HSCROLLING_OFF       = HSCROLLER_NEVER|HSCROLLER_ALWAYS,  /// Horizontal scrolling turned off
00041   VSCROLLING_ON        = 0,                                 /// Vertical scrolling turned on (default)
00042   VSCROLLING_OFF       = VSCROLLER_NEVER|VSCROLLER_ALWAYS,  /// Vertical scrolling turned off
00043   SCROLLERS_TRACK      = 0,                                 /// Scrollers track continuously for smooth scrolling
00044   SCROLLERS_DONT_TRACK = 0x00080000                         /// Scrollers don't track continuously
00045   };
00046 
00047 
00048 class FXScrollbar;
00049 class FXScrollCorner;
00050 struct FXTimer;
00051 
00052 
00053 /**
00054 * The scroll area widget manages a content area and a viewport
00055 * area through which the content is viewed.  When the content area
00056 * becomes larger than the viewport area, scrollbars are placed to
00057 * permit viewing of the entire content by scrolling the content.
00058 * Depending on the mode, scrollbars may be displayed on an as-needed
00059 * basis, always, or never.
00060 * Normally, the scroll area's size and the content's size are independent;
00061 * however, it is possible to disable scrolling in the horizontal
00062 * (vertical) direction.  In this case, the content width (height)
00063 * will influence the width (height) of the scroll area widget.
00064 * For content which is time-consuming to repaint, continuous
00065 * scrolling may be turned off.
00066 */
00067 class FXAPI FXScrollArea : public FXComposite {
00068   FXDECLARE(FXScrollArea)
00069 protected:
00070   FXScrollbar    *horizontal;
00071   FXScrollbar    *vertical;
00072   FXScrollCorner *corner;
00073   FXTimer        *scrolltimer;
00074   FXint           viewport_w;
00075   FXint           viewport_h;
00076   FXint           content_w;
00077   FXint           content_h;
00078   FXint           pos_x;
00079   FXint           pos_y;
00080 protected:
00081   FXScrollArea();
00082   FXbool startAutoScroll(FXint x,FXint y,FXbool onlywheninside=FALSE);
00083   void stopAutoScroll();
00084   virtual void layout();
00085   FXScrollArea(FXComposite* p,FXuint opts,FXint x,FXint y,FXint w,FXint h);
00086 private:
00087   FXScrollArea(const FXScrollArea&);
00088   FXScrollArea &operator=(const FXScrollArea&);
00089 public:
00090   long onHMouseWheel(FXObject*,FXSelector,void*);
00091   long onVMouseWheel(FXObject*,FXSelector,void*);
00092   long onHScrollerChanged(FXObject*,FXSelector,void*);
00093   long onVScrollerChanged(FXObject*,FXSelector,void*);
00094   long onHScrollerDragged(FXObject*,FXSelector,void*);
00095   long onVScrollerDragged(FXObject*,FXSelector,void*);
00096   long onAutoScroll(FXObject*,FXSelector,void*);
00097 public:
00098 
00099   /// Return default width
00100   virtual FXint getDefaultWidth();
00101 
00102   /// Return default height
00103   virtual FXint getDefaultHeight();
00104 
00105   /// Return viewport size
00106   virtual FXint getViewportHeight();
00107   virtual FXint getViewportWidth();
00108 
00109   /// Return content size
00110   virtual FXint getContentWidth();
00111   virtual FXint getContentHeight();
00112 
00113   /// Change scroll style
00114   void setScrollStyle(FXuint style);
00115 
00116   /// Return scroll style
00117   FXuint getScrollStyle() const;
00118 
00119   /// Return TRUE if horizontally scrollable
00120   FXbool isHorizontalScrollable() const;
00121 
00122   /// Return TRUE if vertically scrollable
00123   FXbool isVerticalScrollable() const;
00124 
00125   /// Return a pointer to the horizontal scrollbar
00126   FXScrollbar* horizontalScrollbar() const { return horizontal; }
00127 
00128   /// Return a pointer to the vertical scrollbar
00129   FXScrollbar* verticalScrollbar() const { return vertical; }
00130 
00131   /// Return the current x-position
00132   FXint getXPosition() const { return pos_x; }
00133 
00134   /// Return the current y-position
00135   FXint getYPosition() const { return pos_y; }
00136 
00137   /// Set the current position
00138   void setPosition(FXint x,FXint y);
00139 
00140   /// Get the current position
00141   void getPosition(FXint& x,FXint& y) const { x=pos_x; y=pos_y; }
00142 
00143   /// Move contents to the specified position
00144   virtual void moveContents(FXint x,FXint y);
00145 
00146   /// Destructor
00147   virtual ~FXScrollArea();
00148   };
00149 
00150 
00151 
00152 #endif