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