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

FXDial.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * D i a l W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,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: FXDial.h,v 1.35 2006/01/22 17:58:00 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXDIAL_H
25 #define FXDIAL_H
26 
27 #ifndef FXFRAME_H
28 #include "FXFrame.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 // Dial style options
35 enum {
36  DIAL_VERTICAL = 0, // Vertically oriented
37  DIAL_HORIZONTAL = 0x00008000, // Horizontal oriented
38  DIAL_CYCLIC = 0x00010000, // Value wraps around
39  DIAL_HAS_NOTCH = 0x00020000, // Dial has a Center Notch
41  };
42 
43 
44 /**
45 * The Dial widget is a valuator widget which is able to provide a cyclic
46 * value range when the DIAL_CYCLIC is passed, or a simple linear value range.
47 * While being turned, the dial sends a SEL_CHANGED message to its target;
48 * at the end of the interaction, a SEL_COMMAND message is sent.
49 * The message data represents the current value, of type FXint. The options
50 * DIAL_VERTICAL and DIAL_HORIZONTAL control the orientation of the dial.
51 * An optional notch can be used to indicate the zero-position of
52 * the dial; display of the notch is controlled by the DIAL_HAS_NOTCH option.
53 */
54 class FXAPI FXDial : public FXFrame {
56 protected:
57  FXint range[2]; // Reported data range
58  FXColor notchColor; // Main notch color
59  FXint notchangle; // Angle of main notch
60  FXint notchspacing; // Angle between notches
61  FXint notchoffset; // Notch offset
62  FXint dragpoint; // Place where clicked
63  FXint dragpos; // Value where clicked
64  FXint incr; // Rate of change/revolution
65  FXint pos; // Reported data position
66  FXString help; // Help string
67  FXString tip; // Tip string
68 protected:
69  FXDial();
70 private:
71  FXDial(const FXDial&);
72  FXDial &operator=(const FXDial&);
73 public:
74  long onPaint(FXObject*,FXSelector,void*);
75  long onMotion(FXObject*,FXSelector,void*);
76  long onMouseWheel(FXObject*,FXSelector,void*);
77  long onLeftBtnPress(FXObject*,FXSelector,void* );
78  long onLeftBtnRelease(FXObject*,FXSelector,void*);
79  long onKeyPress(FXObject*,FXSelector,void*);
80  long onKeyRelease(FXObject*,FXSelector,void*);
81  long onUngrabbed(FXObject*,FXSelector,void*);
82  long onCmdSetValue(FXObject*,FXSelector,void*);
83  long onCmdSetIntValue(FXObject*,FXSelector,void*);
84  long onCmdGetIntValue(FXObject*,FXSelector,void*);
85  long onCmdSetRealValue(FXObject*,FXSelector,void*);
86  long onCmdGetRealValue(FXObject*,FXSelector,void*);
87  long onCmdSetIntRange(FXObject*,FXSelector,void*);
88  long onCmdGetIntRange(FXObject*,FXSelector,void*);
89  long onCmdSetRealRange(FXObject*,FXSelector,void*);
90  long onCmdGetRealRange(FXObject*,FXSelector,void*);
91  long onCmdSetHelp(FXObject*,FXSelector,void*);
92  long onCmdGetHelp(FXObject*,FXSelector,void*);
93  long onCmdSetTip(FXObject*,FXSelector,void*);
94  long onCmdGetTip(FXObject*,FXSelector,void*);
95  long onQueryHelp(FXObject*,FXSelector,void*);
96  long onQueryTip(FXObject*,FXSelector,void*);
97 public:
98 
99  /// Construct a dial widget
101 
102  /// Return default width
103  virtual FXint getDefaultWidth();
104 
105  /// Return default height
106  virtual FXint getDefaultHeight();
107 
108  /// Returns true because a dial can receive focus
109  virtual bool canFocus() const;
110 
111  /// Set the dial value
112  void setValue(FXint value,FXbool notify=FALSE);
113 
114  /// Return the dial value
115  FXint getValue() const { return pos; }
116 
117  /// Change the dial's range
118  void setRange(FXint lo,FXint hi,FXbool notify=FALSE);
119 
120  /// Obtain the current range of the dial
121  void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; }
122 
123  /**
124  * Set the revolution increment, which is the amount of change
125  * in the position for revolution of the dial; the dial may go
126  * through multiple revolutions to go through its whole range;
127  * by default it takes one 360 degree turn of the dial to go
128  * from the lower to the upper range.
129  */
130  void setRevolutionIncrement(FXint i);
131 
132  /// Get the current value of the revolution increment
133  FXint getRevolutionIncrement() const { return incr; }
134 
135  /**
136  * Change the spacing for the small notches; this should be set
137  * in tenths of degrees in the range [1,3600], and the value should
138  * be a divisor of 3600, so as to make the notches come out evenly
139  */
140  void setNotchSpacing(FXint spacing);
141 
142  /// Get the current notch spacing
143  FXint getNotchSpacing() const { return notchspacing; }
144 
145  /**
146  * Change the notch offset, which is the position of the
147  * center notch; the value should be tenths of degrees
148  * in the range [-3600,3600]
149  */
150  void setNotchOffset(FXint offset);
151 
152  /// Get the current center notch offset
153  FXint getNotchOffset() const { return notchoffset; }
154 
155  /// Changes the dial style.
156  void setDialStyle(FXuint opts);
157 
158  /// Get the current dial style.
159  FXuint getDialStyle() const;
160 
161  /// Change the center notch color
162  void setNotchColor(FXColor clr);
163 
164  /// Get the current center notch color
165  FXColor getNotchColor() const { return notchColor; }
166 
167  /// Set the help text to be displayed on the status line
168  void setHelpText(const FXString& text);
169 
170  /// Get the current help text
171  const FXString& getHelpText() const { return help; }
172 
173  /// Set the tip text to be displayed in the tooltip
174  void setTipText(const FXString& text);
175 
176  /// Get the current tooltip text value
177  const FXString& getTipText() const { return tip; }
178 
179  /// Save to stream
180  virtual void save(FXStream& store) const;
181 
182  /// Load from stream
183  virtual void load(FXStream& store);
184  };
185 
186 }
187 
188 #endif
FXVec2d lo(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:174
The Frame widget provides borders around some contents.
Definition: FXFrame.h:73
unsigned int FXuint
Definition: fxdefs.h:389
Definition: FXFrame.h:56
Value wraps around.
Definition: FXDial.h:41
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:386
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:447
Definition: FXDial.h:43
Dial has a Center Notch.
Definition: FXDial.h:42
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
FXVec2d hi(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:175
Vertically oriented.
Definition: FXDial.h:39
#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
Horizontal oriented.
Definition: FXDial.h:40
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp