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

FXRealSpinner.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * R e a l - V a l u e d S p i n n e r W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2003,2006 by Bill Baxter. 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: FXRealSpinner.h,v 1.16 2006/02/10 03:53:47 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXREALSPINNER_H
25 #define FXREALSPINNER_H
26 
27 #ifndef FXPACKER_H
28 #include "FXPacker.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// RealSpinner Options
35 enum {
36  REALSPIN_NORMAL = 0, /// Normal, non-cyclic
37  REALSPIN_CYCLIC = 0x00020000, /// Cyclic spinner
38  REALSPIN_NOTEXT = 0x00040000, /// No text visible
39  REALSPIN_NOMAX = 0x00080000, /// Spin all the way up to infinity
40  REALSPIN_NOMIN = 0x00100000, /// Spin all the way down to -infinity
41  REALSPIN_LOG = 0x00200000 /// Logarithmic rather than linear
42  };
43 
44 
45 class FXTextField;
46 class FXDial;
47 
48 
49 /// Spinner control
50 class FXAPI FXRealSpinner : public FXPacker {
52 protected:
53  FXTextField *textField; // Text field
54  FXArrowButton *upButton; // The up button
55  FXArrowButton *downButton; // The down button
56  FXdouble range[2]; // Reported data range
57  FXdouble incr; // Increment
58  FXdouble gran; // Granularity
59  FXdouble pos; // Current position
60 protected:
61  FXRealSpinner();
62 private:
63  FXRealSpinner(const FXRealSpinner&);
64  FXRealSpinner& operator=(const FXRealSpinner&);
65 public:
66  long onUpdIncrement(FXObject*,FXSelector,void*);
67  long onCmdIncrement(FXObject*,FXSelector,void*);
68  long onUpdDecrement(FXObject*,FXSelector,void*);
69  long onCmdDecrement(FXObject*,FXSelector,void*);
70  long onCmdEntry(FXObject*,FXSelector,void*);
71  long onChgEntry(FXObject*,FXSelector,void*);
72  long onWheelEntry(FXObject*,FXSelector,void*);
73  long onKeyPress(FXObject*,FXSelector,void*);
74  long onKeyRelease(FXObject*,FXSelector,void*);
75  long onCmdSetValue(FXObject*,FXSelector,void*);
76  long onCmdSetIntValue(FXObject*,FXSelector,void*);
77  long onCmdGetIntValue(FXObject*,FXSelector,void*);
78  long onCmdSetIntRange(FXObject*,FXSelector,void*);
79  long onCmdGetIntRange(FXObject*,FXSelector,void*);
80  long onCmdSetRealValue(FXObject*,FXSelector,void*);
81  long onCmdGetRealValue(FXObject*,FXSelector,void*);
82  long onCmdSetRealRange(FXObject*,FXSelector,void*);
83  long onCmdGetRealRange(FXObject*,FXSelector,void*);
84  long onFocusSelf(FXObject*,FXSelector,void*);
85 public:
86  enum{
87  ID_INCREMENT=FXPacker::ID_LAST,
88  ID_DECREMENT,
89  ID_ENTRY,
90  ID_LAST
91  };
92 public:
93 
94  /// Construct a spinner
96 
97  /// Perform layout
98  virtual void layout();
99 
100  /// Disable spinner
101  virtual void disable();
102 
103  /// Enable spinner
104  virtual void enable();
105 
106  /// Return default width
107  virtual FXint getDefaultWidth();
108 
109  /// Return default height
110  virtual FXint getDefaultHeight();
111 
112  /// Increment spinner
113  void increment(FXbool notify=FALSE);
114 
115  /// Increment spinner by certain amount
116  void incrementByAmount(FXdouble amount,FXbool notify=FALSE);
117 
118  /// Decrement spinner
119  void decrement(FXbool notify=FALSE);
120 
121  /// Decrement spinner by certain amount
122  void decrementByAmount(FXdouble amount, FXbool notify=FALSE);
123 
124  /// Return TRUE if in cyclic mode
125  FXbool isCyclic() const;
126 
127  /// Set to cyclic mode, i.e. wrap around at maximum/minimum
128  void setCyclic(FXbool cyclic);
129 
130  /// Return TRUE if text is visible
131  FXbool isTextVisible() const;
132 
133  /// Set text visible flag
134  void setTextVisible(FXbool shown);
136  /// Change current value
137  virtual void setValue(FXdouble value,FXbool notify=FALSE);
138 
139  /// Return current value
140  FXdouble getValue() const { return pos; }
142  /// Change the spinner's range
143  void setRange(FXdouble lo,FXdouble hi,FXbool notify=FALSE);
144 
145  /// Get the spinner's current range
146  void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; }
148  /// Change spinner increment
149  void setIncrement(FXdouble increment);
150 
151  /// Return spinner increment
152  FXdouble getIncrement() const { return incr; }
154  /// Change spinner granularity
155  void setGranularity(FXdouble gr);
156 
157  /// Return spinner granularity
158  FXdouble getGranularity() const { return gran; }
159 
160  /// Set the text font
161  void setFont(FXFont *fnt);
162 
163  /// Get the text font
164  FXFont *getFont() const;
165 
166  /// Set the status line help text for this spinner
167  void setHelpText(const FXString& text);
168 
169  /// Get the status line help text for this spinner
170  const FXString& getHelpText() const;
171 
172  /// Set the tool tip message for this spinner
173  void setTipText(const FXString& text);
174 
175  /// Get the tool tip message for this spinner
176  const FXString& getTipText() const;
177 
178  /// Change spinner style
179  void setSpinnerStyle(FXuint style);
180 
181  /// Return current spinner style
182  FXuint getSpinnerStyle() const;
183 
184  /// Allow editing of the text field
185  void setEditable(FXbool edit=TRUE);
186 
187  /// Return TRUE if text field is editable
188  FXbool isEditable() const;
189 
190  /// Change color of the up arrow
191  void setUpArrowColor(FXColor clr);
192 
193  /// Return color of the up arrow
194  FXColor getUpArrowColor() const;
195 
196  /// Change color of the down arrow
197  void setDownArrowColor(FXColor clr);
198 
199  /// Return color of the the down arrow
200  FXColor getDownArrowColor() const;
201 
202  /// Change text color
203  void setTextColor(FXColor clr);
204 
205  /// Return text color
206  FXColor getTextColor() const;
207 
208  /// Change selected background color
209  void setSelBackColor(FXColor clr);
210 
211  /// Return selected background color
212  FXColor getSelBackColor() const;
213 
214  /// Change selected text color
215  void setSelTextColor(FXColor clr);
216 
217  /// Return selected text color
218  FXColor getSelTextColor() const;
219 
220  /// Changes the cursor color
221  void setCursorColor(FXColor clr);
222 
223  /// Return the cursor color
224  FXColor getCursorColor() const;
225 
226  /// Change width of text field in terms of number of columns * `m'
227  void setNumColumns(FXint cols);
228 
229  /// Return number of columns
230  FXint getNumColumns() const;
231 
232  /// Save spinner to a stream
233  virtual void save(FXStream& store) const;
234 
235  /// Load spinner from a stream
236  virtual void load(FXStream& store);
237 
238  /// Destructor
239  virtual ~FXRealSpinner();
240  };
241 
242 }
243 
244 #endif
FXVec2d lo(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:174
Spinner control.
Definition: FXRealSpinner.h:58
#define TRUE
Definition: fxdefs.h:32
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:396
Definition: FXFrame.h:56
FXuint FXSelector
Association key.
Definition: FXObject.h:53
Spin all the way down to -infinity.
Definition: FXRealSpinner.h:43
No text visible.
Definition: FXRealSpinner.h:41
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
The Dial widget is a valuator widget which is able to provide a cyclic value range when the DIAL_CYCL...
Definition: FXDial.h:61
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:454
Spin all the way up to infinity.
Definition: FXRealSpinner.h:42
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
double FXdouble
Definition: fxdefs.h:399
int FXint
Definition: fxdefs.h:397
Packer is a layout manager which automatically places child windows inside its area against the left...
Definition: FXPacker.h:58
FXVec2d hi(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:175
A text field is a single-line text entry widget.
Definition: FXTextField.h:73
Cyclic spinner.
Definition: FXRealSpinner.h:40
#define FALSE
Definition: fxdefs.h:35
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
Normal, non-cyclic.
Definition: FXRealSpinner.h:39
Logarithmic rather than linear.
Definition: FXRealSpinner.h:44
Font class.
Definition: FXFont.h:142
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33
Button with an arrow; the arrow can point in any direction.
Definition: FXArrowButton.h:65

Copyright © 1997-2005 Jeroen van der Zijp