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

FXSpinner.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * S p i n B u t t o n W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Lyle Johnson. 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: FXSpinner.h,v 1.46 2006/02/06 03:03:40 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXSPINNER_H
25 #define FXSPINNER_H
26 
27 #ifndef FXPACKER_H
28 #include "FXPacker.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Spinner Options
35 enum {
36  SPIN_NORMAL = 0, /// Normal, non-cyclic
37  SPIN_CYCLIC = 0x00020000, /// Cyclic spinner
38  SPIN_NOTEXT = 0x00040000, /// No text visible
39  SPIN_NOMAX = 0x00080000, /// Spin all the way up to infinity
40  SPIN_NOMIN = 0x00100000 /// Spin all the way down to -infinity
41  };
42 
43 
44 class FXTextField;
45 class FXArrowButton;
46 
47 
48 /// Spinner control
49 class FXAPI FXSpinner : public FXPacker {
51 protected:
52  FXTextField *textField; // Text field
53  FXArrowButton *upButton; // The up button
54  FXArrowButton *downButton; // The down button
55  FXint range[2]; // Reported data range
56  FXint incr; // Increment
57  FXint pos; // Current position
58 protected:
59  FXSpinner();
60 private:
61  FXSpinner(const FXSpinner&);
62  FXSpinner& operator=(const FXSpinner&);
63 public:
64  long onUpdIncrement(FXObject*,FXSelector,void*);
65  long onCmdIncrement(FXObject*,FXSelector,void*);
66  long onUpdDecrement(FXObject*,FXSelector,void*);
67  long onCmdDecrement(FXObject*,FXSelector,void*);
68  long onCmdEntry(FXObject*,FXSelector,void*);
69  long onChgEntry(FXObject*,FXSelector,void*);
70  long onWheelEntry(FXObject*,FXSelector,void*);
71  long onKeyPress(FXObject*,FXSelector,void*);
72  long onKeyRelease(FXObject*,FXSelector,void*);
73  long onCmdSetValue(FXObject*,FXSelector,void*);
74  long onCmdSetIntValue(FXObject*,FXSelector,void*);
75  long onCmdGetIntValue(FXObject*,FXSelector,void*);
76  long onCmdSetIntRange(FXObject*,FXSelector,void*);
77  long onCmdGetIntRange(FXObject*,FXSelector,void*);
78  long onFocusSelf(FXObject*,FXSelector,void*);
79 public:
80  enum{
81  ID_INCREMENT=FXPacker::ID_LAST,
82  ID_DECREMENT,
83  ID_ENTRY,
84  ID_LAST
85  };
86 public:
87 
88  /// Construct a spinner
90 
91  /// Perform layout
92  virtual void layout();
93 
94  /// Disable spinner
95  virtual void disable();
96 
97  /// Enable spinner
98  virtual void enable();
99 
100  /// Return default width
101  virtual FXint getDefaultWidth();
102 
103  /// Return default height
104  virtual FXint getDefaultHeight();
105 
106  /// Increment spinner
107  void increment(FXbool notify=FALSE);
108 
109  /// Increment spinner by certain amount
110  void incrementByAmount(FXint amount,FXbool notify=FALSE);
111 
112  /// Decrement spinner
113  void decrement(FXbool notify=FALSE);
114 
115  /// Decrement spinner by certain amount
116  void decrementByAmount(FXint amount, FXbool notify=FALSE);
117 
118  /// Return TRUE if in cyclic mode
119  FXbool isCyclic() const;
120 
121  /// Set to cyclic mode, i.e. wrap around at maximum/minimum
122  void setCyclic(FXbool cyclic);
123 
124  /// Return TRUE if text is visible
125  FXbool isTextVisible() const;
126 
127  /// Set text visible flag
128  void setTextVisible(FXbool shown);
129 
130  /// Change current value
131  virtual void setValue(FXint value,FXbool notify=FALSE);
132 
133  /// Return current value
134  FXint getValue() const { return pos; }
135 
136  /// Change the spinner's range
137  void setRange(FXint lo,FXint hi,FXbool notify=FALSE);
138 
139  /// Get the spinner's current range
140  void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; }
141 
142  /// Change spinner increment
143  void setIncrement(FXint increment);
144 
145  /// Return spinner increment
146  FXint getIncrement() const { return incr; }
147 
148  /// Set the text font
149  void setFont(FXFont *fnt);
150 
151  /// Get the text font
152  FXFont *getFont() const;
153 
154  /// Set the status line help text for this spinner
155  void setHelpText(const FXString& text);
156 
157  /// Get the status line help text for this spinner
158  const FXString& getHelpText() const;
159 
160  /// Set the tool tip message for this spinner
161  void setTipText(const FXString& text);
162 
163  /// Get the tool tip message for this spinner
164  const FXString& getTipText() const;
165 
166  /// Change spinner style
167  void setSpinnerStyle(FXuint style);
168 
169  /// Return current spinner style
170  FXuint getSpinnerStyle() const;
171 
172  /// Allow editing of the text field
173  void setEditable(FXbool edit=TRUE);
174 
175  /// Return TRUE if text field is editable
176  FXbool isEditable() const;
177 
178  /// Change color of the up arrow
179  void setUpArrowColor(FXColor clr);
180 
181  /// Return color of the up arrow
182  FXColor getUpArrowColor() const;
183 
184  /// Change color of the down arrow
185  void setDownArrowColor(FXColor clr);
186 
187  /// Return color of the the down arrow
188  FXColor getDownArrowColor() const;
189 
190  /// Change text color
191  void setTextColor(FXColor clr);
192 
193  /// Return text color
194  FXColor getTextColor() const;
195 
196  /// Change selected background color
197  void setSelBackColor(FXColor clr);
198 
199  /// Return selected background color
200  FXColor getSelBackColor() const;
201 
202  /// Change selected text color
203  void setSelTextColor(FXColor clr);
204 
205  /// Return selected text color
206  FXColor getSelTextColor() const;
207 
208  /// Changes the cursor color
209  void setCursorColor(FXColor clr);
210 
211  /// Return the cursor color
212  FXColor getCursorColor() const;
213 
214  /// Change width of text field in terms of number of columns * `m'
215  void setNumColumns(FXint cols);
216 
217  /// Return number of columns
218  FXint getNumColumns() const;
219 
220  /// Save spinner to a stream
221  virtual void save(FXStream& store) const;
222 
223  /// Load spinner from a stream
224  virtual void load(FXStream& store);
225 
226  /// Destructor
227  virtual ~FXSpinner();
228  };
229 
230 }
231 
232 #endif
FXVec2d lo(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:174
Normal, non-cyclic.
Definition: FXSpinner.h:39
No text visible.
Definition: FXSpinner.h:41
#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
#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
Cyclic spinner.
Definition: FXSpinner.h:40
Spin all the way down to -infinity.
Definition: FXSpinner.h:43
Definition: FX4Splitter.h:31
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
Spin all the way up to infinity.
Definition: FXSpinner.h:42
A text field is a single-line text entry widget.
Definition: FXTextField.h:73
#define FALSE
Definition: fxdefs.h:35
Spinner control.
Definition: FXSpinner.h:57
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
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