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

FXKnob.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * K n o b W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2005,2006 by Leandro Nini. 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: FXKnob.h,v 1.7 2006/01/22 17:58:05 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXKNOB_H
25 #define FXKNOB_H
26 
27 #ifndef FXFRAME_H
28 #include "FXFrame.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Knob Control styles
35 enum {
36  KNOB_NEEDLE = 0, /// Use a needle as indicator
37  KNOB_DOT = 0x00008000, /// Use a dot as indicator
38  KNOB_TICKS = 0x00010000, /// Show ticks around the knob
39  KNOB_INDICATOR = 0x00020000, /// Show only the indicator (like a speedometer)
40  KNOB_NORMAL = (KNOB_NEEDLE|KNOB_TICKS) /// Normal knob looks
41  };
42 
43 
44 
45 /**
46 * The knob widget is a valuator widget which provides simple linear value range.
47 * While being moved, the knob sends SEL_CHANGED messages to its target;
48 * at the end of the interaction, a final SEL_COMMAND message is sent.
49 * The message data represents the current knob value, of type FXint.
50 */
51 class FXAPI FXKnob : public FXFrame {
53 protected:
54  FXint range[2]; // Reported data range
55  FXdouble limits[2]; // Starting and ending positions
56  FXColor lineColor; // Color of indicator needle
57  FXint pos; // Reported data position
58  FXint incr; // Increment when auto-sliding
59  FXint delta; // Interval between ticks
60  FXString help; // Help string
61  FXString tip; // Tip string
62 protected:
63  FXKnob();
64  FXint calcValue(FXint x,FXint y);
65 private:
66  FXKnob(const FXKnob&);
67  FXKnob &operator=(const FXKnob&);
68 public:
69  long onPaint(FXObject*,FXSelector,void*);
70  long onLeftBtnPress(FXObject*,FXSelector,void*);
71  long onLeftBtnRelease(FXObject*,FXSelector,void*);
72  long onMiddleBtnPress(FXObject*,FXSelector,void*);
73  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
74  long onMouseWheel(FXObject*,FXSelector,void*);
75  long onUngrabbed(FXObject*,FXSelector,void*);
76  long onMotion(FXObject*,FXSelector,void*);
77  long onFocusIn(FXObject*,FXSelector,void*);
78  long onFocusOut(FXObject*,FXSelector,void*);
79  long onKeyPress(FXObject*,FXSelector,void*);
80  long onKeyRelease(FXObject*,FXSelector,void*);
81  long onAutoSlide(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  enum{
99  ID_AUTOSLIDE=FXFrame::ID_LAST,
100  ID_LAST
101  };
102 public:
103 
104  /// Construct a knob widget
106 
107  /// Returns true because a knob can receive focus
108  virtual bool canFocus() const;
109 
110  /// Return default width
111  virtual FXint getDefaultWidth();
112 
113  /// Return default height
114  virtual FXint getDefaultHeight();
115 
116  /// Perform layout
117  virtual void layout();
118 
119  /// Enable the knob
120  virtual void enable();
122  /// Disable the knob
123  virtual void disable();
124 
125  /// Change knob value
126  void setValue(FXint value,FXbool notify=FALSE);
128  /// Return knob value
129  FXint getValue() const { return pos; }
130 
131  /// Change the knob's range
132  void setRange(FXint lo,FXint hi,FXbool notify=FALSE);
133 
134  /// Get the knob's current range
135  void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; }
136 
137  /**
138  * Change the knob's movement limits (start and ending angles)
139  * accept values in degrees from 0 (south) to 360.
140  */
141  void setLimits(FXint start,FXint end,FXbool notify=FALSE);
142 
143  /// Get the knob's current limits
144  void getLimits(FXint& start,FXint& end);
146  /// Change the knob style
147  FXuint getKnobStyle() const;
149  /// Get the current knob style
150  void setKnobStyle(FXuint style);
151 
152  /// Get the knob's auto-increment/decrement value
153  FXint getIncrement() const { return incr; }
155  /// Change the knob's auto-increment/decrement value
156  void setIncrement(FXint inc){ incr=inc; }
157 
158  /// Change the delta between ticks
159  void setTickDelta(FXint dist);
161  /// Get delta between ticks
162  FXint getTickDelta() const { return delta; }
164  /// Change the indicator needle color
165  void setLineColor(FXColor clr);
167  /// Get the current indicator needle color
168  FXColor getLineColor() const { return lineColor; }
170  /// Set the help text to be displayed on the status line
171  void setHelpText(const FXString& text){ help=text; }
173  /// Get the current help text
174  const FXString& getHelpText() const { return help; }
175 
176  /// Set the tip text to be displayed in the tooltip
177  void setTipText(const FXString& text){ tip=text; }
178 
179  /// Get the current tooltip text value
180  const FXString& getTipText() const { return tip; }
181 
182  /// Save to stream
183  virtual void save(FXStream& store) const;
184 
185  /// Load from stream
186  virtual void load(FXStream& store);
187 
188  /// Destroy the knob
189  virtual ~FXKnob();
190  };
191 
192 }
193 
194 #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
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
Show ticks around the knob.
Definition: FXKnob.h:41
double FXdouble
Definition: fxdefs.h:399
Use a needle as indicator.
Definition: FXKnob.h:39
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
FXVec2d hi(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:175
#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 knob looks.
Definition: FXKnob.h:43
The knob widget is a valuator widget which provides simple linear value range.
Definition: FXKnob.h:58
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
Use a dot as indicator.
Definition: FXKnob.h:40
Show only the indicator (like a speedometer)
Definition: FXKnob.h:42
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp