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,2017 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=NULL,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

Copyright © 1997-2016 Jeroen van der Zijp