FXRealSpinDial.cpp

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *       R e a l - V a l u e d   S p i n n e r / D i a l    W i d g e t          *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2004 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: FXRealSpinDial.cpp 8236 2010-02-10 11:16:41Z behrisch $                   *
00023 ********************************************************************************/
00024 /* =========================================================================
00025  * included modules
00026  * ======================================================================= */
00027 #ifdef _MSC_VER
00028 #include <windows_config.h>
00029 #else
00030 #include <config.h>
00031 #endif
00032 
00033 #include <fx.h>
00034 #include "xincs.h"
00035 #include "fxver.h"
00036 #include "fxdefs.h"
00037 #include "fxkeys.h"
00038 #include "FXStream.h"
00039 #include "FXString.h"
00040 #include "FXSize.h"
00041 #include "FXPoint.h"
00042 #include "FXRectangle.h"
00043 #include "FXRegistry.h"
00044 #include "FXAccelTable.h"
00045 #include "FXApp.h"
00046 #include "FXLabel.h"
00047 #include "FXTextField.h"
00048 #include "FXDial.h"
00049 #include "FXRealSpinDial.h"
00050 
00051 #include <float.h>
00052 
00053 #ifdef CHECK_MEMORY_LEAKS
00054 #include <foreign/nvwa/debug_new.h>
00055 #endif // CHECK_MEMORY_LEAKS
00056 /*
00057   Notes:
00058   - Based originally on Lyle's FXSpinner.
00059   - Can use with spin buttons, dial, or both, and with or without text
00060   - Three increment levels, fine, normal, and coarse.  Access different modes
00061     with CONTROL key (fine control) and SHIFT key (coarse mode).  Modifiers
00062     affect all of up/down keys, mousewheel, dial and spinbuttons.
00063   - Can specify display format for text either as a precision,showExponent pair
00064     or an sprintf format string.  (String format can include extra text like '$'!)
00065   - Wheel mouse increment/decrement in even multiples of fine/norm/coarse scales.
00066     (Key modifers sometimes require mouse motion to kick in because FOX doesn't
00067      have a [public] way to query the key state asynchronously.  Hacked extern to
00068      FOX's internal WIN32 function for querying this, so it works on Win32)
00069   - Dial warps the pointer at the edge of the screen so you don't run out of
00070     screen real estate.
00071 */
00072 #define DIALINCR    160
00073 #define DIALMULT    40
00074 #define DIALWIDTH   12
00075 #define BUTTONWIDTH 12
00076 #define GAPWIDTH     1
00077 
00078 #define INTMAX  2147483647
00079 #define INTMIN  (-INTMAX-1)
00080 
00081 #define SPINDIAL_MASK (SPINDIAL_CYCLIC|SPINDIAL_NOTEXT|SPINDIAL_NOBUTTONS|SPINDIAL_NODIAL|SPINDIAL_NOMAX|SPINDIAL_NOMIN|SPINDIAL_LOG)
00082 
00083 using namespace FX;
00084 
00085 /*******************************************************************************/
00086 /*  Custom FXDial subclass                                                     */
00087 /*******************************************************************************/
00088 namespace FX {
00089 class FXRealSpinDialDial : public FXDial {
00090     FXDECLARE(FXRealSpinDialDial)
00091 protected:
00092     FXRealSpinDialDial() {}
00093 private:
00094     FXRealSpinDialDial(const FXRealSpinDialDial&);
00095     FXRealSpinDialDial &operator=(const FXRealSpinDialDial&);
00096 public:
00097     //long onDefault(FXObject*,FXSelector,void* );
00098     long onKey(FXObject*,FXSelector,void*);
00099     long onButtonPress(FXObject*,FXSelector,void*);
00100     long onButtonRelease(FXObject*,FXSelector,void*);
00101     long onRightButtonPress(FXObject*,FXSelector,void*);
00102     long onRightButtonRelease(FXObject*,FXSelector,void*);
00103     long onMotion(FXObject*,FXSelector,void*);
00104     long onAuto(FXObject*,FXSelector,void*);
00105     enum {
00106         ID_AUTOSPIN=FXDial::ID_LAST,
00107         ID_LAST
00108     };
00109 public:
00110 
00112     FXRealSpinDialDial(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=DIAL_NORMAL,
00113                        FXint x=0,FXint y=0,FXint w=0,FXint h=0,
00114                        FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD):
00115             FXDial(p,tgt,sel,opts,x,y,w,h,pl,pr,pt,pb) {}
00116 
00117 };
00118 
00119 FXDEFMAP(FXRealSpinDialDial) FXSpinDialMap[]={
00120     FXMAPFUNC(SEL_KEYPRESS,0,  FXRealSpinDialDial::onKey),
00121     FXMAPFUNC(SEL_KEYRELEASE,0,  FXRealSpinDialDial::onKey),
00122     FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,  FXRealSpinDialDial::onButtonPress),
00123     FXMAPFUNC(SEL_RIGHTBUTTONRELEASE,0,  FXRealSpinDialDial::onRightButtonRelease),
00124     FXMAPFUNC(SEL_RIGHTBUTTONPRESS,0,  FXRealSpinDialDial::onRightButtonPress),
00125     FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,  FXRealSpinDialDial::onButtonRelease),
00126     FXMAPFUNC(SEL_MOTION,0,  FXRealSpinDialDial::onMotion),
00127 
00128     FXMAPFUNC(SEL_TIMEOUT,FXRealSpinDialDial::ID_AUTOSPIN, FXRealSpinDialDial::onAuto),
00129 
00130     //FXMAPFUNC(SEL_KEYPRESS,0,  FXRealSpinDialDial::onKeyPress),
00131     //FXMAPFUNC(SEL_KEYRELEASE,0,FXRealSpinDialDial::onKeyRelease),
00132 };
00133 FXIMPLEMENT(FXRealSpinDialDial,FXDial,FXSpinDialMap,ARRAYNUMBER(FXSpinDialMap))
00134 //FXIMPLEMENT(FXRealSpinDialDial,FXDial,0,0)
00135 
00136 //long FXRealSpinDialDial::onDefault(FXObject*o,FXSelector s,void*p )
00137 //{
00138 //  printf("DEFAULT!\n");
00139 //  if (target) return target->handle(o,s,p);
00140 //  return 0;
00141 //}
00142 long FXRealSpinDialDial::onKey(FXObject*o,FXSelector s,void*p) {
00143     if (target) return target->handle(o,s,p);
00144     return 0;
00145 }
00146 long FXRealSpinDialDial::onButtonPress(FXObject*o,FXSelector s,void*p) {
00147     grabKeyboard();
00148     return FXDial::onLeftBtnPress(o,s,p);
00149 }
00150 long FXRealSpinDialDial::onButtonRelease(FXObject*o,FXSelector s,void*p) {
00151     ungrabKeyboard();
00152     return FXDial::onLeftBtnRelease(o,s,p);
00153 }
00154 long FXRealSpinDialDial::onRightButtonPress(FXObject*o,FXSelector s,void*p) {
00155     if (isEnabled()) {
00156         grab();
00157         grabKeyboard();
00158         //if(target && target->handle(this,FXSEL(SEL_RIGHTBUTTONPRESS,message),ptr)) return 1;
00159         FXEvent *event = (FXEvent*)p;
00160         if (options&DIAL_HORIZONTAL)
00161             dragpoint=event->win_x;
00162         else
00163             dragpoint=event->win_y;
00164         getApp()->addTimeout(this,ID_AUTOSPIN,getApp()->getScrollSpeed());
00165     }
00166     return 1;
00167 }
00168 long FXRealSpinDialDial::onRightButtonRelease(FXObject*o,FXSelector s,void*p) {
00169     ungrab();
00170     ungrabKeyboard();
00171     getApp()->removeTimeout(this,ID_AUTOSPIN);
00172     if (isEnabled()) {
00173         //if(target && target->handle(this,FXSEL(SEL_RIGHTBUTTONRELEASE,message),p)) return 1;
00174     }
00175     return 1;
00176 
00177 }
00178 long FXRealSpinDialDial::onAuto(FXObject*o,FXSelector s,void*p) {
00179     getApp()->addTimeout(this,ID_AUTOSPIN,getApp()->getScrollSpeed());
00180     setValue(getValue()+int((dragpoint-dragpos)/float(5)));
00181     int v = getValue();
00182     if (target) target->handle(this,FXSEL(SEL_CHANGED,message),&v);
00183     return 1;
00184 }
00185 
00186 long FXRealSpinDialDial::onMotion(FXObject*o,FXSelector s,void*p) {
00187     if (!isEnabled()) return 0;
00188     if (target && target->handle(this,FXSEL(SEL_MOTION,message),p)) return 1;
00189 
00190     FXbool bJump=FALSE;
00191     FXEvent *e = (FXEvent*)p;
00192     if (!(flags&FLAG_PRESSED)) { // not doing clickdrag
00193         dragpos = e->win_y;
00194     }
00195     FXWindow *rootWin= getApp()->getRootWindow();
00196     FXint x = e->root_x, y = e->root_y;
00197     if (e->root_x >= rootWin->getWidth()-1)  {
00198         x-=40;
00199         dragpoint-=40;
00200         bJump=TRUE;
00201     } else if (e->root_x <= 10)                {
00202         x+=40;
00203         dragpoint+=40;
00204         bJump=TRUE;
00205     }
00206     if (e->root_y >= rootWin->getHeight()-1) {
00207         y-=40;
00208         dragpoint-=40;
00209         bJump=TRUE;
00210     } else if (e->root_y <= 10)                {
00211         y+=40;
00212         dragpoint+=40;
00213         bJump=TRUE;
00214     }
00215     if (bJump) {
00216         rootWin->setCursorPosition(x,y);
00217         return 1;
00218     } else
00219         return FXDial::onMotion(o,s,p);
00220 }
00221 
00222 }
00223 
00224 /*******************************************************************************/
00225 /*  Custom FXArrowButton subclass                                              */
00226 /*******************************************************************************/
00227 namespace FX {
00228 class FXRealSpinDialBtn : public FXArrowButton {
00229     FXDECLARE(FXRealSpinDialBtn)
00230 protected:
00231     FXRealSpinDialBtn() {}
00232 private:
00233     FXRealSpinDialBtn(const FXRealSpinDialBtn&);
00234     FXRealSpinDialBtn &operator=(const FXRealSpinDialBtn&);
00235 public:
00236     //long onDefault(FXObject*,FXSelector,void* );
00237     long onKey(FXObject*,FXSelector,void*);
00238     long onButtonPress(FXObject*,FXSelector,void*);
00239     long onButtonRelease(FXObject*,FXSelector,void*);
00240     enum {
00241         ID_AUTOSPIN=FXDial::ID_LAST,
00242         ID_LAST
00243     };
00244 public:
00245 
00247     FXRealSpinDialBtn(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,
00248                       FXuint opts=ARROW_NORMAL,
00249                       FXint x=0,FXint y=0,FXint w=0,FXint h=0,
00250                       FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD):
00251             FXArrowButton(p,tgt,sel,opts,x,y,w,h,pl,pr,pt,pb) {}
00252 
00253 };
00254 
00255 FXDEFMAP(FXRealSpinDialBtn) FXSpinDialBtnMap[]={
00256     FXMAPFUNC(SEL_KEYPRESS,0,  FXRealSpinDialBtn::onKey),
00257     FXMAPFUNC(SEL_KEYRELEASE,0,  FXRealSpinDialBtn::onKey),
00258     FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,  FXRealSpinDialBtn::onButtonPress),
00259     FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,  FXRealSpinDialBtn::onButtonRelease),
00260 
00261 
00262     //FXMAPFUNC(SEL_KEYPRESS,0,  FXRealSpinDialBtn::onKeyPress),
00263     //FXMAPFUNC(SEL_KEYRELEASE,0,FXRealSpinDialBtn::onKeyRelease),
00264 };
00265 FXIMPLEMENT(FXRealSpinDialBtn,FXArrowButton,FXSpinDialBtnMap,ARRAYNUMBER(FXSpinDialBtnMap))
00266 //FXIMPLEMENT(FXRealSpinDialBtn,FXDial,0,0)
00267 
00268 //long FXRealSpinDialBtn::onDefault(FXObject*o,FXSelector s,void*p )
00269 //{
00270 //  printf("DEFAULT!\n");
00271 //  if (target) return target->handle(o,s,p);
00272 //  return 0;
00273 //}
00274 long FXRealSpinDialBtn::onKey(FXObject*o,FXSelector s,void*p) {
00275     if (target) return target->handle(o,s,p);
00276     return 0;
00277 }
00278 long FXRealSpinDialBtn::onButtonPress(FXObject*o,FXSelector s,void*p) {
00279     grabKeyboard();
00280     return FXArrowButton::onLeftBtnPress(o,s,p);
00281 }
00282 long FXRealSpinDialBtn::onButtonRelease(FXObject*o,FXSelector s,void*p) {
00283     ungrabKeyboard();
00284     return FXArrowButton::onLeftBtnRelease(o,s,p);
00285 }
00286 
00287 
00288 }
00289 
00290 
00291 /*******************************************************************************/
00292 /*  FXTextField subclass                                                       */
00293 /*******************************************************************************/
00294 
00295 namespace FX {
00296 class FXRealSpinDialText : public FXTextField {
00297     FXDECLARE(FXRealSpinDialText)
00298 protected:
00299     FXRealSpinDialText() {}
00300 private:
00301     FXRealSpinDialText(const FXRealSpinDialText&);
00302     FXRealSpinDialText &operator=(const FXRealSpinDialText&);
00303 public:
00304     long onCmdSetRealValue(FXObject*,FXSelector,void*);
00305     long onMotion(FXObject*,FXSelector,void*);
00306     enum {
00307         ID_LAST=FXTextField::ID_LAST
00308     };
00309     enum {
00310         FLAG_FMTSTRING = 0x1
00311     };
00312 public:
00313 
00315     FXRealSpinDialText(FXComposite* p,FXint ncols,FXObject* tgt=NULL,FXSelector sel=0,
00316                        FXuint opts=TEXTFIELD_NORMAL,
00317                        FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint
00318                        pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD
00319                       ) :
00320             FXTextField(p,ncols,tgt,sel,opts,x,y,w,h,pl,pr,pt,pb),
00321             precision(3),
00322             exponent(FALSE),
00323             flags(0) {}
00324 
00325     void setNumberFormat(FXint prec, FXbool bExp=FALSE) {
00326         precision=prec;
00327         exponent=bExp;
00328         flags &= ~FLAG_FMTSTRING;
00329     }
00330     FXint getNumberFormatPrecision() const {
00331         return precision;
00332     }
00333     FXbool getNumberFormatExponent() const {
00334         return exponent;
00335     }
00336     void setFormatString(FXchar *fmt) {
00337         fmtString = fmt;
00338         flags |= FLAG_FMTSTRING;
00339     }
00340     FXString getNumberFormatString() const {
00341         return fmtString;
00342     }
00343 
00344 protected:
00345     FXint precision;
00346     FXbool exponent;
00347     FXString fmtString;
00348     FXuint flags;
00349 };
00350 
00351 FXDEFMAP(FXRealSpinDialText) FXSpinDialTextMap[]={
00352     FXMAPFUNC(SEL_MOTION, 0,  FXRealSpinDialText::onMotion),
00353     FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETREALVALUE,  FXRealSpinDialText::onCmdSetRealValue),
00354 };
00355 FXIMPLEMENT(FXRealSpinDialText,FXTextField,FXSpinDialTextMap,ARRAYNUMBER(FXSpinDialTextMap))
00356 
00357 long FXRealSpinDialText::onMotion(FXObject*o,FXSelector s,void*ptr) {
00358     // Forward motion events so we can monitor key state.  We don't get the modifier
00359     // keys themselves if we aren't focused, so this seems the best we can do.
00360     if (!isEnabled()) return 0;
00361     if (target && target->handle(this,FXSEL(SEL_MOTION,message),ptr)) return 1;
00362     return FXTextField::onMotion(o,s,ptr);
00363 }
00364 long FXRealSpinDialText::onCmdSetRealValue(FXObject*o,FXSelector s,void*ptr) {
00365     //  setText(FXStringVal(*((FXdouble*)ptr)));
00366     if (flags & FLAG_FMTSTRING)
00367         setText(FXStringFormat(fmtString.text(),*((FXdouble*)ptr)));
00368     else {
00369         setText(FXStringVal(*((FXdouble*)ptr),precision,exponent));
00370     }
00371     return 1;
00372 }
00373 
00374 }
00375 
00376 /*******************************************************************************/
00377 /*  FXRealSpinDial                                                          */
00378 /*******************************************************************************/
00379 
00380 namespace FX {
00381 
00382 //  Message map
00383 FXDEFMAP(FXRealSpinDial) FXRealSpinDialMap[]={
00384     FXMAPFUNC(SEL_KEYPRESS,0,  FXRealSpinDial::onKeyPress),
00385     FXMAPFUNC(SEL_KEYRELEASE,0,FXRealSpinDial::onKeyRelease),
00386     FXMAPFUNC(SEL_MOTION,0,FXRealSpinDial::onMotion),
00387     FXMAPFUNC(SEL_MOTION,FXRealSpinDial::ID_ENTRY,FXRealSpinDial::onMotion),
00388     FXMAPFUNC(SEL_MOTION,FXRealSpinDial::ID_DIAL,FXRealSpinDial::onMotion),
00389     FXMAPFUNC(SEL_UPDATE, FXRealSpinDial::ID_ENTRY,FXRealSpinDial::onUpdEntry),
00390     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_ENTRY,FXRealSpinDial::onCmdEntry),
00391     FXMAPFUNC(SEL_CHANGED,FXRealSpinDial::ID_ENTRY,FXRealSpinDial::onChgEntry),
00392     FXMAPFUNC(SEL_UPDATE, FXRealSpinDial::ID_DIAL,FXRealSpinDial::onUpdDial),
00393     FXMAPFUNC(SEL_CHANGED,FXRealSpinDial::ID_DIAL,FXRealSpinDial::onChgDial),
00394     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_DIAL,FXRealSpinDial::onCmdDial),
00395     FXMAPFUNC(SEL_MOUSEWHEEL,FXRealSpinDial::ID_ENTRY,FXRealSpinDial::onMouseWheel),
00396     FXMAPFUNC(SEL_MOUSEWHEEL,FXRealSpinDial::ID_DIAL,FXRealSpinDial::onMouseWheel),
00397     FXMAPFUNC(SEL_MOUSEWHEEL,FXRealSpinDial::ID_INCREMENT,FXRealSpinDial::onMouseWheel),
00398     FXMAPFUNC(SEL_MOUSEWHEEL,FXRealSpinDial::ID_DECREMENT,FXRealSpinDial::onMouseWheel),
00399     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_SETVALUE, FXRealSpinDial::onCmdSetValue),
00400     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_SETINTVALUE,FXRealSpinDial::onCmdSetIntValue),
00401     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_GETINTVALUE,FXRealSpinDial::onCmdGetIntValue),
00402     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_SETINTRANGE,FXRealSpinDial::onCmdSetIntRange),
00403     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_GETINTRANGE,FXRealSpinDial::onCmdGetIntRange),
00404     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_SETREALVALUE,FXRealSpinDial::onCmdSetRealValue),
00405     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_GETREALVALUE,FXRealSpinDial::onCmdGetRealValue),
00406     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_SETREALRANGE,FXRealSpinDial::onCmdSetRealRange),
00407     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_GETREALRANGE,FXRealSpinDial::onCmdGetRealRange),
00408     FXMAPFUNC(SEL_UPDATE, FXRealSpinDial::ID_INCREMENT,FXRealSpinDial::onUpdIncrement),
00409     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_INCREMENT,FXRealSpinDial::onCmdIncrement),
00410     FXMAPFUNC(SEL_UPDATE, FXRealSpinDial::ID_DECREMENT,FXRealSpinDial::onUpdDecrement),
00411     FXMAPFUNC(SEL_COMMAND,FXRealSpinDial::ID_DECREMENT,FXRealSpinDial::onCmdDecrement),
00412 };
00413 
00414 
00415 // Object implementation
00416 FXIMPLEMENT(FXRealSpinDial,FXPacker,FXRealSpinDialMap,ARRAYNUMBER(FXRealSpinDialMap))
00417 
00418 
00419 // Construct spinner out of two buttons and a text field
00420 FXRealSpinDial::FXRealSpinDial() {
00421     flags=(flags|FLAG_ENABLED|FLAG_SHOWN)&~FLAG_UPDATE;
00422     textField=(FXRealSpinDialText*)-1L;
00423     dial=(FXDial*)-1L;
00424     upButton=(FXRealSpinDialBtn*)-1L;
00425     downButton=(FXRealSpinDialBtn*)-1L;
00426     range[0]=-DBL_MAX;
00427     range[1]= DBL_MAX;
00428     incr[0]=0.1;
00429     incr[1]=1.0;
00430     incr[2]=10;
00431     pos=1;
00432     dialpos=0;
00433 }
00434 
00435 
00436 // Construct spinner out of dial and a text field
00437 FXRealSpinDial::FXRealSpinDial(FXComposite *p,FXint cols,FXObject *tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):
00438         FXPacker(p,opts&~(FRAME_RIDGE),x,y,w,h,0,0,0,0,0,0) {
00439     flags=(flags|FLAG_ENABLED|FLAG_SHOWN)&~FLAG_UPDATE;
00440     target=tgt;
00441     message=sel;
00442     dial=new FXRealSpinDialDial(this,this,ID_DIAL,DIAL_VERTICAL, 0,0,0,0, 0,0,0,0);
00443     dial->setNotchSpacing(450);
00444     dial->setRevolutionIncrement(DIALINCR);
00445     upButton=new FXRealSpinDialBtn(this,this,ID_INCREMENT,FRAME_RAISED|FRAME_THICK|ARROW_UP|ARROW_REPEAT, 0,0,0,0, 0,0,0,0);
00446     downButton=new FXRealSpinDialBtn(this,this,ID_DECREMENT,FRAME_RAISED|FRAME_THICK|ARROW_DOWN|ARROW_REPEAT, 0,0,0,0, 0,0,0,0);
00447     textField=new FXRealSpinDialText(this,cols,this,ID_ENTRY,(opts&FRAME_RIDGE)|TEXTFIELD_REAL|JUSTIFY_RIGHT,0,0,0,0,pl,pr,pt,pb);
00448     textField->setText("0");
00449     range[0]=(options&SPINDIAL_NOMIN) ? -DBL_MAX : 0;
00450     range[1]=(options&SPINDIAL_NOMAX) ?  DBL_MAX : 100;
00451     dial->setRange(INTMIN,INTMAX);
00452     dialpos=dial->getValue();
00453     incr[0]=0.1;
00454     incr[1]=1.0;
00455     incr[2]=10;
00456     pos=0;
00457     keystate=0;
00458 }
00459 
00460 
00461 // Get default width
00462 FXint FXRealSpinDial::getDefaultWidth() {
00463     FXint tw=0;
00464     if (!(options&SPINDIAL_NOTEXT)) tw=textField->getDefaultWidth();
00465     return tw+DIALWIDTH+GAPWIDTH+(border<<1);
00466 }
00467 
00468 
00469 // Get default height
00470 FXint FXRealSpinDial::getDefaultHeight() {
00471     return textField->getDefaultHeight()+(border<<1);
00472 }
00473 
00474 
00475 // Create window
00476 void FXRealSpinDial::create() {
00477     FXPacker::create();
00478 }
00479 
00480 
00481 // Enable the widget
00482 void FXRealSpinDial::enable() {
00483     if (!(flags&FLAG_ENABLED)) {
00484         FXPacker::enable();
00485         textField->enable();
00486         dial->enable();
00487     }
00488 }
00489 
00490 
00491 // Disable the widget
00492 void FXRealSpinDial::disable() {
00493     if (flags&FLAG_ENABLED) {
00494         FXPacker::disable();
00495         textField->disable();
00496         dial->disable();
00497     }
00498 }
00499 
00500 
00501 // Recompute layout
00502 void FXRealSpinDial::layout() {
00503     FXint dialWidth,dialHeight,buttonWidth,buttonHeight,textHeight;
00504 
00505     textHeight=height-2*border;
00506     dialHeight=textHeight;
00507     buttonHeight=textHeight>>1;
00508 
00509     FXuint hideOpts = SPINDIAL_NOTEXT|SPINDIAL_NODIAL|SPINDIAL_NOBUTTONS;
00510     if ((options&hideOpts) == hideOpts) {
00511         flags&=~FLAG_DIRTY;
00512         return; // nothing to layout
00513     }
00514 
00515     FXint right = width-border;
00516 
00517     if (options&SPINDIAL_NOTEXT) {
00518         // Dial takes up the extra space if shown, otherwise spinbuttons
00519         if (!(options&SPINDIAL_NODIAL)) {
00520             // HAS DIAL
00521             int left=border;
00522             if (!(options&SPINDIAL_NOBUTTONS)) {
00523                 FXint bw=BUTTONWIDTH;
00524                 upButton->position(border,border,bw,buttonHeight);
00525                 downButton->position(border,height-buttonHeight-border,bw,buttonHeight);
00526                 left+=bw+GAPWIDTH;
00527             }
00528             dial->position(left,border,right-left,dialHeight);
00529         } else {
00530             FXint w=BUTTONWIDTH;
00531             upButton->position(border,border,right-border,buttonHeight);
00532             downButton->position(border,height-buttonHeight-border,right-border,buttonHeight);
00533         }
00534     } else {
00535         // dial/buttons are default width, text stretches to fill the rest
00536         dialWidth=buttonWidth=0;
00537         if (!(options&SPINDIAL_NODIAL)) {
00538             FXint w=DIALWIDTH;
00539             dial->position(right-w,border,w,dialHeight);
00540             right -= w+GAPWIDTH;
00541         }
00542         if (!(options&SPINDIAL_NOBUTTONS)) {
00543             FXint w=BUTTONWIDTH;
00544             upButton->position(right-w,border,w,buttonHeight);
00545             downButton->position(right-w,height-buttonHeight-border,w,buttonHeight);
00546             right -= w + GAPWIDTH;
00547         }
00548         textField->position(border,border,right-border,textHeight);
00549     }
00550     flags&=~FLAG_DIRTY;
00551 }
00552 
00553 
00554 // Respond to dial message
00555 long FXRealSpinDial::onUpdDial(FXObject* sender,FXSelector,void*) {
00556     if (isEnabled() && ((options&SPINDIAL_CYCLIC) || (pos<=range[1])))
00557         sender->handle(this,FXSEL(SEL_COMMAND,ID_ENABLE),NULL);
00558     else
00559         sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),NULL);
00560     return 1;
00561 }
00562 
00563 
00564 // Respond to dial message
00565 long FXRealSpinDial::onChgDial(FXObject*p,FXSelector sel,void*ptr) {
00566     if (!isEnabled()) return 0;
00567     FXdouble newpos;
00568     FXdouble inc;
00569     if (FXApp::instance()->getKeyState(CONTROLMASK))    inc = incr[0];
00570     else if (FXApp::instance()->getKeyState(SHIFTMASK)) inc = incr[2];
00571     else                         inc = incr[1];
00572     FXint dialdelta = dial->getValue()-dialpos;
00573     if (options&SPINDIAL_LOG) {
00574         newpos = pos * pow(inc , DIALMULT * FXdouble(dialdelta) / DIALINCR);
00575     } else {
00576         newpos = pos + DIALMULT * inc * (dialdelta) / DIALINCR;
00577     }
00578     // Now clamp newpos.
00579     if (dialdelta>0) {
00580         if (options&SPINDIAL_LOG) {
00581             if (options&SPINDIAL_CYCLIC && newpos>range[1]) {
00582                 FXdouble lr0=log(range[0]), lr1=log(range[1]), lnp=log(newpos);
00583                 newpos = exp(lr0 + fmod(lnp-lr0, lr1-lr0)) ;
00584             }
00585         } else {
00586             if (options&SPINDIAL_CYCLIC) {
00587                 newpos = range[0] + fmod(newpos-range[0], range[1]-range[0]+1) ;
00588             }
00589         }
00590     } else {
00591         if (options&SPINDIAL_LOG) {
00592             if (options&SPINDIAL_CYCLIC  && newpos<range[0]) {
00593                 FXdouble lr0=log(range[0]), lr1=log(range[1]), lnp=log(newpos), lpos=log(pos);
00594                 FXdouble span=lr1-lr0;
00595                 newpos = exp(lr0 + fmod(lpos-lr0+1+(span-inc), span));
00596             }
00597         } else {
00598             if (options&SPINDIAL_CYCLIC) {
00599                 newpos = range[0] + fmod(pos+(range[1]-range[0]+1+(newpos-pos)-range[0]) , range[1]-range[0]+1);
00600             }
00601         }
00602     }
00603     setValue(newpos);
00604     if (target) target->handle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
00605     dialpos = dial->getValue();
00606     return 1;
00607 }
00608 
00609 // Respond to dial message
00610 long FXRealSpinDial::onCmdDial(FXObject*,FXSelector sel,void*) {
00611     if (!isEnabled()) return 0;
00612     // if(target) target->handle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
00613     dialpos = dial->getValue() % DIALINCR;
00614     dial->setValue(dialpos);
00615     return 1;
00616 }
00617 
00618 
00619 // Respond to increment message
00620 long FXRealSpinDial::onUpdIncrement(FXObject* sender,FXSelector,void*) {
00621     if (isEnabled() && ((options&REALSPIN_CYCLIC) || (pos<range[1])))
00622         sender->handle(this,FXSEL(SEL_COMMAND,ID_ENABLE),NULL);
00623     else
00624         sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),NULL);
00625     return 1;
00626 }
00627 
00628 
00629 // Respond to increment message
00630 long FXRealSpinDial::onCmdIncrement(FXObject*,FXSelector,void*) {
00631     if (!isEnabled()) return 0;
00632     FXint mode;
00633     if (keystate&CONTROLMASK)    mode = SPINDIAL_INC_FINE;
00634     else if (keystate&SHIFTMASK) mode = SPINDIAL_INC_COARSE;
00635     else                         mode = SPINDIAL_INC_NORMAL;
00636     increment(mode);
00637     if (target) target->handle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
00638     return 1;
00639 }
00640 
00641 
00642 // Disable decrement if at low end already
00643 long FXRealSpinDial::onUpdDecrement(FXObject* sender,FXSelector,void*) {
00644     if (isEnabled() && ((options&REALSPIN_CYCLIC) || (range[0]<pos)))
00645         sender->handle(this,FXSEL(SEL_COMMAND,ID_ENABLE),NULL);
00646     else
00647         sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),NULL);
00648     return 1;
00649 }
00650 
00651 
00652 // Respond to decrement message
00653 long FXRealSpinDial::onCmdDecrement(FXObject*,FXSelector,void*) {
00654     if (!isEnabled()) return 0;
00655     FXint mode;
00656     if (keystate&CONTROLMASK)    mode = SPINDIAL_INC_FINE;
00657     else if (keystate&SHIFTMASK) mode = SPINDIAL_INC_COARSE;
00658     else                         mode = SPINDIAL_INC_NORMAL;
00659     decrement(mode);
00660     if (target) target->handle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
00661     return 1;
00662 }
00663 
00664 
00665 
00666 // Update from text field
00667 long FXRealSpinDial::onUpdEntry(FXObject*,FXSelector,void*) {
00668     return target && target->handle(this,FXSEL(SEL_UPDATE,message),NULL);
00669 }
00670 
00671 long FXRealSpinDial::onMouseWheel(FXObject*o,FXSelector s,void*p) {
00672     FXint mode;
00673     keystate = ((FXEvent*)p)->state;
00674     if (keystate&CONTROLMASK)    mode = SPINDIAL_INC_FINE;
00675     else if (keystate&SHIFTMASK) mode = SPINDIAL_INC_COARSE;
00676     else                         mode = SPINDIAL_INC_NORMAL;
00677     if (((FXEvent*)p)->code>0) increment(mode);
00678     else decrement(mode);
00679     if (target) target->handle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
00680     return 1;
00681 }
00682 
00683 // Text field changed
00684 long FXRealSpinDial::onChgEntry(FXObject*,FXSelector,void*) {
00685     register FXdouble value=FXDoubleVal(textField->getText());
00686     if (value<range[0]) value=range[0];
00687     if (value>range[1]) value=range[1];
00688     if (value!=pos) {
00689         pos=value;
00690         if (target) target->handle(this,FXSEL(SEL_CHANGED,message),(void*)&pos);
00691     }
00692     return 1;
00693 }
00694 
00695 
00696 // Text field command
00697 long FXRealSpinDial::onCmdEntry(FXObject*,FXSelector,void*) {
00698     textField->setText(FXStringVal(pos));       // Put back adjusted value
00699     if (target) target->handle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
00700     return 1;
00701 }
00702 
00703 
00704 // Keyboard press
00705 long FXRealSpinDial::onKeyPress(FXObject* sender,FXSelector sel,void* ptr) {
00706     FXEvent* event=(FXEvent*)ptr;
00707     if (!isEnabled()) return 0;
00708     keystate=event->state;
00709     if (target && target->handle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1;
00710     FXint mode;
00711     if (keystate&CONTROLMASK)    mode = SPINDIAL_INC_FINE;
00712     else if (keystate&SHIFTMASK) mode = SPINDIAL_INC_COARSE;
00713     else                         mode = SPINDIAL_INC_NORMAL;
00714     switch (event->code) {
00715     case KEY_Up:
00716     case KEY_KP_Up:
00717         increment(mode);
00718         if (target) target->handle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
00719         return 1;
00720     case KEY_Down:
00721     case KEY_KP_Down:
00722         decrement(mode);
00723         if (target) target->handle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
00724         return 1;
00725     default:
00726         return textField->handle(sender,sel,ptr);
00727     }
00728     return 0;
00729 }
00730 
00731 
00732 // Keyboard release
00733 long FXRealSpinDial::onKeyRelease(FXObject* sender,FXSelector sel,void* ptr) {
00734     FXEvent* event=(FXEvent*)ptr;
00735     if (!isEnabled()) return 0;
00736     keystate=event->state;
00737     if (target && target->handle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1;
00738     switch (event->code) {
00739     case KEY_Up:
00740     case KEY_KP_Up:
00741     case KEY_Down:
00742     case KEY_KP_Down:
00743         return 1;
00744     default:
00745         return textField->handle(sender,sel,ptr);
00746     }
00747     return 0;
00748 }
00749 
00750 // Mouse motion
00751 long FXRealSpinDial::onMotion(FXObject* sender,FXSelector sel,void* ptr) {
00752     if (!isEnabled()) return 0;
00753     keystate=((FXEvent*)ptr)->state;
00754     return 0;
00755 }
00756 
00757 // Update value from a message
00758 long FXRealSpinDial::onCmdSetValue(FXObject*,FXSelector,void* ptr) {
00759     setValue((FXdouble)(FXuval)ptr);
00760     return 1;
00761 }
00762 
00763 
00764 // Update value from a message
00765 long FXRealSpinDial::onCmdSetIntValue(FXObject*,FXSelector,void* ptr) {
00766     setValue(FXdouble(*((FXint*)ptr)));
00767     return 1;
00768 }
00769 
00770 
00771 // Obtain value from spinner
00772 long FXRealSpinDial::onCmdGetIntValue(FXObject*,FXSelector,void* ptr) {
00773     *((FXint*)ptr)=(FXint)getValue();
00774     return 1;
00775 }
00776 
00777 
00778 // Update range from a message
00779 long FXRealSpinDial::onCmdSetIntRange(FXObject*,FXSelector,void* ptr) {
00780     FXdouble lo = (FXdouble)((FXint*)ptr)[0];
00781     FXdouble hi = (FXdouble)((FXint*)ptr)[1];
00782     setRange(lo,hi);
00783     return 1;
00784 }
00785 
00786 
00787 // Get range with a message
00788 long FXRealSpinDial::onCmdGetIntRange(FXObject*,FXSelector,void* ptr) {
00789     ((FXdouble*)ptr)[0] = range[0];
00790     ((FXdouble*)ptr)[1] = range[1];
00791     return 1;
00792 }
00793 
00794 
00795 // Update value from a message
00796 long FXRealSpinDial::onCmdSetRealValue(FXObject*,FXSelector,void* ptr) {
00797     setValue(*((FXdouble*)ptr));
00798     return 1;
00799 }
00800 
00801 
00802 // Obtain value from spinner
00803 long FXRealSpinDial::onCmdGetRealValue(FXObject*,FXSelector,void* ptr) {
00804     *((FXdouble*)ptr)=getValue();
00805     return 1;
00806 }
00807 
00808 
00809 // Update range from a message
00810 long FXRealSpinDial::onCmdSetRealRange(FXObject*,FXSelector,void* ptr) {
00811     setRange(((FXdouble*)ptr)[0],((FXdouble*)ptr)[1]);
00812     return 1;
00813 }
00814 
00815 
00816 // Get range with a message
00817 long FXRealSpinDial::onCmdGetRealRange(FXObject*,FXSelector,void* ptr) {
00818     getRange(((FXdouble*)ptr)[0],((FXdouble*)ptr)[1]);
00819     return 1;
00820 }
00821 
00822 
00823 
00824 // Increment spinner
00825 void FXRealSpinDial::increment(FXint incMode) {
00826     FXdouble inc = incr[incMode+1];
00827     FXdouble newpos;
00828     if (range[0]<range[1]) {
00829         if (options&SPINDIAL_LOG) {
00830             newpos = pos * inc;
00831             if (options&SPINDIAL_CYCLIC && newpos>range[1]) {
00832                 // can have a huge magnitude disparity here, so better to work in log space
00833                 FXdouble lr0=log(range[0]), lr1=log(range[1]), lnp=log(newpos);
00834                 newpos = exp(lr0 + fmod(lnp-lr0, lr1-lr0)) ;
00835             }
00836         } else {
00837             newpos = pos + inc;
00838             if (options&SPINDIAL_CYCLIC) {
00839                 newpos = range[0] + fmod(newpos-range[0], range[1]-range[0]+1) ;
00840             }
00841         }
00842         setValue(newpos);
00843     }
00844 }
00845 
00846 
00847 // Decrement spinner
00848 void FXRealSpinDial::decrement(FXint incMode) {
00849     FXdouble inc = incr[incMode+1];
00850     FXdouble newpos;
00851     if (range[0]<range[1]) {
00852         if (options&SPINDIAL_LOG) {
00853             newpos = pos / inc;
00854             if (options&SPINDIAL_CYCLIC  && newpos<range[0]) {
00855                 // can have a huge magnitude disparity here, so better to work in log space
00856                 FXdouble lr0=log(range[0]), lr1=log(range[1]), lnp=log(newpos), lpos=log(pos);
00857                 FXdouble span=lr1-lr0;
00858                 newpos = exp(lr0 + fmod(lpos-lr0+1+(span-inc), span));
00859             }
00860         } else {
00861             newpos = pos - inc;
00862             if (options&SPINDIAL_CYCLIC) {
00863                 newpos = range[0] + fmod(pos+(range[1]-range[0]+1+(newpos-pos)-range[0]) , range[1]-range[0]+1);
00864             }
00865         }
00866         setValue(newpos);
00867     }
00868 }
00869 
00870 // True if spinner is cyclic
00871 FXbool FXRealSpinDial::isCyclic() const {
00872     return (options&SPINDIAL_CYCLIC)!=0;
00873 }
00874 
00875 
00876 // Set spinner cyclic mode
00877 void FXRealSpinDial::setCyclic(FXbool cyclic) {
00878     if (cyclic) options|=SPINDIAL_CYCLIC;
00879     else options&=~SPINDIAL_CYCLIC;
00880 }
00881 
00882 
00883 // Set spinner range; this also revalidates the position,
00884 void FXRealSpinDial::setRange(FXdouble lo,FXdouble hi) {
00885     if (lo>hi) {
00886         fxerror("%s::setRange: trying to set negative range.\n",getClassName());
00887     }
00888     if (range[0]!=lo || range[1]!=hi) {
00889         range[0]=lo;
00890         range[1]=hi;
00891         setValue(pos);
00892     }
00893 }
00894 
00895 
00896 // Set new value
00897 void FXRealSpinDial::setValue(FXdouble value) {
00898     if (value<range[0]) value=range[0];
00899     if (value>range[1]) value=range[1];
00900     if (pos!=value) {
00901         textField->handle(this,FXSEL(SEL_COMMAND,ID_SETREALVALUE), &value);
00902         pos=value;
00903     }
00904 }
00905 
00906 
00907 // Change value increment
00908 void FXRealSpinDial::setIncrement(FXdouble inc) {
00909     if (inc<0) {
00910         fxerror("%s::setIncrement: negative or zero increment specified.\n",getClassName());
00911     }
00912     incr[1]=inc;
00913 }
00914 void FXRealSpinDial::setFineIncrement(FXdouble inc) {
00915     if (inc<0) {
00916         fxerror("%s::setIncrement: negative or zero increment specified.\n",getClassName());
00917     }
00918     incr[0]=inc;
00919 }
00920 void FXRealSpinDial::setCoarseIncrement(FXdouble inc) {
00921     if (inc<0) {
00922         fxerror("%s::setIncrement: negative or zero increment specified.\n",getClassName());
00923     }
00924     incr[2]=inc;
00925 }
00926 void FXRealSpinDial::setIncrements(FXdouble fine,FXdouble inc,FXdouble coarse) {
00927     if (inc<0) {
00928         fxerror("%s::setIncrement: negative or zero increment specified.\n",getClassName());
00929     }
00930     incr[0]=fine;
00931     incr[1]=inc;
00932     incr[2]=coarse;
00933 }
00934 
00935 
00936 // True if text supposed to be visible
00937 FXbool FXRealSpinDial::isTextVisible() const {
00938     return textField->shown();
00939 }
00940 
00941 
00942 // Change text visibility
00943 void FXRealSpinDial::setTextVisible(FXbool shown) {
00944     FXuint opts=shown?(options&~SPINDIAL_NOTEXT):(options|SPINDIAL_NOTEXT);
00945     if (options!=opts) {
00946         options=opts;
00947         recalc();
00948     }
00949 }
00950 
00951 
00952 // Set the font used in the text field|
00953 void FXRealSpinDial::setFont(FXFont *fnt) {
00954     textField->setFont(fnt);
00955 }
00956 
00957 
00958 // Return the font used in the text field
00959 FXFont *FXRealSpinDial::getFont() const {
00960     return textField->getFont();
00961 }
00962 
00963 
00964 // Set help text
00965 void FXRealSpinDial::setHelpText(const FXString&  text) {
00966     textField->setHelpText(text);
00967     dial->setHelpText(text);
00968     upButton->setHelpText(text);
00969     downButton->setHelpText(text);
00970 }
00971 
00972 
00973 // Get help text
00974 FXString FXRealSpinDial::getHelpText() const {
00975     return textField->getHelpText();
00976 }
00977 
00978 
00979 // Set tip text
00980 void FXRealSpinDial::setTipText(const FXString&  text) {
00981     textField->setTipText(text);
00982     dial->setTipText(text);
00983     upButton->setTipText(text);
00984     downButton->setTipText(text);
00985 }
00986 
00987 
00988 
00989 // Get tip text
00990 FXString FXRealSpinDial::getTipText() const {
00991     return textField->getTipText();
00992 }
00993 
00994 
00995 // Change spinner style
00996 void FXRealSpinDial::setSpinnerStyle(FXuint style) {
00997     FXuint opts=(options&~SPINDIAL_MASK) | (style&SPINDIAL_MASK);
00998     if (options!=opts) {
00999         if (opts&SPINDIAL_NOMIN) range[0]=-DBL_MAX;
01000         if (opts&SPINDIAL_NOMAX) range[1]=DBL_MAX;
01001         options=opts;
01002         recalc();
01003     }
01004 }
01005 
01006 
01007 // Get spinner style
01008 FXuint FXRealSpinDial::getSpinnerStyle() const {
01009     return (options&SPINDIAL_MASK);
01010 }
01011 
01012 
01013 // Allow editing of the text field
01014 void FXRealSpinDial::setEditable(FXbool edit) {
01015     textField->setEditable(edit);
01016 }
01017 
01018 
01019 // Return TRUE if text field is editable
01020 FXbool FXRealSpinDial::isEditable() const {
01021     return textField->isEditable();
01022 }
01023 
01024 // Change color of the dial
01025 void FXRealSpinDial::setDialColor(FXColor clr) {
01026     dial->setBackColor(clr);
01027 }
01028 
01029 // Return color of the dial
01030 FXColor FXRealSpinDial::getDialColor() const {
01031     return dial->getBackColor();
01032 }
01033 
01034 // Change color of the up arrow
01035 void FXRealSpinDial::setUpArrowColor(FXColor clr) {
01036     upButton->setArrowColor(clr);
01037 }
01038 
01039 // Return color of the up arrow
01040 FXColor FXRealSpinDial::getUpArrowColor() const {
01041     return upButton->getArrowColor();
01042 }
01043 
01044 // Change color of the down arrow
01045 void FXRealSpinDial::setDownArrowColor(FXColor clr) {
01046     downButton->setArrowColor(clr);
01047 }
01048 
01049 // Return color of the the down arrow
01050 FXColor FXRealSpinDial::getDownArrowColor() const {
01051     return downButton->getArrowColor();
01052 }
01053 
01054 
01055 // Change text color
01056 void FXRealSpinDial::setTextColor(FXColor clr) {
01057     textField->setTextColor(clr);
01058 }
01059 
01060 // Return text color
01061 FXColor FXRealSpinDial::getTextColor() const {
01062     return textField->getTextColor();
01063 }
01064 
01065 // Change selected background color
01066 void FXRealSpinDial::setSelBackColor(FXColor clr) {
01067     textField->setSelBackColor(clr);
01068 }
01069 
01070 // Return selected background color
01071 FXColor FXRealSpinDial::getSelBackColor() const {
01072     return textField->getSelBackColor();
01073 }
01074 
01075 // Change selected text color
01076 void FXRealSpinDial::setSelTextColor(FXColor clr) {
01077     textField->setSelTextColor(clr);
01078 }
01079 
01080 // Return selected text color
01081 FXColor FXRealSpinDial::getSelTextColor() const {
01082     return textField->getSelTextColor();
01083 }
01084 
01085 // Changes the cursor color
01086 void FXRealSpinDial::setCursorColor(FXColor clr) {
01087     textField->setCursorColor(clr);
01088 }
01089 
01090 // Return the cursor color
01091 FXColor FXRealSpinDial::getCursorColor() const {
01092     return textField->getCursorColor();
01093 }
01094 
01095 void FXRealSpinDial::setNumberFormat(FXint  prec, FXbool  bExp) {
01096     textField->setNumberFormat(prec,bExp);
01097 }
01098 
01099 FXint FXRealSpinDial::getNumberFormatPrecision() const {
01100     return textField->getNumberFormatPrecision();
01101 }
01102 
01103 FXbool FXRealSpinDial::getNumberFormatExponent() const {
01104     return textField->getNumberFormatExponent();
01105 }
01106 
01107 void FXRealSpinDial::setFormatString(FXchar  *fmt) {
01108     textField->setFormatString(fmt);
01109 }
01110 
01111 FXString FXRealSpinDial::getNumberFormatString() const {
01112     return textField->getNumberFormatString();
01113 }
01114 
01115 // Save object to stream
01116 void FXRealSpinDial::save(FXStream& store) const {
01117     FXPacker::save(store);
01118     store << textField;
01119     store << dial;
01120     store << upButton;
01121     store << downButton;
01122     store << range[0] << range[1];
01123     store << incr[0] << incr[1] << incr[2];
01124     store << pos;
01125 }
01126 
01127 
01128 // Load object from stream
01129 void FXRealSpinDial::load(FXStream& store) {
01130     FXPacker::load(store);
01131     store >> textField;
01132     store >> dial;
01133     store >> upButton;
01134     store >> downButton;
01135     store >> range[0] >> range[1];
01136     store >> incr[0] >> incr[1] >> incr[2];
01137     store >> pos;
01138 }
01139 
01140 
01141 // Destruct spinner:- trash it!
01142 FXRealSpinDial::~FXRealSpinDial() {
01143     textField=(FXRealSpinDialText*)-1L;
01144     dial=(FXDial*)-1L;
01145     upButton=(FXRealSpinDialBtn*)-1L;
01146     downButton=(FXRealSpinDialBtn*)-1L;
01147 }
01148 
01149 }
01150 
01151 
01152 void
01153 FXRealSpinDial::selectAll() {
01154     textField->selectAll();
01155 }
01156 
01157 
01158 
01159 const FXDial &
01160 FXRealSpinDial::getDial() const {
01161     return *dial;
01162 }
01163 
01164 

Generated on Wed May 5 00:06:29 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6