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

FXKnob.h
1 /********************************************************************************
2 * *
3 * K n o b W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2005,2024 by Leandro Nini. 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 FXKNOB_H
22 #define FXKNOB_H
23 
24 #ifndef FXFRAME_H
25 #include "FXFrame.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum {
33  KNOB_NEEDLE = 0,
34  KNOB_DOT = 0x00008000,
35  KNOB_TICKS = 0x00010000,
36  KNOB_INDICATOR = 0x00020000,
37  KNOB_NORMAL = (KNOB_NEEDLE|KNOB_TICKS)
38  };
39 
40 
41 
48 class FXAPI FXKnob : public FXFrame {
49  FXDECLARE(FXKnob)
50 protected:
51  FXint range[2]; // Reported data range
52  FXdouble limits[2]; // Starting and ending positions
53  FXColor lineColor; // Color of indicator needle
54  FXint pos; // Reported data position
55  FXint incr; // Increment when auto-sliding
56  FXint delta; // Interval between ticks
57  FXString help; // Help string
58  FXString tip; // Tip string
59 protected:
60  FXKnob();
61  FXint calcValue(FXint x,FXint y);
62 private:
63  FXKnob(const FXKnob&);
64  FXKnob &operator=(const FXKnob&);
65 public:
66  long onPaint(FXObject*,FXSelector,void*);
67  long onLeftBtnPress(FXObject*,FXSelector,void*);
68  long onLeftBtnRelease(FXObject*,FXSelector,void*);
69  long onMiddleBtnPress(FXObject*,FXSelector,void*);
70  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
71  long onMouseWheel(FXObject*,FXSelector,void*);
72  long onUngrabbed(FXObject*,FXSelector,void*);
73  long onMotion(FXObject*,FXSelector,void*);
74  long onFocusIn(FXObject*,FXSelector,void*);
75  long onFocusOut(FXObject*,FXSelector,void*);
76  long onKeyPress(FXObject*,FXSelector,void*);
77  long onKeyRelease(FXObject*,FXSelector,void*);
78  long onAutoSlide(FXObject*,FXSelector,void*);
79  long onCmdSetValue(FXObject*,FXSelector,void*);
80  long onCmdSetIntValue(FXObject*,FXSelector,void*);
81  long onCmdGetIntValue(FXObject*,FXSelector,void*);
82  long onCmdSetLongValue(FXObject*,FXSelector,void*);
83  long onCmdGetLongValue(FXObject*,FXSelector,void*);
84  long onCmdSetRealValue(FXObject*,FXSelector,void*);
85  long onCmdGetRealValue(FXObject*,FXSelector,void*);
86  long onCmdSetIntRange(FXObject*,FXSelector,void*);
87  long onCmdGetIntRange(FXObject*,FXSelector,void*);
88  long onCmdSetRealRange(FXObject*,FXSelector,void*);
89  long onCmdGetRealRange(FXObject*,FXSelector,void*);
90  long onCmdSetHelp(FXObject*,FXSelector,void*);
91  long onCmdGetHelp(FXObject*,FXSelector,void*);
92  long onCmdSetTip(FXObject*,FXSelector,void*);
93  long onCmdGetTip(FXObject*,FXSelector,void*);
94  long onQueryHelp(FXObject*,FXSelector,void*);
95  long onQueryTip(FXObject*,FXSelector,void*);
96 public:
97  enum{
98  ID_AUTOSLIDE=FXFrame::ID_LAST,
99  ID_LAST
100  };
101 public:
102 
104  FXKnob(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=KNOB_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);
105 
107  virtual FXbool canFocus() const;
108 
110  virtual FXint getDefaultWidth();
111 
113  virtual FXint getDefaultHeight();
114 
116  virtual void layout();
117 
119  virtual void enable();
120 
122  virtual void disable();
123 
125  void setValue(FXint value,FXbool notify=false);
126 
128  FXint getValue() const { return pos; }
129 
131  void setRange(FXint lo,FXint hi,FXbool notify=false);
132 
134  void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; }
135 
140  void setLimits(FXint start,FXint end,FXbool notify=false);
141 
143  void getLimits(FXint& start,FXint& end);
144 
146  FXuint getKnobStyle() const;
147 
149  void setKnobStyle(FXuint style);
150 
152  FXint getIncrement() const { return incr; }
153 
155  void setIncrement(FXint inc){ incr=inc; }
156 
158  void setTickDelta(FXint dist);
159 
161  FXint getTickDelta() const { return delta; }
162 
164  void setLineColor(FXColor clr);
165 
167  FXColor getLineColor() const { return lineColor; }
168 
170  void setHelpText(const FXString& text){ help=text; }
171 
173  const FXString& getHelpText() const { return help; }
174 
176  void setTipText(const FXString& text){ tip=text; }
177 
179  const FXString& getTipText() const { return tip; }
180 
182  virtual void save(FXStream& store) const;
183 
185  virtual void load(FXStream& store);
186 
188  virtual ~FXKnob();
189  };
190 
191 }
192 
193 #endif
The Frame widget provides borders around some contents.
Definition: FXFrame.h:58
const FXString & getTipText() const
Get the current tooltip text value.
Definition: FXKnob.h:179
void setTipText(const FXString &text)
Set the tip text to be displayed in the tooltip.
Definition: FXKnob.h:176
Base composite.
Definition: FXComposite.h:32
const FXString & getHelpText() const
Get the current help text.
Definition: FXKnob.h:173
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
FXColor getLineColor() const
Get the current indicator needle color.
Definition: FXKnob.h:167
Definition: FX4Splitter.h:28
void setIncrement(FXint inc)
Change the knob&#39;s auto-increment/decrement value.
Definition: FXKnob.h:155
void getRange(FXint &lo, FXint &hi) const
Get the knob&#39;s current range.
Definition: FXKnob.h:134
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
FXint getIncrement() const
Get the knob&#39;s auto-increment/decrement value.
Definition: FXKnob.h:152
The knob widget is a valuator widget which provides simple linear value range.
Definition: FXKnob.h:48
void setHelpText(const FXString &text)
Set the help text to be displayed on the status line.
Definition: FXKnob.h:170
FXint getValue() const
Return knob value.
Definition: FXKnob.h:128
FXint getTickDelta() const
Get delta between ticks.
Definition: FXKnob.h:161
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp