![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
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,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: FXScrollArea.h,v 1.45 2009/01/06 13:07:27 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXSCROLLAREA_H 00024 #define FXSCROLLAREA_H 00025 00026 #ifndef FXCOMPOSITE_H 00027 #include "FXComposite.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /// Scrollbar options 00034 enum { 00035 SCROLLERS_NORMAL = 0, /// Show the scrollbars when needed 00036 HSCROLLER_ALWAYS = 0x00008000, /// Always show horizontal scrollers 00037 HSCROLLER_NEVER = 0x00010000, /// Never show horizontal scrollers 00038 VSCROLLER_ALWAYS = 0x00020000, /// Always show vertical scrollers 00039 VSCROLLER_NEVER = 0x00040000, /// Never show vertical scrollers 00040 HSCROLLING_ON = 0, /// Horizontal scrolling turned on (default) 00041 HSCROLLING_OFF = HSCROLLER_NEVER|HSCROLLER_ALWAYS, /// Horizontal scrolling turned off 00042 VSCROLLING_ON = 0, /// Vertical scrolling turned on (default) 00043 VSCROLLING_OFF = VSCROLLER_NEVER|VSCROLLER_ALWAYS, /// Vertical scrolling turned off 00044 SCROLLERS_TRACK = 0, /// Scrollers track continuously for smooth scrolling 00045 SCROLLERS_DONT_TRACK = 0x00080000 /// Scrollers don't track continuously 00046 }; 00047 00048 00049 class FXScrollBar; 00050 class FXScrollCorner; 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; // Horizontal scroll bar 00071 FXScrollBar *vertical; // Vertical scroll bar 00072 FXScrollCorner *corner; // Scroll corner 00073 FXint pos_x; // X scroll position (pos_x<=0) 00074 FXint pos_y; // Y scroll position (pos_y<=0) 00075 protected: 00076 FXScrollArea(); 00077 FXScrollArea(FXComposite* p,FXuint opts,FXint x,FXint y,FXint w,FXint h); 00078 virtual void moveContents(FXint x,FXint y); 00079 FXbool startAutoScroll(FXEvent *event,FXbool onlywheninside=false); 00080 void stopAutoScroll(); 00081 void placeScrollBars(FXint vw,FXint vh); 00082 private: 00083 FXScrollArea(const FXScrollArea&); 00084 FXScrollArea &operator=(const FXScrollArea&); 00085 public: 00086 long onHMouseWheel(FXObject*,FXSelector,void*); 00087 long onVMouseWheel(FXObject*,FXSelector,void*); 00088 long onHScrollerChanged(FXObject*,FXSelector,void*); 00089 long onVScrollerChanged(FXObject*,FXSelector,void*); 00090 long onHScrollerDragged(FXObject*,FXSelector,void*); 00091 long onVScrollerDragged(FXObject*,FXSelector,void*); 00092 long onAutoScroll(FXObject*,FXSelector,void*); 00093 public: 00094 00095 /// Return default width 00096 virtual FXint getDefaultWidth(); 00097 00098 /// Return default height 00099 virtual FXint getDefaultHeight(); 00100 00101 /// Perform layout 00102 virtual void layout(); 00103 00104 /// Return content area x position 00105 FXint getContentX() const { return pos_x; } 00106 00107 /// Return content area y position 00108 FXint getContentY() const { return pos_y; } 00109 00110 /// Return content area width 00111 virtual FXint getContentWidth(); 00112 00113 /// Return content area height 00114 virtual FXint getContentHeight(); 00115 00116 /// Return visible scroll-area x position 00117 virtual FXint getVisibleX() const; 00118 00119 /// Return visible scroll-area y position 00120 virtual FXint getVisibleY() const; 00121 00122 /// Return visible scroll-area width 00123 virtual FXint getVisibleWidth() const; 00124 00125 /// Return visible scroll-area height 00126 virtual FXint getVisibleHeight() const; 00127 00128 /// Return true if horizontally scrollable 00129 FXbool isHorizontalScrollable() const; 00130 00131 /// Return true if vertically scrollable 00132 FXbool isVerticalScrollable() const; 00133 00134 /// Change scroll style 00135 void setScrollStyle(FXuint style); 00136 00137 /// Return scroll style 00138 FXuint getScrollStyle() const; 00139 00140 /// Return a pointer to the horizontal scrollbar 00141 FXScrollBar* horizontalScrollBar() const { return horizontal; } 00142 00143 /// Return a pointer to the vertical scrollbar 00144 FXScrollBar* verticalScrollBar() const { return vertical; } 00145 00146 /// Set the current position 00147 void setPosition(FXint x,FXint y); 00148 00149 /// Get the current position 00150 void getPosition(FXint& x,FXint& y) const { x=pos_x; y=pos_y; } 00151 00152 /// Save to a stream 00153 virtual void save(FXStream& store) const; 00154 00155 /// Load from a stream 00156 virtual void load(FXStream& store); 00157 00158 /// Destructor 00159 virtual ~FXScrollArea(); 00160 }; 00161 00162 } 00163 00164 #endif
![]() |