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

FXScrollArea.h

Go to the documentation of this file.
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,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: FXScrollArea.h,v 1.29 2006/01/22 17:58:09 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 
00053 
00054 /**
00055 * The scroll area widget manages a content area and a viewport
00056 * area through which the content is viewed.  When the content area
00057 * becomes larger than the viewport area, scrollbars are placed to
00058 * permit viewing of the entire content by scrolling the content.
00059 * Depending on the mode, scrollbars may be displayed on an as-needed
00060 * basis, always, or never.
00061 * Normally, the scroll area's size and the content's size are independent;
00062 * however, it is possible to disable scrolling in the horizontal
00063 * (vertical) direction.  In this case, the content width (height)
00064 * will influence the width (height) of the scroll area widget.
00065 * For content which is time-consuming to repaint, continuous
00066 * scrolling may be turned off.
00067 */
00068 class FXAPI FXScrollArea : public FXComposite {
00069   FXDECLARE(FXScrollArea)
00070 protected:
00071   FXScrollBar    *horizontal;   // Horizontal scroll bar
00072   FXScrollBar    *vertical;     // Vertical scroll bar
00073   FXScrollCorner *corner;       // Scroll corner
00074   FXint           viewport_w;   // Viewport width
00075   FXint           viewport_h;   // Viewport height
00076   FXint           pos_x;        // X scroll position (pos_x<=0)
00077   FXint           pos_y;        // Y scroll position (pos_y<=0)
00078 protected:
00079   FXScrollArea();
00080   FXbool startAutoScroll(FXEvent *event,FXbool onlywheninside=FALSE);
00081   void stopAutoScroll();
00082   FXScrollArea(FXComposite* p,FXuint opts,FXint x,FXint y,FXint w,FXint h);
00083   virtual void moveContents(FXint x,FXint y);
00084 private:
00085   FXScrollArea(const FXScrollArea&);
00086   FXScrollArea &operator=(const FXScrollArea&);
00087 public:
00088   long onHMouseWheel(FXObject*,FXSelector,void*);
00089   long onVMouseWheel(FXObject*,FXSelector,void*);
00090   long onHScrollerChanged(FXObject*,FXSelector,void*);
00091   long onVScrollerChanged(FXObject*,FXSelector,void*);
00092   long onHScrollerDragged(FXObject*,FXSelector,void*);
00093   long onVScrollerDragged(FXObject*,FXSelector,void*);
00094   long onAutoScroll(FXObject*,FXSelector,void*);
00095 public:
00096 
00097   /// Return default width
00098   virtual FXint getDefaultWidth();
00099 
00100   /// Return default height
00101   virtual FXint getDefaultHeight();
00102 
00103   /// Perform layout
00104   virtual void layout();
00105 
00106   /// Return viewport height
00107   virtual FXint getViewportHeight();
00108 
00109   /// Return viewport width
00110   virtual FXint getViewportWidth();
00111 
00112   /// Return content width
00113   virtual FXint getContentWidth();
00114 
00115   /// Return content height
00116   virtual FXint getContentHeight();
00117 
00118   /// Change scroll style
00119   void setScrollStyle(FXuint style);
00120 
00121   /// Return scroll style
00122   FXuint getScrollStyle() const;
00123 
00124   /// Return TRUE if horizontally scrollable
00125   FXbool isHorizontalScrollable() const;
00126 
00127   /// Return TRUE if vertically scrollable
00128   FXbool isVerticalScrollable() const;
00129 
00130   /// Return a pointer to the horizontal scrollbar
00131   FXScrollBar* horizontalScrollBar() const { return horizontal; }
00132 
00133   /// Return a pointer to the vertical scrollbar
00134   FXScrollBar* verticalScrollBar() const { return vertical; }
00135 
00136   /// Return the current x-position
00137   FXint getXPosition() const { return pos_x; }
00138 
00139   /// Return the current y-position
00140   FXint getYPosition() const { return pos_y; }
00141 
00142   /// Set the current position
00143   void setPosition(FXint x,FXint y);
00144 
00145   /// Get the current position
00146   void getPosition(FXint& x,FXint& y) const { x=pos_x; y=pos_y; }
00147 
00148   /// Destructor
00149   virtual ~FXScrollArea();
00150   };
00151 
00152 }
00153 
00154 #endif

Copyright © 1997-2005 Jeroen van der Zijp