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

FXSpinner.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                        S p i n   B u t t o n   W i d g e t                    *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2002 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: FXSpinner.h,v 1.30 2002/09/30 13:06:56 fox Exp $                         *
00023 ********************************************************************************/
00024 #ifndef FXSPINNER_H
00025 #define FXSPINNER_H
00026 
00027 #ifndef FXPACKER_H
00028 #include "FXPacker.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 // Spinner Options
00035 enum {
00036   SPIN_NORMAL  =  0,                // Normal, non-cyclic
00037   SPIN_CYCLIC  =  0x00020000,       // Cyclic spinner
00038   SPIN_NOTEXT  =  0x00040000,       // No text visible
00039   SPIN_NOMAX   =  0x00080000,       // Spin all the way up to infinity
00040   SPIN_NOMIN   =  0x00100000        // Spin all the way down to -infinity
00041   };
00042 
00043 
00044 class FXTextField;
00045 class FXArrowButton;
00046 
00047 
00048 /// Spinner control
00049 class FXAPI FXSpinner : public FXPacker {
00050   FXDECLARE(FXSpinner)
00051 protected:
00052   FXTextField   *textField;         // Text field
00053   FXArrowButton *upButton;          // The up button
00054   FXArrowButton *downButton;        // The down button
00055   FXint          range[2];          // Reported data range
00056   FXint          incr;              // Increment
00057   FXint          pos;               // Current position
00058 protected:
00059   FXSpinner();
00060   virtual void layout();
00061 private:
00062   FXSpinner(const FXSpinner&);
00063   FXSpinner& operator=(const FXSpinner&);
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 onCmdEntry(FXObject*,FXSelector,void*);
00071   long onChgEntry(FXObject*,FXSelector,void*);
00072   long onKeyPress(FXObject*,FXSelector,void*);
00073   long onKeyRelease(FXObject*,FXSelector,void*);
00074   long onCmdSetValue(FXObject*,FXSelector,void*);
00075   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00076   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00077   long onCmdSetIntRange(FXObject*,FXSelector,void*);
00078   long onCmdGetIntRange(FXObject*,FXSelector,void*);
00079 public:
00080   enum{
00081     ID_INCREMENT=FXPacker::ID_LAST,
00082     ID_DECREMENT,
00083     ID_ENTRY,
00084     ID_LAST
00085     };
00086 public:
00087 
00088   /// Construct a spinner
00089   FXSpinner(FXComposite *p,FXint cols,FXObject *tgt=NULL,FXSelector sel=0,FXuint opts=SPIN_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);
00090 
00091   /// Create server-side resources
00092   virtual void create();
00093 
00094   /// Disable spinner
00095   virtual void disable();
00096 
00097   /// Enable spinner
00098   virtual void enable();
00099 
00100   /// Return default width
00101   virtual FXint getDefaultWidth();
00102 
00103   /// Return default height
00104   virtual FXint getDefaultHeight();
00105 
00106   /// Increment spinner
00107   void increment();
00108 
00109   /// Decrement spinner
00110   void decrement();
00111 
00112   /// Return TRUE if in cyclic mode
00113   FXbool isCyclic() const;
00114 
00115   /// Set to cyclic mode, i.e. wrap around at maximum/minimum
00116   void setCyclic(FXbool cyclic);
00117 
00118   /// Return TRUE if text is visible
00119   FXbool isTextVisible() const;
00120 
00121   /// Set text visible flag
00122   void setTextVisible(FXbool shown);
00123 
00124   /// Change current value
00125   virtual void setValue(FXint value);
00126 
00127   /// Return current value
00128   FXint getValue() const { return pos; }
00129 
00130   /// Change the spinner's range
00131   void setRange(FXint lo,FXint hi);
00132 
00133   /// Get the spinner's current range
00134   void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; }
00135 
00136   /// Change spinner increment
00137   void setIncrement(FXint increment);
00138 
00139   /// Return spinner increment
00140   FXint getIncrement() const { return incr; }
00141 
00142   /// Set the text font
00143   void setFont(FXFont *fnt);
00144 
00145   /// Get the text font
00146   FXFont *getFont() const;
00147 
00148   /// Set the status line help text for this spinner
00149   void setHelpText(const FXString& text);
00150 
00151   /// Get the status line help text for this spinner
00152   const FXString& getHelpText() const;
00153 
00154   /// Set the tool tip message for this spinner
00155   void setTipText(const FXString& text);
00156 
00157   /// Get the tool tip message for this spinner
00158   const FXString& getTipText() const;
00159 
00160   /// Change spinner style
00161   void setSpinnerStyle(FXuint style);
00162 
00163   /// Return current spinner style
00164   FXuint getSpinnerStyle() const;
00165 
00166   /// Allow editing of the text field
00167   void setEditable(FXbool edit=TRUE);
00168 
00169   /// Return TRUE if text field is editable
00170   FXbool isEditable() const;
00171 
00172   /// Save spinner to a stream
00173   virtual void save(FXStream& store) const;
00174 
00175   /// Load spinner from a stream
00176   virtual void load(FXStream& store);
00177 
00178   /// Destructor
00179   virtual ~FXSpinner();
00180   };
00181 
00182 }
00183 
00184 #endif