FXKnob.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                             K n o b   W i d g e t                             *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2005,2006 by Leandro Nini.   All Rights Reserved.               *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (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 GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXKnob.h,v 1.7 2006/01/22 17:58:05 fox Exp $                             *
00023 ********************************************************************************/
00024 #ifndef FXKNOB_H
00025 #define FXKNOB_H
00026 
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00035 enum {
00036   KNOB_NEEDLE    = 0,                           
00037   KNOB_DOT       = 0x00008000,                  
00038   KNOB_TICKS     = 0x00010000,                  
00039   KNOB_INDICATOR = 0x00020000,                  
00040   KNOB_NORMAL    = (KNOB_NEEDLE|KNOB_TICKS)     
00041   };
00042 
00043 
00044 
00051 class FXAPI FXKnob : public FXFrame {
00052   FXDECLARE(FXKnob)
00053 protected:
00054   FXint    range[2];            // Reported data range
00055   FXdouble limits[2];           // Starting and ending positions
00056   FXColor  lineColor;           // Color of indicator needle
00057   FXint    pos;                 // Reported data position
00058   FXint    incr;                // Increment when auto-sliding
00059   FXint    delta;               // Interval between ticks
00060   FXString help;                // Help string
00061   FXString tip;                 // Tip string
00062 protected:
00063   FXKnob();
00064   FXint calcValue(FXint x,FXint y);
00065 private:
00066   FXKnob(const FXKnob&);
00067   FXKnob &operator=(const FXKnob&);
00068 public:
00069   long onPaint(FXObject*,FXSelector,void*);
00070   long onLeftBtnPress(FXObject*,FXSelector,void*);
00071   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00072   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00073   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00074   long onMouseWheel(FXObject*,FXSelector,void*);
00075   long onUngrabbed(FXObject*,FXSelector,void*);
00076   long onMotion(FXObject*,FXSelector,void*);
00077   long onFocusIn(FXObject*,FXSelector,void*);
00078   long onFocusOut(FXObject*,FXSelector,void*);
00079   long onKeyPress(FXObject*,FXSelector,void*);
00080   long onKeyRelease(FXObject*,FXSelector,void*);
00081   long onAutoSlide(FXObject*,FXSelector,void*);
00082   long onCmdSetValue(FXObject*,FXSelector,void*);
00083   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00084   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00085   long onCmdSetRealValue(FXObject*,FXSelector,void*);
00086   long onCmdGetRealValue(FXObject*,FXSelector,void*);
00087   long onCmdSetIntRange(FXObject*,FXSelector,void*);
00088   long onCmdGetIntRange(FXObject*,FXSelector,void*);
00089   long onCmdSetRealRange(FXObject*,FXSelector,void*);
00090   long onCmdGetRealRange(FXObject*,FXSelector,void*);
00091   long onCmdSetHelp(FXObject*,FXSelector,void*);
00092   long onCmdGetHelp(FXObject*,FXSelector,void*);
00093   long onCmdSetTip(FXObject*,FXSelector,void*);
00094   long onCmdGetTip(FXObject*,FXSelector,void*);
00095   long onQueryHelp(FXObject*,FXSelector,void*);
00096   long onQueryTip(FXObject*,FXSelector,void*);
00097 public:
00098   enum{
00099     ID_AUTOSLIDE=FXFrame::ID_LAST,
00100     ID_LAST
00101     };
00102 public:
00103 
00105   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);
00106 
00108   virtual bool canFocus() const;
00109 
00111   virtual FXint getDefaultWidth();
00112 
00114   virtual FXint getDefaultHeight();
00115 
00117   virtual void layout();
00118 
00120   virtual void enable();
00121 
00123   virtual void disable();
00124 
00126   void setValue(FXint value,FXbool notify=FALSE);
00127 
00129   FXint getValue() const { return pos; }
00130 
00132   void setRange(FXint lo,FXint hi,FXbool notify=FALSE);
00133 
00135   void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; }
00136 
00141   void setLimits(FXint start,FXint end,FXbool notify=FALSE);
00142 
00144   void getLimits(FXint& start,FXint& end);
00145 
00147   FXuint getKnobStyle() const;
00148 
00150   void setKnobStyle(FXuint style);
00151 
00153   FXint getIncrement() const { return incr; }
00154 
00156   void setIncrement(FXint inc){ incr=inc; }
00157 
00159   void setTickDelta(FXint dist);
00160 
00162   FXint getTickDelta() const { return delta; }
00163 
00165   void setLineColor(FXColor clr);
00166 
00168   FXColor getLineColor() const { return lineColor; }
00169 
00171   void setHelpText(const FXString& text){ help=text; }
00172 
00174   const FXString& getHelpText() const { return help; }
00175 
00177   void setTipText(const FXString& text){ tip=text; }
00178 
00180   const FXString& getTipText() const { return tip; }
00181 
00183   virtual void save(FXStream& store) const;
00184 
00186   virtual void load(FXStream& store);
00187 
00189   virtual ~FXKnob();
00190   };
00191 
00192 }
00193 
00194 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:23 2009 for TnFOX by doxygen v1.4.7