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

FXRuler.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * R u l e r W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2002,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: FXRuler.h,v 1.36 2006/01/28 20:30:21 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXRULER_H
25 #define FXRULER_H
26 
27 #ifndef FXFRAME_H
28 #include "FXFrame.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Ruler options
35 enum {
36  RULER_NORMAL = 0, /// Default appearance (default)
37  RULER_HORIZONTAL = 0, /// Ruler is horizontal (default)
38  RULER_VERTICAL = 0x00008000, /// Ruler is vertical
39  RULER_TICKS_OFF = 0, /// Tick marks off (default)
40  RULER_TICKS_TOP = 0x00010000, /// Ticks on the top (if horizontal)
41  RULER_TICKS_BOTTOM = 0x00020000, /// Ticks on the bottom (if horizontal)
42  RULER_TICKS_LEFT = RULER_TICKS_TOP, /// Ticks on the left (if vertical)
43  RULER_TICKS_RIGHT = RULER_TICKS_BOTTOM, /// Ticks on the right (if vertical)
45  RULER_NUMBERS = 0x00040000, /// Show numbers
46  RULER_ARROW = 0x00080000, /// Draw small arrow for cursor position
47  RULER_MARKERS = 0x00100000, /// Draw markers for indentation settings
48  RULER_METRIC = 0, /// Metric subdivision (default)
49  RULER_ENGLISH = 0x00200000, /// English subdivision
50  RULER_MARGIN_ADJUST = 0x00400000, /// Allow margin adjustment
51  RULER_ALIGN_CENTER = 0, /// Center document horizontally
52  RULER_ALIGN_LEFT = 0x00800000, /// Align document to the left
53  RULER_ALIGN_RIGHT = 0x01000000, /// Align document to the right
54  RULER_ALIGN_TOP = RULER_ALIGN_LEFT, /// Align document to the top
55  RULER_ALIGN_BOTTOM = RULER_ALIGN_RIGHT, /// Align document to the bottom
56  RULER_ALIGN_STRETCH = RULER_ALIGN_LEFT|RULER_ALIGN_RIGHT, /// Stretch document to fit horizontally
57  RULER_ALIGN_NORMAL = RULER_ALIGN_CENTER /// Normally, document is centered both ways
58  };
59 
60 
61 class FXFont;
62 
63 
64 /**
65 * The ruler widget is placed alongside a document to measure position
66 * and size of entities within the document, such as margins, paragraph
67 * indents, and tickmarks.
68 * The ruler widget sends a SEL_CHANGED when the indentation or margins
69 * are interactively changed by the user.
70 * If the document size exceeds the available space, it is possible to
71 * scroll the document using setPosition(). When the document size is
72 * less than the available space, the alignment options can be used to
73 * center, left-adjust, or right-adjust the document.
74 * Finally, a special option exists to stretch the document to the
75 * available space, that is to say, the document will always be fitten
76 * with given left and right edges substracted from the available space.
77 */
78 class FXAPI FXRuler : public FXFrame {
80 protected:
81  FXFont *font; // Font for numbers
82  FXint documentSize; // Size of document
83  FXint edgeSpacing; // Edge spacing around document
84  FXint marginLower; // Lower margin
85  FXint marginUpper; // Upper margin
86  FXint indentFirst; // First line paragraph indent
87  FXint indentLower; // Lower paragraph indent
88  FXint indentUpper; // Upper paragraph indent
89  FXdouble pixelPerTick; // Number of pixels per tick increment
90  FXint numberTicks; // Tick increments between numbers
91  FXint majorTicks; // Tick increments between major ticks
92  FXint mediumTicks; // Tick increments between medium ticks
93  FXint tinyTicks; // Tick increments between tiny ticks
94  FXint arrowPos; // Arrow position
95  FXColor textColor; // Color for numbers and ticks
96  FXint shift; // Left edge of content
97  FXint pos; // Scroll position
98  FXint off; // Offset item was grabbed
99  FXString tip; // Tooltip text
100  FXString help; // Help text
101  FXuchar mode; // Mode widget is in
102 protected:
104  FXint picked(FXint x,FXint y);
105  void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y);
106  void drawRightArrow(FXDCWindow& dc,FXint x,FXint y);
107  void drawUpArrow(FXDCWindow& dc,FXint x,FXint y);
108  void drawDownArrow(FXDCWindow& dc,FXint x,FXint y);
109  void drawLeftMarker(FXDCWindow& dc,FXint x,FXint y);
110  void drawRightMarker(FXDCWindow& dc,FXint x,FXint y);
111  void drawUpMarker(FXDCWindow& dc,FXint x,FXint y);
112  void drawDownMarker(FXDCWindow& dc,FXint x,FXint y);
113 protected:
114  enum{
115  MOUSE_NONE, // No mouse operation
116  MOUSE_MARG_LOWER, // Drag lower margin
117  MOUSE_MARG_UPPER, // Drag upper margin
118  MOUSE_PARA_FIRST, // Drag first indent
119  MOUSE_PARA_LOWER, // Drag lower indent
120  MOUSE_PARA_UPPER // Drag upper indent
121  };
122 private:
123  FXRuler(const FXRuler&);
124  FXRuler &operator=(const FXRuler&);
125 public:
126  long onPaint(FXObject*,FXSelector,void*);
127  long onLeftBtnPress(FXObject*,FXSelector,void*);
128  long onLeftBtnRelease(FXObject*,FXSelector,void*);
129  long onMotion(FXObject*,FXSelector,void*);
130  long onCmdSetValue(FXObject*,FXSelector,void*);
131  long onCmdSetIntValue(FXObject*,FXSelector,void*);
132  long onCmdGetIntValue(FXObject*,FXSelector,void*);
133  long onCmdSetHelp(FXObject*,FXSelector,void*);
134  long onCmdGetHelp(FXObject*,FXSelector,void*);
135  long onCmdSetTip(FXObject*,FXSelector,void*);
136  long onCmdGetTip(FXObject*,FXSelector,void*);
137  long onQueryHelp(FXObject*,FXSelector,void*);
138  long onQueryTip(FXObject*,FXSelector,void*);
139 public:
140  enum{
141  ID_ARROW=FXFrame::ID_LAST,
142  ID_LAST
143  };
144 public:
145 
146  /// Construct label with given text and icon
149  /// Perform layout
150  virtual void layout();
151 
152  /// Create server-side resources
153  virtual void create();
154 
155  /// Detach server-side resources
156  virtual void detach();
157 
158  /// Return default width
159  virtual FXint getDefaultWidth();
161  /// Return default height
162  virtual FXint getDefaultHeight();
163 
164  /// Set the current position
165  void setPosition(FXint pos,FXbool notify=FALSE);
166 
167  /// Return the current position
168  FXint getPosition() const { return pos; }
169 
170  /// Change/return content size
171  void setContentSize(FXint size,FXbool notify=FALSE);
172  FXint getContentSize() const;
173 
174  /// Get lower edge of document
175  FXint getDocumentLower() const;
177  /// Get upper edge of document
178  FXint getDocumentUpper() const;
179 
180  /// Change/return document size
181  void setDocumentSize(FXint size,FXbool notify=FALSE);
182  FXint getDocumentSize() const { return documentSize; }
183 
184  /// Change/return document edge spacing
185  void setEdgeSpacing(FXint space,FXbool notify=FALSE);
186  FXint getEdgeSpacing() const { return edgeSpacing; }
187 
188  /// Change/return lower document margin
189  void setMarginLower(FXint mgn,FXbool notify=FALSE);
190  FXint getMarginLower() const { return marginLower; }
191 
192  /// Change/return upper document margin
193  void setMarginUpper(FXint mgn,FXbool notify=FALSE);
194  FXint getMarginUpper() const { return marginUpper; }
195 
196  /// Change/return first line indent
197  void setIndentFirst(FXint ind,FXbool notify=FALSE);
198  FXint getIndentFirst() const { return indentFirst; }
199 
200  /// Change/return lower indent
201  void setIndentLower(FXint ind,FXbool notify=FALSE);
202  FXint getIndentLower() const { return indentLower; }
203 
204  /// Change/return upper indent
205  void setIndentUpper(FXint ind,FXbool notify=FALSE);
206  FXint getIndentUpper() const { return indentUpper; }
207 
208  /// Change/return document number placement
209  void setNumberTicks(FXint ticks,FXbool notify=FALSE);
210  FXint getNumberTicks() const { return numberTicks; }
211 
212  /// Change/return document major ticks
213  void setMajorTicks(FXint ticks,FXbool notify=FALSE);
214  FXint getMajorTicks() const { return majorTicks; }
216  /// Change/return document medium ticks
217  void setMediumTicks(FXint ticks,FXbool notify=FALSE);
218  FXint getMediumTicks() const { return mediumTicks; }
219 
220  /// Change/return document tiny ticks
221  void setTinyTicks(FXint ticks,FXbool notify=FALSE);
222  FXint getTinyTicks() const { return tinyTicks; }
223 
224  /// Change/return pixel per tick spacing
225  void setPixelPerTick(FXdouble space,FXbool notify=FALSE);
226  FXdouble getPixelPerTick() const { return pixelPerTick; }
228  /// Set the text font
229  void setFont(FXFont *fnt,FXbool notify=FALSE);
231  /// Get the text font
232  FXFont* getFont() const { return font; }
233 
234  /// Change arrow value, relative to document position
235  void setValue(FXint value);
236 
237  /// Return arrow value in document
238  FXint getValue() const { return arrowPos; }
239 
240  /// Set ruler style
241  void setRulerStyle(FXuint style);
242 
243  /// Get ruler style
244  FXuint getRulerStyle() const;
245 
246  /// Set ruler alignment
247  void setRulerAlignment(FXuint alignment,FXbool notify=FALSE);
248 
249  /// Get ruler alignment
250  FXuint getRulerAlignment() const;
251 
252  /// Get the current text color
253  FXColor getTextColor() const { return textColor; }
254 
255  /// Set the current text color
256  void setTextColor(FXColor clr);
257 
258  /// Set the status line help text for the ruler
259  void setHelpText(const FXString& text){ help=text; }
260 
261  /// Get the status line help text for the ruler
262  const FXString& getHelpText() const { return help; }
263 
264  /// Set the tool tip message for the ruler
265  void setTipText(const FXString& text){ tip=text; }
266 
267  /// Get the tool tip message for the ruler
268  const FXString& getTipText() const { return tip; }
269 
270  /// Save label to a stream
271  virtual void save(FXStream& store) const;
272 
273  /// Load label from a stream
274  virtual void load(FXStream& store);
275 
276  /// Destructor
277  virtual ~FXRuler();
278  };
279 
280 }
281 
282 #endif
Align document to the bottom.
Definition: FXRuler.h:58
Align document to the left.
Definition: FXRuler.h:55
Ruler is vertical.
Definition: FXRuler.h:41
Ruler is horizontal (default)
Definition: FXRuler.h:40
The ruler widget is placed alongside a document to measure position and size of entities within the d...
Definition: FXRuler.h:85
The Frame widget provides borders around some contents.
Definition: FXFrame.h:73
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:389
Align document to the top.
Definition: FXRuler.h:57
Definition: FXFrame.h:56
FXuint FXSelector
Association key.
Definition: FXObject.h:53
Align document to the right.
Definition: FXRuler.h:56
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:386
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:447
Metric subdivision (default)
Definition: FXRuler.h:51
Show numbers.
Definition: FXRuler.h:48
Normally, document is centered both ways.
Definition: FXRuler.h:60
Tickmarks centered.
Definition: FXRuler.h:47
double FXdouble
Definition: fxdefs.h:392
Center document horizontally.
Definition: FXRuler.h:54
Allow margin adjustment.
Definition: FXRuler.h:53
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
Draw markers for indentation settings.
Definition: FXRuler.h:50
Ticks on the bottom (if horizontal)
Definition: FXRuler.h:44
Ticks on the top (if horizontal)
Definition: FXRuler.h:43
English subdivision.
Definition: FXRuler.h:52
#define FALSE
Definition: fxdefs.h:35
Ticks on the left (if vertical)
Definition: FXRuler.h:45
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:385
Window Device Context.
Definition: FXDCWindow.h:52
Default appearance (default)
Definition: FXRuler.h:39
Tick marks off (default)
Definition: FXRuler.h:42
Stretch document to fit horizontally.
Definition: FXRuler.h:59
Font class.
Definition: FXFont.h:142
Ticks on the right (if vertical)
Definition: FXRuler.h:46
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33
Draw small arrow for cursor position.
Definition: FXRuler.h:49

Copyright © 1997-2005 Jeroen van der Zijp