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

FXSpinner.h

Go to the documentation of this file.
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,2006 by Lyle Johnson.   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.46 2006/02/06 03:03:40 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 private:
00061   FXSpinner(const FXSpinner&);
00062   FXSpinner& operator=(const FXSpinner&);
00063 public:
00064   long onUpdIncrement(FXObject*,FXSelector,void*);
00065   long onCmdIncrement(FXObject*,FXSelector,void*);
00066   long onUpdDecrement(FXObject*,FXSelector,void*);
00067   long onCmdDecrement(FXObject*,FXSelector,void*);
00068   long onCmdEntry(FXObject*,FXSelector,void*);
00069   long onChgEntry(FXObject*,FXSelector,void*);
00070   long onWheelEntry(FXObject*,FXSelector,void*);
00071   long onKeyPress(FXObject*,FXSelector,void*);
00072   long onKeyRelease(FXObject*,FXSelector,void*);
00073   long onCmdSetValue(FXObject*,FXSelector,void*);
00074   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00075   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00076   long onCmdSetIntRange(FXObject*,FXSelector,void*);
00077   long onCmdGetIntRange(FXObject*,FXSelector,void*);
00078   long onFocusSelf(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   /// Perform layout
00092   virtual void layout();
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(FXbool notify=FALSE);
00108 
00109   /// Increment spinner by certain amount
00110   void incrementByAmount(FXint amount,FXbool notify=FALSE);
00111 
00112   /// Decrement spinner
00113   void decrement(FXbool notify=FALSE);
00114 
00115   /// Decrement spinner by certain amount
00116   void decrementByAmount(FXint amount, FXbool notify=FALSE);
00117 
00118   /// Return TRUE if in cyclic mode
00119   FXbool isCyclic() const;
00120 
00121   /// Set to cyclic mode, i.e. wrap around at maximum/minimum
00122   void setCyclic(FXbool cyclic);
00123 
00124   /// Return TRUE if text is visible
00125   FXbool isTextVisible() const;
00126 
00127   /// Set text visible flag
00128   void setTextVisible(FXbool shown);
00129 
00130   /// Change current value
00131   virtual void setValue(FXint value,FXbool notify=FALSE);
00132 
00133   /// Return current value
00134   FXint getValue() const { return pos; }
00135 
00136   /// Change the spinner's range
00137   void setRange(FXint lo,FXint hi,FXbool notify=FALSE);
00138 
00139   /// Get the spinner's current range
00140   void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; }
00141 
00142   /// Change spinner increment
00143   void setIncrement(FXint increment);
00144 
00145   /// Return spinner increment
00146   FXint getIncrement() const { return incr; }
00147 
00148   /// Set the text font
00149   void setFont(FXFont *fnt);
00150 
00151   /// Get the text font
00152   FXFont *getFont() const;
00153 
00154   /// Set the status line help text for this spinner
00155   void setHelpText(const FXString& text);
00156 
00157   /// Get the status line help text for this spinner
00158   const FXString& getHelpText() const;
00159 
00160   /// Set the tool tip message for this spinner
00161   void setTipText(const FXString& text);
00162 
00163   /// Get the tool tip message for this spinner
00164   const FXString& getTipText() const;
00165 
00166   /// Change spinner style
00167   void setSpinnerStyle(FXuint style);
00168 
00169   /// Return current spinner style
00170   FXuint getSpinnerStyle() const;
00171 
00172   /// Allow editing of the text field
00173   void setEditable(FXbool edit=TRUE);
00174 
00175   /// Return TRUE if text field is editable
00176   FXbool isEditable() const;
00177 
00178   /// Change color of the up arrow
00179   void setUpArrowColor(FXColor clr);
00180 
00181   /// Return color of the up arrow
00182   FXColor getUpArrowColor() const;
00183 
00184   /// Change color of the down arrow
00185   void setDownArrowColor(FXColor clr);
00186 
00187   /// Return color of the the down arrow
00188   FXColor getDownArrowColor() const;
00189 
00190   /// Change text color
00191   void setTextColor(FXColor clr);
00192 
00193   /// Return text color
00194   FXColor getTextColor() const;
00195 
00196   /// Change selected background color
00197   void setSelBackColor(FXColor clr);
00198 
00199   /// Return selected background color
00200   FXColor getSelBackColor() const;
00201 
00202   /// Change selected text color
00203   void setSelTextColor(FXColor clr);
00204 
00205   /// Return selected text color
00206   FXColor getSelTextColor() const;
00207 
00208   /// Changes the cursor color
00209   void setCursorColor(FXColor clr);
00210 
00211   /// Return the cursor color
00212   FXColor getCursorColor() const;
00213 
00214   /// Change width of text field in terms of number of columns * `m'
00215   void setNumColumns(FXint cols);
00216 
00217   /// Return number of columns
00218   FXint getNumColumns() const;
00219 
00220   /// Save spinner to a stream
00221   virtual void save(FXStream& store) const;
00222 
00223   /// Load spinner from a stream
00224   virtual void load(FXStream& store);
00225 
00226   /// Destructor
00227   virtual ~FXSpinner();
00228   };
00229 
00230 }
00231 
00232 #endif

Copyright © 1997-2005 Jeroen van der Zijp