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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXKnob.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                             K n o b   W i d g e t                             *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2005,2012 by Leandro Nini.   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 FXKNOB_H
00022 #define FXKNOB_H
00023 
00024 #ifndef FXFRAME_H
00025 #include "FXFrame.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00032 enum {
00033   KNOB_NEEDLE    = 0,                           
00034   KNOB_DOT       = 0x00008000,                  
00035   KNOB_TICKS     = 0x00010000,                  
00036   KNOB_INDICATOR = 0x00020000,                  
00037   KNOB_NORMAL    = (KNOB_NEEDLE|KNOB_TICKS)     
00038   };
00039 
00040 
00041 
00048 class FXAPI FXKnob : public FXFrame {
00049   FXDECLARE(FXKnob)
00050 protected:
00051   FXint    range[2];            // Reported data range
00052   FXdouble limits[2];           // Starting and ending positions
00053   FXColor  lineColor;           // Color of indicator needle
00054   FXint    pos;                 // Reported data position
00055   FXint    incr;                // Increment when auto-sliding
00056   FXint    delta;               // Interval between ticks
00057   FXString help;                // Help string
00058   FXString tip;                 // Tip string
00059 protected:
00060   FXKnob();
00061   FXint calcValue(FXint x,FXint y);
00062 private:
00063   FXKnob(const FXKnob&);
00064   FXKnob &operator=(const FXKnob&);
00065 public:
00066   long onPaint(FXObject*,FXSelector,void*);
00067   long onLeftBtnPress(FXObject*,FXSelector,void*);
00068   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00069   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00070   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00071   long onMouseWheel(FXObject*,FXSelector,void*);
00072   long onUngrabbed(FXObject*,FXSelector,void*);
00073   long onMotion(FXObject*,FXSelector,void*);
00074   long onFocusIn(FXObject*,FXSelector,void*);
00075   long onFocusOut(FXObject*,FXSelector,void*);
00076   long onKeyPress(FXObject*,FXSelector,void*);
00077   long onKeyRelease(FXObject*,FXSelector,void*);
00078   long onAutoSlide(FXObject*,FXSelector,void*);
00079   long onCmdSetValue(FXObject*,FXSelector,void*);
00080   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00081   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00082   long onCmdSetLongValue(FXObject*,FXSelector,void*);
00083   long onCmdGetLongValue(FXObject*,FXSelector,void*);
00084   long onCmdSetRealValue(FXObject*,FXSelector,void*);
00085   long onCmdGetRealValue(FXObject*,FXSelector,void*);
00086   long onCmdSetIntRange(FXObject*,FXSelector,void*);
00087   long onCmdGetIntRange(FXObject*,FXSelector,void*);
00088   long onCmdSetRealRange(FXObject*,FXSelector,void*);
00089   long onCmdGetRealRange(FXObject*,FXSelector,void*);
00090   long onCmdSetHelp(FXObject*,FXSelector,void*);
00091   long onCmdGetHelp(FXObject*,FXSelector,void*);
00092   long onCmdSetTip(FXObject*,FXSelector,void*);
00093   long onCmdGetTip(FXObject*,FXSelector,void*);
00094   long onQueryHelp(FXObject*,FXSelector,void*);
00095   long onQueryTip(FXObject*,FXSelector,void*);
00096 public:
00097   enum{
00098     ID_AUTOSLIDE=FXFrame::ID_LAST,
00099     ID_LAST
00100     };
00101 public:
00102 
00104   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);
00105 
00107   virtual FXbool canFocus() const;
00108 
00110   virtual FXint getDefaultWidth();
00111 
00113   virtual FXint getDefaultHeight();
00114 
00116   virtual void layout();
00117 
00119   virtual void enable();
00120 
00122   virtual void disable();
00123 
00125   void setValue(FXint value,FXbool notify=false);
00126 
00128   FXint getValue() const { return pos; }
00129 
00131   void setRange(FXint lo,FXint hi,FXbool notify=false);
00132 
00134   void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; }
00135 
00140   void setLimits(FXint start,FXint end,FXbool notify=false);
00141 
00143   void getLimits(FXint& start,FXint& end);
00144 
00146   FXuint getKnobStyle() const;
00147 
00149   void setKnobStyle(FXuint style);
00150 
00152   FXint getIncrement() const { return incr; }
00153 
00155   void setIncrement(FXint inc){ incr=inc; }
00156 
00158   void setTickDelta(FXint dist);
00159 
00161   FXint getTickDelta() const { return delta; }
00162 
00164   void setLineColor(FXColor clr);
00165 
00167   FXColor getLineColor() const { return lineColor; }
00168 
00170   void setHelpText(const FXString& text){ help=text; }
00171 
00173   const FXString& getHelpText() const { return help; }
00174 
00176   void setTipText(const FXString& text){ tip=text; }
00177 
00179   const FXString& getTipText() const { return tip; }
00180 
00182   virtual void save(FXStream& store) const;
00183 
00185   virtual void load(FXStream& store);
00186 
00188   virtual ~FXKnob();
00189   };
00190 
00191 }
00192 
00193 #endif

Copyright © 1997-2011 Jeroen van der Zijp