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

FXRuler.h
1 /********************************************************************************
2 * *
3 * R u l e r W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2002,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXRULER_H
22 #define FXRULER_H
23 
24 #ifndef FXFRAME_H
25 #include "FXFrame.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum {
33  RULER_NORMAL = 0,
34  RULER_HORIZONTAL = 0,
35  RULER_VERTICAL = 0x00008000,
36  RULER_TICKS_OFF = 0,
37  RULER_TICKS_TOP = 0x00010000,
38  RULER_TICKS_BOTTOM = 0x00020000,
39  RULER_TICKS_LEFT = RULER_TICKS_TOP,
40  RULER_TICKS_RIGHT = RULER_TICKS_BOTTOM,
41  RULER_TICKS_CENTER = RULER_TICKS_TOP|RULER_TICKS_BOTTOM,
42  RULER_NUMBERS = 0x00040000,
43  RULER_ARROW = 0x00080000,
44  RULER_MARKERS = 0x00100000,
45  RULER_METRIC = 0,
46  RULER_ENGLISH = 0x00200000,
47  RULER_MARGIN_ADJUST = 0x00400000,
48  RULER_ALIGN_CENTER = 0,
49  RULER_ALIGN_LEFT = 0x00800000,
50  RULER_ALIGN_RIGHT = 0x01000000,
51  RULER_ALIGN_TOP = RULER_ALIGN_LEFT,
52  RULER_ALIGN_BOTTOM = RULER_ALIGN_RIGHT,
53  RULER_ALIGN_STRETCH = RULER_ALIGN_LEFT|RULER_ALIGN_RIGHT,
54  RULER_ALIGN_NORMAL = RULER_ALIGN_CENTER
55  };
56 
57 
58 class FXFont;
59 
60 
75 class FXAPI FXRuler : public FXFrame {
76  FXDECLARE(FXRuler)
77 protected:
78  FXFont *font; // Font for numbers
79  FXint documentSize; // Size of document
80  FXint edgeSpacing; // Edge spacing around document
81  FXint marginLower; // Lower margin
82  FXint marginUpper; // Upper margin
83  FXint indentFirst; // First line paragraph indent
84  FXint indentLower; // Lower paragraph indent
85  FXint indentUpper; // Upper paragraph indent
86  FXdouble pixelPerTick; // Number of pixels per tick increment
87  FXint numberTicks; // Tick increments between numbers
88  FXint majorTicks; // Tick increments between major ticks
89  FXint mediumTicks; // Tick increments between medium ticks
90  FXint tinyTicks; // Tick increments between tiny ticks
91  FXint arrowPos; // Arrow position
92  FXColor textColor; // Color for numbers and ticks
93  FXint shift; // Left edge of content
94  FXint pos; // Scroll position
95  FXint off; // Offset item was grabbed
96  FXString tip; // Tooltip text
97  FXString help; // Help text
98  FXuchar mode; // Mode widget is in
99 protected:
100  FXRuler();
101  FXint picked(FXint x,FXint y);
102  void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y);
103  void drawRightArrow(FXDCWindow& dc,FXint x,FXint y);
104  void drawUpArrow(FXDCWindow& dc,FXint x,FXint y);
105  void drawDownArrow(FXDCWindow& dc,FXint x,FXint y);
106  void drawLeftMarker(FXDCWindow& dc,FXint x,FXint y);
107  void drawRightMarker(FXDCWindow& dc,FXint x,FXint y);
108  void drawUpMarker(FXDCWindow& dc,FXint x,FXint y);
109  void drawDownMarker(FXDCWindow& dc,FXint x,FXint y);
110 protected:
111  enum{
112  MOUSE_NONE, // No mouse operation
113  MOUSE_MARG_LOWER, // Drag lower margin
114  MOUSE_MARG_UPPER, // Drag upper margin
115  MOUSE_PARA_FIRST, // Drag first indent
116  MOUSE_PARA_LOWER, // Drag lower indent
117  MOUSE_PARA_UPPER // Drag upper indent
118  };
119 private:
120  FXRuler(const FXRuler&);
121  FXRuler &operator=(const FXRuler&);
122 public:
123  long onPaint(FXObject*,FXSelector,void*);
124  long onLeftBtnPress(FXObject*,FXSelector,void*);
125  long onLeftBtnRelease(FXObject*,FXSelector,void*);
126  long onMotion(FXObject*,FXSelector,void*);
127  long onCmdSetValue(FXObject*,FXSelector,void*);
128  long onCmdSetIntValue(FXObject*,FXSelector,void*);
129  long onCmdGetIntValue(FXObject*,FXSelector,void*);
130  long onCmdSetHelp(FXObject*,FXSelector,void*);
131  long onCmdGetHelp(FXObject*,FXSelector,void*);
132  long onCmdSetTip(FXObject*,FXSelector,void*);
133  long onCmdGetTip(FXObject*,FXSelector,void*);
134  long onQueryHelp(FXObject*,FXSelector,void*);
135  long onQueryTip(FXObject*,FXSelector,void*);
136 public:
137  enum{
138  ID_ARROW=FXFrame::ID_LAST,
139  ID_LAST
140  };
141 public:
142 
144  FXRuler(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=RULER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
145 
147  virtual void layout();
148 
150  virtual void create();
151 
153  virtual void detach();
154 
156  virtual FXint getDefaultWidth();
157 
159  virtual FXint getDefaultHeight();
160 
162  void setPosition(FXint pos,FXbool notify=false);
163 
165  FXint getPosition() const { return pos; }
166 
168  void setContentSize(FXint size,FXbool notify=false);
169  FXint getContentSize() const;
170 
172  FXint getDocumentLower() const;
173 
175  FXint getDocumentUpper() const;
176 
178  void setDocumentSize(FXint size,FXbool notify=false);
179  FXint getDocumentSize() const { return documentSize; }
180 
182  void setEdgeSpacing(FXint space,FXbool notify=false);
183  FXint getEdgeSpacing() const { return edgeSpacing; }
184 
186  void setMarginLower(FXint mgn,FXbool notify=false);
187  FXint getMarginLower() const { return marginLower; }
188 
190  void setMarginUpper(FXint mgn,FXbool notify=false);
191  FXint getMarginUpper() const { return marginUpper; }
192 
194  void setIndentFirst(FXint ind,FXbool notify=false);
195  FXint getIndentFirst() const { return indentFirst; }
196 
198  void setIndentLower(FXint ind,FXbool notify=false);
199  FXint getIndentLower() const { return indentLower; }
200 
202  void setIndentUpper(FXint ind,FXbool notify=false);
203  FXint getIndentUpper() const { return indentUpper; }
204 
206  void setNumberTicks(FXint ticks,FXbool notify=false);
207  FXint getNumberTicks() const { return numberTicks; }
208 
210  void setMajorTicks(FXint ticks,FXbool notify=false);
211  FXint getMajorTicks() const { return majorTicks; }
212 
214  void setMediumTicks(FXint ticks,FXbool notify=false);
215  FXint getMediumTicks() const { return mediumTicks; }
216 
218  void setTinyTicks(FXint ticks,FXbool notify=false);
219  FXint getTinyTicks() const { return tinyTicks; }
220 
222  void setPixelPerTick(FXdouble space,FXbool notify=false);
223  FXdouble getPixelPerTick() const { return pixelPerTick; }
224 
226  void setFont(FXFont *fnt,FXbool notify=false);
227 
229  FXFont* getFont() const { return font; }
230 
232  void setValue(FXint value);
233 
235  FXint getValue() const { return arrowPos; }
236 
238  void setRulerStyle(FXuint style);
239 
241  FXuint getRulerStyle() const;
242 
244  void setRulerAlignment(FXuint alignment,FXbool notify=false);
245 
247  FXuint getRulerAlignment() const;
248 
250  FXColor getTextColor() const { return textColor; }
251 
253  void setTextColor(FXColor clr);
254 
256  void setHelpText(const FXString& text){ help=text; }
257 
259  const FXString& getHelpText() const { return help; }
260 
262  void setTipText(const FXString& text){ tip=text; }
263 
265  const FXString& getTipText() const { return tip; }
266 
268  virtual void save(FXStream& store) const;
269 
271  virtual void load(FXStream& store);
272 
274  virtual ~FXRuler();
275  };
276 
277 }
278 
279 #endif
void setTipText(const FXString &text)
Set the tool tip message for the ruler.
Definition: FXRuler.h:262
The ruler widget is placed alongside a document to measure position and size of entities within the d...
Definition: FXRuler.h:75
FXColor getTextColor() const
Get the current text color.
Definition: FXRuler.h:250
FXint getPosition() const
Return the current position.
Definition: FXRuler.h:165
The Frame widget provides borders around some contents.
Definition: FXFrame.h:58
FXFont * getFont() const
Get the text font.
Definition: FXRuler.h:229
const FXString & getHelpText() const
Get the status line help text for the ruler.
Definition: FXRuler.h:259
Base composite.
Definition: FXComposite.h:32
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
void setHelpText(const FXString &text)
Set the status line help text for the ruler.
Definition: FXRuler.h:256
Definition: FX4Splitter.h:28
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:138
Window Device Context.
Definition: FXDCWindow.h:48
FXint getValue() const
Return arrow value in document.
Definition: FXRuler.h:235
const FXString & getTipText() const
Get the tool tip message for the ruler.
Definition: FXRuler.h:265
Font class.
Definition: FXFont.h:137
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp