![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * S c r o l l B a r 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: FXScrollbar.h,v 1.17 2002/01/18 22:42:54 jeroen Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXSCROLLBAR_H 00025 #define FXSCROLLBAR_H 00026 00027 #ifndef FXWINDOW_H 00028 #include "FXWindow.h" 00029 #endif 00030 00031 00032 00033 struct FXTimer; 00034 00035 00036 /// Scrollbar styles 00037 enum { 00038 SCROLLBAR_HORIZONTAL = 0x00020000, /// Horizontally oriented 00039 SCROLLBAR_VERTICAL = 0 /// Vertically oriented 00040 }; 00041 00042 00043 00044 /** 00045 * The scroll bar is used when a document has a larger content than may be made 00046 * visible. The range is the total size of the document, the page is the part 00047 * of the document which is visible. The size of the scrollbar thumb is adjusted 00048 * to give feedback of the relative sizes of each. 00049 * The scroll bar may be manipulated by the left mouse (normal scrolling), right 00050 * mouse (vernier or fine-scrolling), or middle mouse (same as the left mouse only 00051 * the scroll position can hop to the place where the click is made). 00052 * Finally, if the mouse sports a wheel, the scroll bar can be manipulated by means 00053 * of the mouse wheel as well. Holding down the Control-key during wheel motion 00054 * will cause the scrolling to go faster than normal. 00055 * While moving the scroll bar, a message of type SEL_CHANGED will be sent to the 00056 * target, and the message data will reflect the current position of type FXint. 00057 * At the end of the interaction, the scroll bar will send a message of type 00058 * SEL_COMMAND to notify the target of the final position. 00059 */ 00060 class FXAPI FXScrollbar : public FXWindow { 00061 FXDECLARE(FXScrollbar) 00062 protected: 00063 FXint range; // Scrollable range 00064 FXint page; // Page size 00065 FXint line; // Line size 00066 FXint pos; // Position 00067 FXint thumbsize; // Thumb size 00068 FXint thumbpos; // Thumb position 00069 FXColor hiliteColor; // Hightlight color 00070 FXColor shadowColor; // Shadow color 00071 FXColor borderColor; // Border color 00072 FXTimer *timer; // Autoscroll timer 00073 FXint dragpoint; // Point where grabbed 00074 FXint dragjump; // Jump this much 00075 FXuchar pressed; // Action being undertaken 00076 protected: 00077 FXScrollbar(); 00078 void drawButton(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); 00079 void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); 00080 void drawRightArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); 00081 void drawUpArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); 00082 void drawDownArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); 00083 virtual void layout(); 00084 private: 00085 FXScrollbar(const FXScrollbar&); 00086 FXScrollbar &operator=(const FXScrollbar&); 00087 public: 00088 long onPaint(FXObject*,FXSelector,void*); 00089 long onMotion(FXObject*,FXSelector,void*); 00090 long onMouseWheel(FXObject*,FXSelector,void*); 00091 long onLeftBtnPress(FXObject*,FXSelector,void*); 00092 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00093 long onMiddleBtnPress(FXObject*,FXSelector,void*); 00094 long onMiddleBtnRelease(FXObject*,FXSelector,void*); 00095 long onRightBtnPress(FXObject*,FXSelector,void*); 00096 long onRightBtnRelease(FXObject*,FXSelector,void*); 00097 long onUngrabbed(FXObject*,FXSelector,void*); 00098 long onTimeIncPix(FXObject*,FXSelector,void*); 00099 long onTimeIncLine(FXObject*,FXSelector,void*); 00100 long onTimeIncPage(FXObject*,FXSelector,void*); 00101 long onTimeDecPix(FXObject*,FXSelector,void*); 00102 long onTimeDecLine(FXObject*,FXSelector,void*); 00103 long onTimeDecPage(FXObject*,FXSelector,void*); 00104 long onTimeWheel(FXObject*,FXSelector,void*); 00105 long onCmdSetValue(FXObject*,FXSelector,void*); 00106 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00107 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00108 long onCmdSetIntRange(FXObject*,FXSelector,void*); 00109 long onCmdGetIntRange(FXObject*,FXSelector,void*); 00110 public: 00111 enum{ 00112 ID_TIMEWHEEL=FXWindow::ID_LAST, 00113 ID_AUTOINC_LINE, 00114 ID_AUTODEC_LINE, 00115 ID_AUTOINC_PAGE, 00116 ID_AUTODEC_PAGE, 00117 ID_AUTOINC_PIX, 00118 ID_AUTODEC_PIX, 00119 ID_LAST 00120 }; 00121 public: 00122 00123 /// Construct scroll bar 00124 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); 00125 00126 /// Return default width 00127 virtual FXint getDefaultWidth(); 00128 00129 /// Return default height 00130 virtual FXint getDefaultHeight(); 00131 00132 /// Set content size range 00133 void setRange(FXint r); 00134 00135 /// Return content size range 00136 FXint getRange() const { return range; } 00137 00138 /// Set viewport page size 00139 void setPage(FXint p); 00140 00141 /// Return page size 00142 FXint getPage() const { return page; } 00143 00144 /// Set scoll increment for line 00145 void setLine(FXint l); 00146 00147 /// Return line increment 00148 FXint getLine() const { return line; } 00149 00150 /// Change current scroll position 00151 void setPosition(FXint p); 00152 00153 /// return scroll position 00154 FXint getPosition() const { return pos; } 00155 00156 /// Change highlight color 00157 void setHiliteColor(FXColor clr); 00158 00159 /// Return highlight color 00160 FXColor getHiliteColor() const { return hiliteColor; } 00161 00162 /// Change shadow color 00163 void setShadowColor(FXColor clr); 00164 00165 /// Return shadow color 00166 FXColor getShadowColor() const { return shadowColor; } 00167 00168 /// Change border color 00169 FXColor getBorderColor() const { return borderColor; } 00170 00171 /// Return border color 00172 void setBorderColor(FXColor clr); 00173 00174 /// Change the scrollbar style 00175 FXuint getScrollbarStyle() const; 00176 00177 /// Get the current scrollbar style 00178 void setScrollbarStyle(FXuint style); 00179 00180 /// Save to stream 00181 virtual void save(FXStream& store) const; 00182 00183 /// Load from stream 00184 virtual void load(FXStream& store); 00185 00186 /// Destructor 00187 virtual ~FXScrollbar(); 00188 }; 00189 00190 00191 /// Corner between scroll bars 00192 class FXAPI FXScrollCorner : public FXWindow { 00193 FXDECLARE(FXScrollCorner) 00194 protected: 00195 FXScrollCorner(); 00196 private: 00197 FXScrollCorner(const FXScrollCorner&); 00198 FXScrollCorner &operator=(const FXScrollCorner&); 00199 public: 00200 long onPaint(FXObject*,FXSelector,void*); 00201 public: 00202 00203 /// Constructor 00204 FXScrollCorner(FXComposite* p); 00205 00206 /// Can not be enabled 00207 virtual void enable(); 00208 00209 /// Can not be disabled 00210 virtual void disable(); 00211 }; 00212 00213 00214 #endif