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,2004 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.40 2004/02/08 17:17:34 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 onUpdEntry(FXObject*,FXSelector,void*); 00069 long onCmdEntry(FXObject*,FXSelector,void*); 00070 long onChgEntry(FXObject*,FXSelector,void*); 00071 long onWheelEntry(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 long onFocusSelf(FXObject*,FXSelector,void*); 00080 public: 00081 enum{ 00082 ID_INCREMENT=FXPacker::ID_LAST, 00083 ID_DECREMENT, 00084 ID_ENTRY, 00085 ID_LAST 00086 }; 00087 public: 00088 00089 /// Construct a spinner 00090 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); 00091 00092 /// Perform layout 00093 virtual void layout(); 00094 00095 /// Disable spinner 00096 virtual void disable(); 00097 00098 /// Enable spinner 00099 virtual void enable(); 00100 00101 /// Return default width 00102 virtual FXint getDefaultWidth(); 00103 00104 /// Return default height 00105 virtual FXint getDefaultHeight(); 00106 00107 /// Increment spinner 00108 void increment(); 00109 00110 /// Decrement spinner 00111 void decrement(); 00112 00113 /// Return TRUE if in cyclic mode 00114 FXbool isCyclic() const; 00115 00116 /// Set to cyclic mode, i.e. wrap around at maximum/minimum 00117 void setCyclic(FXbool cyclic); 00118 00119 /// Return TRUE if text is visible 00120 FXbool isTextVisible() const; 00121 00122 /// Set text visible flag 00123 void setTextVisible(FXbool shown); 00124 00125 /// Change current value 00126 virtual void setValue(FXint value); 00127 00128 /// Return current value 00129 FXint getValue() const { return pos; } 00130 00131 /// Change the spinner's range 00132 void setRange(FXint lo,FXint hi); 00133 00134 /// Get the spinner's current range 00135 void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; } 00136 00137 /// Change spinner increment 00138 void setIncrement(FXint increment); 00139 00140 /// Return spinner increment 00141 FXint getIncrement() const { return incr; } 00142 00143 /// Set the text font 00144 void setFont(FXFont *fnt); 00145 00146 /// Get the text font 00147 FXFont *getFont() const; 00148 00149 /// Set the status line help text for this spinner 00150 void setHelpText(const FXString& text); 00151 00152 /// Get the status line help text for this spinner 00153 FXString getHelpText() const; 00154 00155 /// Set the tool tip message for this spinner 00156 void setTipText(const FXString& text); 00157 00158 /// Get the tool tip message for this spinner 00159 FXString getTipText() const; 00160 00161 /// Change spinner style 00162 void setSpinnerStyle(FXuint style); 00163 00164 /// Return current spinner style 00165 FXuint getSpinnerStyle() const; 00166 00167 /// Allow editing of the text field 00168 void setEditable(FXbool edit=TRUE); 00169 00170 /// Return TRUE if text field is editable 00171 FXbool isEditable() const; 00172 00173 /// Change color of the up arrow 00174 void setUpArrowColor(FXColor clr); 00175 00176 /// Return color of the up arrow 00177 FXColor getUpArrowColor() const; 00178 00179 /// Change color of the down arrow 00180 void setDownArrowColor(FXColor clr); 00181 00182 /// Return color of the the down arrow 00183 FXColor getDownArrowColor() const; 00184 00185 /// Change text color 00186 void setTextColor(FXColor clr); 00187 00188 /// Return text color 00189 FXColor getTextColor() const; 00190 00191 /// Change selected background color 00192 void setSelBackColor(FXColor clr); 00193 00194 /// Return selected background color 00195 FXColor getSelBackColor() const; 00196 00197 /// Change selected text color 00198 void setSelTextColor(FXColor clr); 00199 00200 /// Return selected text color 00201 FXColor getSelTextColor() const; 00202 00203 /// Changes the cursor color 00204 void setCursorColor(FXColor clr); 00205 00206 /// Return the cursor color 00207 FXColor getCursorColor() const; 00208 00209 /// Change width of text field in terms of number of columns * `m' 00210 void setNumColumns(FXint cols); 00211 00212 /// Return number of columns 00213 FXint getNumColumns() const; 00214 00215 /// Save spinner to a stream 00216 virtual void save(FXStream& store) const; 00217 00218 /// Load spinner from a stream 00219 virtual void load(FXStream& store); 00220 00221 /// Destructor 00222 virtual ~FXSpinner(); 00223 }; 00224 00225 } 00226 00227 #endif

Copyright © 1997-2004 Jeroen van der Zijp