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,2005 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.43 2005/01/16 16:06:06 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(); 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 /// Change color of the up arrow 00173 void setUpArrowColor(FXColor clr); 00174 00175 /// Return color of the up arrow 00176 FXColor getUpArrowColor() const; 00177 00178 /// Change color of the down arrow 00179 void setDownArrowColor(FXColor clr); 00180 00181 /// Return color of the the down arrow 00182 FXColor getDownArrowColor() const; 00183 00184 /// Change text color 00185 void setTextColor(FXColor clr); 00186 00187 /// Return text color 00188 FXColor getTextColor() const; 00189 00190 /// Change selected background color 00191 void setSelBackColor(FXColor clr); 00192 00193 /// Return selected background color 00194 FXColor getSelBackColor() const; 00195 00196 /// Change selected text color 00197 void setSelTextColor(FXColor clr); 00198 00199 /// Return selected text color 00200 FXColor getSelTextColor() const; 00201 00202 /// Changes the cursor color 00203 void setCursorColor(FXColor clr); 00204 00205 /// Return the cursor color 00206 FXColor getCursorColor() const; 00207 00208 /// Change width of text field in terms of number of columns * `m' 00209 void setNumColumns(FXint cols); 00210 00211 /// Return number of columns 00212 FXint getNumColumns() const; 00213 00214 /// Save spinner to a stream 00215 virtual void save(FXStream& store) const; 00216 00217 /// Load spinner from a stream 00218 virtual void load(FXStream& store); 00219 00220 /// Destructor 00221 virtual ~FXSpinner(); 00222 }; 00223 00224 } 00225 00226 #endif

Copyright © 1997-2005 Jeroen van der Zijp