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

FXGauge.h
1 /********************************************************************************
2 * *
3 * G a u g e W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2010,2017 by Jeroen van der Zijp. 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 FXGAUGE_H
22 #define FXGAUGE_H
23 
24 #ifndef FXFRAME_H
25 #include "FXFrame.h"
26 #endif
27 
28 
30 
31 
32 namespace FX {
33 
34 
36 enum {
37  GAUGE_NORMAL = 0,
38  GAUGE_PIVOT_CENTER = 0x00008000,
39  GAUGE_PIVOT_INSIDE = 0x00010000,
40  GAUGE_ELLIPTICAL = 0x00020000,
41  GAUGE_CYCLIC = 0x00040000
42  };
43 
44 
48 class FXAPI FXGauge : public FXFrame {
49  FXDECLARE(FXGauge)
50 protected:
51  struct Indicator {
52  FXdouble radius; // Fraction of dial radius
53  FXdouble ratio; // Ratio of movement
54  FXColor color; // Color
55  FXbool shown; // Whether its shown or not
56  };
57 protected:
58  FXString caption; // Caption text
59  FXFont *numberFont; // Font for number labels
60  FXFont *captionFont; // Font for centered caption
61  Indicator indicator[3]; // Up to three indicators
62  FXint startAngle; // Start angle of arc (ccw from x-axis)
63  FXint sweepAngle; // Sweep angle of arc (ccw from startAngle)
64  FXdouble range[2]; // Reported data range
65  FXdouble value; // Reported data value
66 FXdouble innerRadius; // Inside radius
67  FXdouble majorTickDelta; // Major tick delta
68  FXdouble minorTickDelta; // Minor tick delta
69  FXColor majorTickColor; // Major tickmark color
70  FXColor minorTickColor; // Major tickmark color
71  FXshort majorTickSize; // Major tick size
72  FXshort minorTickSize; // Minor tick size
73  FXColor faceColor; // Dial face color
74  FXColor arcColor; // Color of arc
75  FXshort arcWeight; // Line weight
76  FXString help; // Help string
77  FXString tip; // Tip string
78 protected:
79  FXGauge();
80  void drawPointer(FXDCWindow& dc,FXdouble ang,FXint xx,FXint yy,FXint ww,FXint hh,FXint cx,FXint cy,FXint rx,FXint ry,FXint p) const;
81  void drawGauge(FXDCWindow& dc,FXint xx,FXint yy,FXint ww,FXint hh,FXint cx,FXint cy,FXint rx,FXint ry) const;
82 private:
83  FXGauge(const FXGauge&);
84  FXGauge &operator=(const FXGauge&);
85 public:
86  long onPaint(FXObject*,FXSelector,void*);
87  long onQueryHelp(FXObject*,FXSelector,void*);
88  long onQueryTip(FXObject*,FXSelector,void*);
89  long onCmdSetValue(FXObject*,FXSelector,void*);
90  long onCmdSetIntValue(FXObject*,FXSelector,void*);
91  long onCmdGetIntValue(FXObject*,FXSelector,void*);
92  long onCmdSetRealValue(FXObject*,FXSelector,void*);
93  long onCmdGetRealValue(FXObject*,FXSelector,void*);
94  long onCmdSetLongValue(FXObject*,FXSelector,void*);
95  long onCmdGetLongValue(FXObject*,FXSelector,void*);
96  long onCmdSetIntRange(FXObject*,FXSelector,void*);
97  long onCmdGetIntRange(FXObject*,FXSelector,void*);
98  long onCmdSetRealRange(FXObject*,FXSelector,void*);
99  long onCmdGetRealRange(FXObject*,FXSelector,void*);
100  long onCmdSetHelp(FXObject*,FXSelector,void*);
101  long onCmdGetHelp(FXObject*,FXSelector,void*);
102  long onCmdSetTip(FXObject*,FXSelector,void*);
103  long onCmdGetTip(FXObject*,FXSelector,void*);
104 public:
105 
107  FXGauge(FXComposite* p,FXuint opts=FRAME_NORMAL,FXint startang=180,FXint sweepang=-180,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);
108 
110  virtual FXint getDefaultWidth();
111 
113  virtual FXint getDefaultHeight();
114 
116  void setCaption(const FXString& text);
117 
119  FXString getCaption() const { return caption; }
120 
122  void setStartAngle(FXint degrees);
123 
125  FXint getStartAngle() const { return startAngle; }
126 
128  void setSweepAngle(FXint degrees);
129 
131  FXint getSweepAngle() const { return sweepAngle; }
132 
134  void setValue(FXdouble v,FXbool notify=false);
135 
137  FXdouble getValue() const { return value; }
138 
140  void setRange(FXdouble lo,FXdouble hi,FXbool notify=false);
141 
143  void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; }
144 
146  void setMajorTickDelta(FXdouble delta);
147 
149  FXdouble getMajorTickDelta() const { return majorTickDelta; }
150 
152  void setMinorTickDelta(FXdouble delta);
153 
155  FXdouble getMinorTickDelta() const { return minorTickDelta; }
156 
158  void setGaugeStyle(FXuint style);
159 
161  FXuint getGaugeStyle() const;
162 
164  void setNumberFont(FXFont* fnt);
165 
167  FXFont* getNumberFont() const { return numberFont; }
168 
170  void setCaptionFont(FXFont* fnt);
171 
173  FXFont* getCaptionFont() const { return captionFont; }
174 
176  void setHelpText(const FXString& text){ help=text; }
177 
179  const FXString& getHelpText() const { return help; }
180 
182  void setTipText(const FXString& text){ tip=text; }
183 
185  const FXString& getTipText() const { return tip; }
186 
188  virtual void save(FXStream& store) const;
189 
191  virtual void load(FXStream& store);
192 
194  virtual ~FXGauge();
195  };
196 
197 
198 }
199 
200 #endif

Copyright © 1997-2016 Jeroen van der Zijp