FXSlider.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                           S l i d e r   W i d g e t                           *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   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: FXSlider.h,v 1.44 2006/01/22 17:58:09 fox Exp $                          *
00023 ********************************************************************************/
00024 #ifndef FXSLIDER_H
00025 #define FXSLIDER_H
00026 
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00035 enum {
00036   SLIDER_HORIZONTAL   = 0,                        
00037   SLIDER_VERTICAL     = 0x00008000,               
00038   SLIDER_ARROW_UP     = 0x00010000,               
00039   SLIDER_ARROW_DOWN   = 0x00020000,               
00040   SLIDER_ARROW_LEFT   = SLIDER_ARROW_UP,          
00041   SLIDER_ARROW_RIGHT  = SLIDER_ARROW_DOWN,        
00042   SLIDER_INSIDE_BAR   = 0x00040000,               
00043   SLIDER_TICKS_TOP    = 0x00080000,               
00044   SLIDER_TICKS_BOTTOM = 0x00100000,               
00045   SLIDER_TICKS_LEFT   = SLIDER_TICKS_TOP,         
00046   SLIDER_TICKS_RIGHT  = SLIDER_TICKS_BOTTOM,      
00047   SLIDER_NORMAL       = SLIDER_HORIZONTAL
00048   };
00049 
00050 
00060 class FXAPI FXSlider : public FXFrame {
00061   FXDECLARE(FXSlider)
00062 protected:
00063   FXint         range[2];                 // Reported data range
00064   FXint         pos;                      // Reported data position
00065   FXint         incr;                     // Increment when auto-sliding
00066   FXint         delta;                    // Interval between ticks
00067   FXint         headpos;                  // Head position
00068   FXint         headsize;                 // Head size
00069   FXint         slotsize;                 // Slot size
00070   FXColor       slotColor;                // Color of slot the head moves in
00071   FXint         dragpoint;                // Where the head is grabbed
00072   FXString      help;                     // Help string
00073   FXString      tip;                      // Tip string
00074 protected:
00075   FXSlider();
00076   void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00077   void drawHorzTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00078   void drawVertTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00079 private:
00080   FXSlider(const FXSlider&);
00081   FXSlider &operator=(const FXSlider&);
00082 public:
00083   long onPaint(FXObject*,FXSelector,void*);
00084   long onMotion(FXObject*,FXSelector,void*);
00085   long onMouseWheel(FXObject*,FXSelector,void*);
00086   long onLeftBtnPress(FXObject*,FXSelector,void*);
00087   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00088   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00089   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00090   long onKeyPress(FXObject*,FXSelector,void*);
00091   long onKeyRelease(FXObject*,FXSelector,void*);
00092   long onUngrabbed(FXObject*,FXSelector,void*);
00093   long onAutoSlide(FXObject*,FXSelector,void*);
00094   long onCmdSetValue(FXObject*,FXSelector,void*);
00095   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00096   long onCmdGetIntValue(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   FXSlider(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=SLIDER_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 bool canFocus() const;
00127 
00129   virtual void layout();
00130 
00132   virtual void enable();
00133 
00135   virtual void disable();
00136 
00138   void setValue(FXint value,FXbool notify=FALSE);
00139 
00141   FXint getValue() const { return pos; }
00142 
00144   void setRange(FXint lo,FXint hi,FXbool notify=FALSE);
00145 
00147   void getRange(FXint& lo,FXint& 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   FXint getIncrement() const { return incr; }
00169 
00171   void setIncrement(FXint inc);
00172 
00174   void setTickDelta(FXint dist);
00175 
00177   FXint getTickDelta() const { return delta; }
00178 
00180   void setSlotColor(FXColor clr);
00181 
00183   FXColor getSlotColor() const { return slotColor; }
00184 
00186   void setHelpText(const FXString& text){ help=text; }
00187 
00189   const FXString& getHelpText() const { return help; }
00190 
00192   void setTipText(const FXString& text){ tip=text; }
00193 
00195   const FXString& getTipText() const { return tip; }
00196 
00198   virtual void save(FXStream& store) const;
00199 
00201   virtual void load(FXStream& store);
00202 
00204   virtual ~FXSlider();
00205   };
00206 
00207 }
00208 
00209 #endif

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