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

FXRealSpinner.h

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

Copyright © 1997-2005 Jeroen van der Zijp