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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXRealSlider.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                       R e a l S l i d e r   W i d g e t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,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 FXREALSLIDER_H
00022 #define FXREALSLIDER_H
00023 
00024 #ifndef FXFRAME_H
00025 #include "FXFrame.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00032 enum {
00033   REALSLIDER_HORIZONTAL   = 0,                          
00034   REALSLIDER_VERTICAL     = 0x00008000,                 
00035   REALSLIDER_ARROW_UP     = 0x00010000,                 
00036   REALSLIDER_ARROW_DOWN   = 0x00020000,                 
00037   REALSLIDER_ARROW_LEFT   = REALSLIDER_ARROW_UP,        
00038   REALSLIDER_ARROW_RIGHT  = REALSLIDER_ARROW_DOWN,      
00039   REALSLIDER_INSIDE_BAR   = 0x00040000,                 
00040   REALSLIDER_TICKS_TOP    = 0x00080000,                 
00041   REALSLIDER_TICKS_BOTTOM = 0x00100000,                 
00042   REALSLIDER_TICKS_LEFT   = REALSLIDER_TICKS_TOP,       
00043   REALSLIDER_TICKS_RIGHT  = REALSLIDER_TICKS_BOTTOM,    
00044   REALSLIDER_NORMAL       = REALSLIDER_HORIZONTAL
00045   };
00046 
00047 
00057 class FXAPI FXRealSlider : public FXFrame {
00058   FXDECLARE(FXRealSlider)
00059 protected:
00060   FXint         headPos;        // Head position
00061   FXint         headSize;       // Head size
00062   FXint         slotSize;       // Slot size
00063   FXColor       slotColor;      // Color of slot the head moves in
00064   FXint         dragPoint;      // Where on the head is grabbed
00065   FXdouble      range[2];       // Reported data range
00066   FXdouble      delta;          // Interval between ticks
00067   FXdouble      incr;           // Increment when auto-sliding
00068   FXdouble      gran;           // Granularity
00069   FXdouble      pos;            // Reported data position
00070   FXString      help;           // Help string
00071   FXString      tip;            // Tip string
00072 protected:
00073   FXRealSlider();
00074   void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00075   void drawHorzTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00076   void drawVertTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00077 private:
00078   FXRealSlider(const FXRealSlider&);
00079   FXRealSlider &operator=(const FXRealSlider&);
00080 public:
00081   long onPaint(FXObject*,FXSelector,void*);
00082   long onMotion(FXObject*,FXSelector,void*);
00083   long onMouseWheel(FXObject*,FXSelector,void*);
00084   long onLeftBtnPress(FXObject*,FXSelector,void*);
00085   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00086   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00087   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00088   long onKeyPress(FXObject*,FXSelector,void*);
00089   long onKeyRelease(FXObject*,FXSelector,void*);
00090   long onUngrabbed(FXObject*,FXSelector,void*);
00091   long onAutoSlide(FXObject*,FXSelector,void*);
00092   long onCmdSetValue(FXObject*,FXSelector,void*);
00093   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00094   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00095   long onCmdSetLongValue(FXObject*,FXSelector,void*);
00096   long onCmdGetLongValue(FXObject*,FXSelector,void*);
00097   long onCmdSetRealValue(FXObject*,FXSelector,void*);
00098   long onCmdGetRealValue(FXObject*,FXSelector,void*);
00099   long onCmdSetIntRange(FXObject*,FXSelector,void*);
00100   long onCmdGetIntRange(FXObject*,FXSelector,void*);
00101   long onCmdSetRealRange(FXObject*,FXSelector,void*);
00102   long onCmdGetRealRange(FXObject*,FXSelector,void*);
00103   long onCmdSetHelp(FXObject*,FXSelector,void*);
00104   long onCmdGetHelp(FXObject*,FXSelector,void*);
00105   long onCmdSetTip(FXObject*,FXSelector,void*);
00106   long onCmdGetTip(FXObject*,FXSelector,void*);
00107   long onQueryHelp(FXObject*,FXSelector,void*);
00108   long onQueryTip(FXObject*,FXSelector,void*);
00109 public:
00110   enum{
00111     ID_AUTOSLIDE=FXFrame::ID_LAST,
00112     ID_LAST
00113     };
00114 public:
00115 
00117   FXRealSlider(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=REALSLIDER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0);
00118 
00120   virtual FXint getDefaultWidth();
00121 
00123   virtual FXint getDefaultHeight();
00124 
00126   virtual FXbool canFocus() const;
00127 
00129   virtual void layout();
00130 
00132   virtual void enable();
00133 
00135   virtual void disable();
00136 
00138   void setValue(FXdouble value,FXbool notify=false);
00139 
00141   FXdouble getValue() const { return pos; }
00142 
00144   void setRange(FXdouble lo,FXdouble hi,FXbool notify=false);
00145 
00147   void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; }
00148 
00150   FXuint getSliderStyle() const;
00151 
00153   void setSliderStyle(FXuint style);
00154 
00156   FXint getHeadSize() const { return headSize; }
00157 
00159   void setHeadSize(FXint hs);
00160 
00162   FXint getSlotSize() const { return slotSize; }
00163 
00165   void setSlotSize(FXint bs);
00166 
00168   FXdouble getIncrement() const { return incr; }
00169 
00171   void setIncrement(FXdouble inc);
00172 
00174   void setGranularity(FXdouble gr);
00175 
00177   FXdouble getGranularity() const { return gran; }
00178 
00180   void setTickDelta(FXdouble dist);
00181 
00183   FXdouble getTickDelta() const { return delta; }
00184 
00186   void setSlotColor(FXColor clr);
00187 
00189   FXColor getSlotColor() const { return slotColor; }
00190 
00192   void setHelpText(const FXString& text){ help=text; }
00193 
00195   const FXString& getHelpText() const { return help; }
00196 
00198   void setTipText(const FXString& text){ tip=text; }
00199 
00201   const FXString& getTipText() const { return tip; }
00202 
00204   virtual void save(FXStream& store) const;
00205 
00207   virtual void load(FXStream& store);
00208 
00210   virtual ~FXRealSlider();
00211   };
00212 
00213 }
00214 
00215 #endif

Copyright © 1997-2011 Jeroen van der Zijp