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