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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXGauge.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                             G a u g e   W i d g e t                           *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2010,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXGAUGE_H
00022 #define FXGAUGE_H
00023 
00024 #ifndef FXFRAME_H
00025 #include "FXFrame.h"
00026 #endif
00027 
00028 
00030 
00031 
00032 namespace FX {
00033 
00034 
00036 enum {
00037   GAUGE_NORMAL       = 0,               
00038   GAUGE_PIVOT_CENTER = 0x00008000,      
00039   GAUGE_PIVOT_INSIDE = 0x00010000,      
00040   GAUGE_ELLIPTICAL   = 0x00020000,      
00041   GAUGE_CYCLIC       = 0x00040000       
00042   };
00043 
00044 
00048 class FXAPI FXGauge : public FXFrame {
00049   FXDECLARE(FXGauge)
00050 protected:
00051   struct Indicator {
00052     FXdouble radius;            // Fraction of dial radius
00053     FXdouble ratio;             // Ratio of movement
00054     FXColor  color;             // Color
00055     FXbool   shown;             // Whether its shown or not
00056     };
00057 protected:
00058   FXString      caption;        // Caption text
00059   FXFont       *numberFont;     // Font for number labels
00060   FXFont       *captionFont;    // Font for centered caption
00061   Indicator     indicator[3];   // Up to three indicators
00062   FXint         startAngle;     // Start angle of arc (ccw from x-axis)
00063   FXint         sweepAngle;     // Sweep angle of arc (ccw from startAngle)
00064   FXdouble      range[2];       // Reported data range
00065   FXdouble      value;          // Reported data value
00066 FXdouble      innerRadius;    // Inside radius
00067   FXdouble      majorTickDelta; // Major tick delta
00068   FXdouble      minorTickDelta; // Minor tick delta
00069   FXColor       majorTickColor; // Major tickmark color
00070   FXColor       minorTickColor; // Major tickmark color
00071   FXshort       majorTickSize;  // Major tick size
00072   FXshort       minorTickSize;  // Minor tick size
00073   FXColor       faceColor;      // Dial face color
00074   FXColor       arcColor;       // Color of arc
00075   FXshort       arcWeight;      // Line weight
00076   FXString      help;           // Help string
00077   FXString      tip;            // Tip string
00078 protected:
00079   FXGauge();
00080   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;
00081   void drawGauge(FXDCWindow& dc,FXint xx,FXint yy,FXint ww,FXint hh,FXint cx,FXint cy,FXint rx,FXint ry) const;
00082 private:
00083   FXGauge(const FXGauge&);
00084   FXGauge &operator=(const FXGauge&);
00085 public:
00086   long onPaint(FXObject*,FXSelector,void*);
00087   long onQueryHelp(FXObject*,FXSelector,void*);
00088   long onQueryTip(FXObject*,FXSelector,void*);
00089   long onCmdSetValue(FXObject*,FXSelector,void*);
00090   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00091   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00092   long onCmdSetRealValue(FXObject*,FXSelector,void*);
00093   long onCmdGetRealValue(FXObject*,FXSelector,void*);
00094   long onCmdSetLongValue(FXObject*,FXSelector,void*);
00095   long onCmdGetLongValue(FXObject*,FXSelector,void*);
00096   long onCmdSetIntRange(FXObject*,FXSelector,void*);
00097   long onCmdGetIntRange(FXObject*,FXSelector,void*);
00098   long onCmdSetRealRange(FXObject*,FXSelector,void*);
00099   long onCmdGetRealRange(FXObject*,FXSelector,void*);
00100   long onCmdSetHelp(FXObject*,FXSelector,void*);
00101   long onCmdGetHelp(FXObject*,FXSelector,void*);
00102   long onCmdSetTip(FXObject*,FXSelector,void*);
00103   long onCmdGetTip(FXObject*,FXSelector,void*);
00104 public:
00105 
00107   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);
00108 
00110   virtual FXint getDefaultWidth();
00111 
00113   virtual FXint getDefaultHeight();
00114 
00116   void setCaption(const FXString& text);
00117 
00119   FXString getCaption() const { return caption; }
00120 
00122   void setStartAngle(FXint degrees);
00123 
00125   FXint getStartAngle() const { return startAngle; }
00126 
00128   void setSweepAngle(FXint degrees);
00129 
00131   FXint getSweepAngle() const { return sweepAngle; }
00132 
00134   void setValue(FXdouble v,FXbool notify=false);
00135 
00137   FXdouble getValue() const { return value; }
00138 
00140   void setRange(FXdouble lo,FXdouble hi,FXbool notify=false);
00141 
00143   void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; }
00144 
00146   void setMajorTickDelta(FXdouble delta);
00147 
00149   FXdouble getMajorTickDelta() const { return majorTickDelta; }
00150 
00152   void setMinorTickDelta(FXdouble delta);
00153 
00155   FXdouble getMinorTickDelta() const { return minorTickDelta; }
00156 
00158   void setGaugeStyle(FXuint style);
00159 
00161   FXuint getGaugeStyle() const;
00162 
00164   void setNumberFont(FXFont* fnt);
00165 
00167   FXFont* getNumberFont() const { return numberFont; }
00168 
00170   void setCaptionFont(FXFont* fnt);
00171 
00173   FXFont* getCaptionFont() const { return captionFont; }
00174 
00176   void setHelpText(const FXString& text){ help=text; }
00177 
00179   const FXString& getHelpText() const { return help; }
00180 
00182   void setTipText(const FXString& text){ tip=text; }
00183 
00185   const FXString& getTipText() const { return tip; }
00186 
00188   virtual void save(FXStream& store) const;
00189 
00191   virtual void load(FXStream& store);
00192 
00194   virtual ~FXGauge();
00195   };
00196 
00197 
00198 }
00199 
00200 #endif

Copyright © 1997-2011 Jeroen van der Zijp