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

FXScrollBar.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * S c r o l l B a r W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXScrollBar.h,v 1.15 2006/01/22 17:58:09 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXSCROLLBAR_H
25 #define FXSCROLLBAR_H
26 
27 #ifndef FXWINDOW_H
28 #include "FXWindow.h"
29 #endif
30 
31 
32 namespace FX {
33 
34 
35 
36 /// ScrollBar styles
37 enum {
38  SCROLLBAR_VERTICAL = 0, /// Vertically oriented
39  SCROLLBAR_HORIZONTAL = 0x00020000, /// Horizontally oriented
40  SCROLLBAR_WHEELJUMP = 0x00040000 /// Mouse wheel jumps instead of sliding smoothly
41  };
42 
43 
44 
45 /**
46 * The scroll bar is used when a document has a larger content than may be made
47 * visible. The range is the total size of the document, the page is the part
48 * of the document which is visible. The size of the scrollbar thumb is adjusted
49 * to give feedback of the relative sizes of each.
50 * The scroll bar may be manipulated by the left mouse button (normal scrolling), by the
51 * middle mouse button (same as the left mouse only the scroll position can jump to the
52 * place where the click is made), or by the right mouse button (vernier- or fine-scrolling).
53 * Holding down the control key while scrolling with the left or middle mouse button also
54 * enables vernier-scrolling mode. The vernier-scrolling mode is very useful for accurate
55 * positioning in large documents.
56 * Finally, if the mouse sports a wheel, the scroll bar can be manipulated by means
57 * of the mouse wheel as well. Holding down the Control-key during wheel motion
58 * will cause the scrolling to go faster than normal.
59 * While moving the scroll bar, a message of type SEL_CHANGED will be sent to the
60 * target, and the message data will reflect the current position of type FXint.
61 * At the end of the interaction, the scroll bar will send a message of type
62 * SEL_COMMAND to notify the target of the final position.
63 */
64 class FXAPI FXScrollBar : public FXWindow {
66 protected:
67  FXint range; // Scrollable range
68  FXint page; // Page size
69  FXint line; // Line size
70  FXint pos; // Position
71  FXint barsize; // Bar size
72  FXint thumbsize; // Thumb size
73  FXint thumbpos; // Thumb position
74  FXColor hiliteColor; // Hightlight color
75  FXColor shadowColor; // Shadow color
76  FXColor borderColor; // Border color
77  FXColor arrowColor; // Arrow color
78  FXint dragpoint; // Point where grabbed
79  FXuchar mode; // Current mode of control
80 protected:
81  FXScrollBar();
82  void drawButton(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
83  void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
84  void drawRightArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
85  void drawUpArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
86  void drawDownArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down);
87 protected:
88  enum {
89  MODE_NONE,
90  MODE_INC,
91  MODE_DEC,
92  MODE_PAGE_INC,
93  MODE_PAGE_DEC,
94  MODE_DRAG,
95  MODE_FINE_DRAG
96  };
97 private:
98  FXScrollBar(const FXScrollBar&);
99  FXScrollBar &operator=(const FXScrollBar&);
100 public:
101  long onPaint(FXObject*,FXSelector,void*);
102  long onMotion(FXObject*,FXSelector,void*);
103  long onMouseWheel(FXObject*,FXSelector,void*);
104  long onLeftBtnPress(FXObject*,FXSelector,void*);
105  long onLeftBtnRelease(FXObject*,FXSelector,void*);
106  long onMiddleBtnPress(FXObject*,FXSelector,void*);
107  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
108  long onRightBtnPress(FXObject*,FXSelector,void*);
109  long onRightBtnRelease(FXObject*,FXSelector,void*);
110  long onUngrabbed(FXObject*,FXSelector,void*);
111  long onTimeWheel(FXObject*,FXSelector,void*);
112  long onAutoScroll(FXObject*,FXSelector,void*);
113  long onCmdSetValue(FXObject*,FXSelector,void*);
114  long onCmdSetIntValue(FXObject*,FXSelector,void*);
115  long onCmdGetIntValue(FXObject*,FXSelector,void*);
116  long onCmdSetIntRange(FXObject*,FXSelector,void*);
117  long onCmdGetIntRange(FXObject*,FXSelector,void*);
118 public:
119  enum{
120  ID_TIMEWHEEL=FXWindow::ID_LAST,
121  ID_AUTOSCROLL,
122  ID_LAST
123  };
124 public:
125 
126  /// Construct scroll bar
128 
129  /// Return default width
130  virtual FXint getDefaultWidth();
131 
132  /// Return default height
133  virtual FXint getDefaultHeight();
134 
135  /// Perform layout
136  virtual void layout();
137 
138  /// Set content size range
139  void setRange(FXint r);
140 
141  /// Return content size range
142  FXint getRange() const { return range; }
143 
144  /// Set viewport page size
145  void setPage(FXint p);
146 
147  /// Return page size
148  FXint getPage() const { return page; }
149 
150  /// Set scoll increment for line
151  void setLine(FXint l);
152 
153  /// Return line increment
154  FXint getLine() const { return line; }
155 
156  /// Change scroll position
157  void setPosition(FXint p);
158 
159  /// Return current scroll position
160  FXint getPosition() const { return pos; }
161 
162  /// Change highlight color
163  void setHiliteColor(FXColor clr);
164 
165  /// Return highlight color
166  FXColor getHiliteColor() const { return hiliteColor; }
167 
168  /// Change the shadow color
169  void setShadowColor(FXColor clr);
170 
171  /// Return the shadow color
172  FXColor getShadowColor() const { return shadowColor; }
173 
174  /// Change the border color
175  void setBorderColor(FXColor clr);
176 
177  /// Return the border color
178  FXColor getBorderColor() const { return borderColor; }
179 
180  /// Change the arrow color
181  void setArrowColor(FXColor clr);
182 
183  /// Return the arrow color
184  FXColor getArrowColor() const { return arrowColor; }
185 
186  /// Change the scrollbar style
187  void setScrollBarStyle(FXuint style);
188 
189  /// Return the scrollbar style
190  FXuint getScrollBarStyle() const;
191 
192  /// Change the bar size
193  void setBarSize(FXint size);
194 
195  /// Return the bar size
196  FXint getBarSize() const { return barsize; }
197 
198  /// Save to stream
199  virtual void save(FXStream& store) const;
200 
201  /// Load from stream
202  virtual void load(FXStream& store);
203 
204  /// Destructor
205  virtual ~FXScrollBar();
206  };
207 
208 
209 /// Corner between scroll bars
210 class FXAPI FXScrollCorner : public FXWindow {
211  FXDECLARE(FXScrollCorner)
212 protected:
213  FXScrollCorner();
214 private:
215  FXScrollCorner(const FXScrollCorner&);
216  FXScrollCorner &operator=(const FXScrollCorner&);
217 public:
218  long onPaint(FXObject*,FXSelector,void*);
219 public:
220 
221  /// Constructor
222  FXScrollCorner(FXComposite* p);
223 
224  /// Can not be enabled
225  virtual void enable();
226 
227  /// Can not be disabled
228  virtual void disable();
229  };
230 
231 }
232 
233 #endif
Vertically oriented.
Definition: FXScrollBar.h:41
Base class for all windows.
Definition: FXWindow.h:115
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:396
FXuint FXSelector
Association key.
Definition: FXObject.h:53
The scroll bar is used when a document has a larger content than may be made visible.
Definition: FXScrollBar.h:71
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:454
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
Mouse wheel jumps instead of sliding smoothly.
Definition: FXScrollBar.h:43
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
unsigned char FXuchar
Definition: fxdefs.h:392
Window Device Context.
Definition: FXDCWindow.h:52
Horizontally oriented.
Definition: FXScrollBar.h:42
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92

Copyright © 1997-2005 Jeroen van der Zijp