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