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

FXRealSpinner.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *             R e a l - V a l u e d   S p i n n e r  W i d g e t                *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2003,2009 by Bill Baxter.   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 * $Id: FXRealSpinner.h,v 1.27 2009/01/06 13:07:26 fox Exp $                     *
00022 ********************************************************************************/
00023 #ifndef FXREALSPINNER_H
00024 #define FXREALSPINNER_H
00025 
00026 #ifndef FXPACKER_H
00027 #include "FXPacker.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /// Real Spinner Options
00034 enum {
00035   REALSPIN_NORMAL  =  0,                /// Normal, non-cyclic
00036   REALSPIN_CYCLIC  =  0x00020000,       /// Cyclic spinner
00037   REALSPIN_NOTEXT  =  0x00040000,       /// No text visible
00038   REALSPIN_NOMAX   =  0x00080000,       /// Spin all the way up to infinity
00039   REALSPIN_NOMIN   =  0x00100000,       /// Spin all the way down to -infinity
00040   REALSPIN_LOG     =  0x00200000        /// Logarithmic rather than linear
00041   };
00042 
00043 
00044 class FXTextField;
00045 class FXDial;
00046 
00047 
00048 /// Real Spinner control
00049 class FXAPI FXRealSpinner : public FXPacker {
00050   FXDECLARE(FXRealSpinner)
00051 protected:
00052   FXTextField   *textField;         // Text field
00053   FXArrowButton *upButton;          // The up button
00054   FXArrowButton *downButton;        // The down button
00055   FXdouble       range[2];          // Reported data range
00056   FXdouble       incr;              // Increment
00057   FXdouble       gran;              // Granularity
00058   FXdouble       pos;               // Current position
00059 protected:
00060   FXRealSpinner();
00061 private:
00062   FXRealSpinner(const FXRealSpinner&);
00063   FXRealSpinner& operator=(const FXRealSpinner&);
00064 public:
00065   long onUpdIncrement(FXObject*,FXSelector,void*);
00066   long onCmdIncrement(FXObject*,FXSelector,void*);
00067   long onUpdDecrement(FXObject*,FXSelector,void*);
00068   long onCmdDecrement(FXObject*,FXSelector,void*);
00069   long onUpdEntry(FXObject*,FXSelector,void*);
00070   long onChgEntry(FXObject*,FXSelector,void*);
00071   long onCmdEntry(FXObject*,FXSelector,void*);
00072   long onWheelEntry(FXObject*,FXSelector,void*);
00073   long onKeyPress(FXObject*,FXSelector,void*);
00074   long onKeyRelease(FXObject*,FXSelector,void*);
00075   long onCmdSetValue(FXObject*,FXSelector,void*);
00076   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00077   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00078   long onCmdSetLongValue(FXObject*,FXSelector,void*);
00079   long onCmdGetLongValue(FXObject*,FXSelector,void*);
00080   long onCmdSetIntRange(FXObject*,FXSelector,void*);
00081   long onCmdGetIntRange(FXObject*,FXSelector,void*);
00082   long onCmdSetRealValue(FXObject*,FXSelector,void*);
00083   long onCmdGetRealValue(FXObject*,FXSelector,void*);
00084   long onCmdSetRealRange(FXObject*,FXSelector,void*);
00085   long onCmdGetRealRange(FXObject*,FXSelector,void*);
00086   long onFocusSelf(FXObject*,FXSelector,void*);
00087 public:
00088   enum{
00089     ID_INCREMENT=FXPacker::ID_LAST,
00090     ID_DECREMENT,
00091     ID_ENTRY,
00092     ID_LAST
00093     };
00094 public:
00095 
00096   /// Construct a spinner
00097   FXRealSpinner(FXComposite *p,FXint cols,FXObject *tgt=NULL,FXSelector sel=0,FXuint opts=REALSPIN_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);
00098 
00099   /// Perform layout
00100   virtual void layout();
00101 
00102   /// Disable spinner
00103   virtual void disable();
00104 
00105   /// Enable spinner
00106   virtual void enable();
00107 
00108   /// Return default width
00109   virtual FXint getDefaultWidth();
00110 
00111   /// Return default height
00112   virtual FXint getDefaultHeight();
00113 
00114   /// Increment spinner
00115   void increment(FXbool notify=false);
00116 
00117   /// Increment spinner by certain amount
00118   void incrementByAmount(FXdouble amount,FXbool notify=false);
00119 
00120   /// Decrement spinner
00121   void decrement(FXbool notify=false);
00122 
00123   /// Decrement spinner by certain amount
00124   void decrementByAmount(FXdouble amount,FXbool notify=false);
00125 
00126   /// Return true if in cyclic mode
00127   FXbool isCyclic() const;
00128 
00129   /// Set to cyclic mode, i.e. wrap around at maximum/minimum
00130   void setCyclic(FXbool cyclic);
00131 
00132   /// Return true if text is visible
00133   FXbool isTextVisible() const;
00134 
00135   /// Set text visible flag
00136   void setTextVisible(FXbool flag);
00137 
00138   /// Change current value
00139   virtual void setValue(FXdouble value,FXbool notify=false);
00140 
00141   /// Return current value
00142   FXdouble getValue() const { return pos; }
00143 
00144   /// Change the spinner's range
00145   void setRange(FXdouble lo,FXdouble hi,FXbool notify=false);
00146 
00147   /// Get the spinner's current range
00148   void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; }
00149 
00150   /// Change spinner increment
00151   void setIncrement(FXdouble increment);
00152 
00153   /// Return spinner increment
00154   FXdouble getIncrement() const { return incr; }
00155 
00156   /// Change spinner granularity
00157   void setGranularity(FXdouble gr);
00158 
00159   /// Return spinner granularity
00160   FXdouble getGranularity() const { return gran; }
00161 
00162   /// Set the text font
00163   void setFont(FXFont *fnt);
00164 
00165   /// Get the text font
00166   FXFont *getFont() const;
00167 
00168   /// Set the status line help text for this spinner
00169   void setHelpText(const FXString& text);
00170 
00171   /// Get the status line help text for this spinner
00172   const FXString& getHelpText() const;
00173 
00174   /// Set the tool tip message for this spinner
00175   void setTipText(const FXString& text);
00176 
00177   /// Get the tool tip message for this spinner
00178   const FXString& getTipText() const;
00179 
00180   /// Change spinner style
00181   void setSpinnerStyle(FXuint style);
00182 
00183   /// Return current spinner style
00184   FXuint getSpinnerStyle() const;
00185 
00186   /// Allow editing of the text field
00187   void setEditable(FXbool edit=true);
00188 
00189   /// Return true if text field is editable
00190   FXbool isEditable() const;
00191 
00192   /// Change color of the up arrow
00193   void setUpArrowColor(FXColor clr);
00194 
00195   /// Return color of the up arrow
00196   FXColor getUpArrowColor() const;
00197 
00198   /// Change color of the down arrow
00199   void setDownArrowColor(FXColor clr);
00200 
00201   /// Return color of the the down arrow
00202   FXColor getDownArrowColor() const;
00203 
00204   /// Change text color
00205   void setTextColor(FXColor clr);
00206 
00207   /// Return text color
00208   FXColor getTextColor() const;
00209 
00210   /// Change selected background color
00211   void setSelBackColor(FXColor clr);
00212 
00213   /// Return selected background color
00214   FXColor getSelBackColor() const;
00215 
00216   /// Change selected text color
00217   void setSelTextColor(FXColor clr);
00218 
00219   /// Return selected text color
00220   FXColor getSelTextColor() const;
00221 
00222   /// Changes the cursor color
00223   void setCursorColor(FXColor clr);
00224 
00225   /// Return the cursor color
00226   FXColor getCursorColor() const;
00227 
00228   /// Change width of text field in terms of number of columns * `m'
00229   void setNumColumns(FXint cols);
00230 
00231   /// Return number of columns
00232   FXint getNumColumns() const;
00233 
00234   /// Save spinner to a stream
00235   virtual void save(FXStream& store) const;
00236 
00237   /// Load spinner from a stream
00238   virtual void load(FXStream& store);
00239 
00240   /// Destructor
00241   virtual ~FXRealSpinner();
00242   };
00243 
00244 }
00245 
00246 #endif

Copyright © 1997-2009 Jeroen van der Zijp