SUMO - Simulation of Urban MObility
FXRealSpinDial.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 //
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2004-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 /********************************************************************************
25 * *
26 * 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 *
27 * *
28 *********************************************************************************
29 * Copyright (C) 2004 by Bill Baxter. All Rights Reserved. *
30 *********************************************************************************
31 * This library is free software; you can redistribute it and/or *
32 * modify it under the terms of the GNU Lesser General Public *
33 * License as published by the Free Software Foundation; either *
34 * version 2.1 of the License, or (at your option) any later version. *
35 * *
36 * This library is distributed in the hope that it will be useful, *
37 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
39 * Lesser General Public License for more details. *
40 * *
41 * You should have received a copy of the GNU Lesser General Public *
42 * License along with this library; if not, write to the Free Software *
43 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
44 *********************************************************************************
45 * $Id: FXRealSpinDial.cpp 25771 2017-08-31 14:49:32Z namdre $ *
46 ********************************************************************************/
47 
48 /* =========================================================================
49  * included modules
50  * ======================================================================= */
51 #ifdef _MSC_VER
52 #include <windows_config.h>
53 #else
54 #include <config.h>
55 #endif
56 
57 #include <fx.h>
58 #define NOMINMAX
59 #include <xincs.h>
60 #undef NOMINMAX
61 #include "fxver.h"
62 #include "fxdefs.h"
63 #include "fxkeys.h"
64 #include "FXStream.h"
65 #include "FXString.h"
66 #include "FXSize.h"
67 #include "FXPoint.h"
68 #include "FXRectangle.h"
69 #include "FXRegistry.h"
70 #include "FXAccelTable.h"
71 #include "FXApp.h"
72 #include "FXLabel.h"
73 #include "FXTextField.h"
74 #include "FXDial.h"
75 #include "FXRealSpinDial.h"
76 
77 #include <float.h>
78 
79 /*
80  Notes:
81  - Based originally on Lyle's FXSpinner.
82  - Can use with spin buttons, dial, or both, and with or without text
83  - Three increment levels, fine, normal, and coarse. Access different modes
84  with CONTROL key (fine control) and SHIFT key (coarse mode). Modifiers
85  affect all of up/down keys, mousewheel, dial and spinbuttons.
86  - Can specify display format for text either as a precision,showExponent pair
87  or an sprintf format string. (String format can include extra text like '$'!)
88  - Wheel mouse increment/decrement in even multiples of fine/norm/coarse scales.
89  (Key modifers sometimes require mouse motion to kick in because FOX doesn't
90  have a [public] way to query the key state asynchronously. Hacked extern to
91  FOX's internal WIN32 function for querying this, so it works on Win32)
92  - Dial warps the pointer at the edge of the screen so you don't run out of
93  screen real estate.
94 */
95 #define DIALINCR 160
96 #define DIALMULT 40
97 #define DIALWIDTH 12
98 #define BUTTONWIDTH 12
99 #define GAPWIDTH 1
100 
101 #define INTMAX 2147483647
102 #define INTMIN (-INTMAX-1)
103 
104 #define SPINDIAL_MASK (SPINDIAL_CYCLIC|SPINDIAL_NOTEXT|SPINDIAL_NOBUTTONS|SPINDIAL_NODIAL|SPINDIAL_NOMAX|SPINDIAL_NOMIN|SPINDIAL_LOG)
105 
106 using namespace FX;
107 
108 /*******************************************************************************/
109 /* Custom FXDial subclass */
110 /*******************************************************************************/
111 namespace FX {
112 class FXRealSpinDialDial : public FXDial {
113  FXDECLARE(FXRealSpinDialDial)
114 protected:
116 private:
119 public:
120  //long onDefault(FXObject*,FXSelector,void* );
121  long onKey(FXObject*, FXSelector, void*);
122  long onButtonPress(FXObject*, FXSelector, void*);
123  long onButtonRelease(FXObject*, FXSelector, void*);
124  long onRightButtonPress(FXObject*, FXSelector, void*);
125  long onRightButtonRelease(FXObject*, FXSelector, void*);
126  long onMotion(FXObject*, FXSelector, void*);
127  long onAuto(FXObject*, FXSelector, void*);
128  enum {
129  ID_AUTOSPIN = FXDial::ID_LAST,
131  };
132 public:
133 
135  FXRealSpinDialDial(FXComposite* p, FXObject* tgt = NULL, FXSelector sel = 0, FXuint opts = DIAL_NORMAL,
136  FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0,
137  FXint pl = DEFAULT_PAD, FXint pr = DEFAULT_PAD, FXint pt = DEFAULT_PAD, FXint pb = DEFAULT_PAD):
138  FXDial(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {}
139 
140 };
141 
142 FXDEFMAP(FXRealSpinDialDial) FXSpinDialMap[] = {
143  FXMAPFUNC(SEL_KEYPRESS, 0, FXRealSpinDialDial::onKey),
144  FXMAPFUNC(SEL_KEYRELEASE, 0, FXRealSpinDialDial::onKey),
145  FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, FXRealSpinDialDial::onButtonPress),
146  FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, 0, FXRealSpinDialDial::onRightButtonRelease),
147  FXMAPFUNC(SEL_RIGHTBUTTONPRESS, 0, FXRealSpinDialDial::onRightButtonPress),
148  FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, FXRealSpinDialDial::onButtonRelease),
149  FXMAPFUNC(SEL_MOTION, 0, FXRealSpinDialDial::onMotion),
150 
152 
153  //FXMAPFUNC(SEL_KEYPRESS,0, FXRealSpinDialDial::onKeyPress),
154  //FXMAPFUNC(SEL_KEYRELEASE,0,FXRealSpinDialDial::onKeyRelease),
155 };
156 FXIMPLEMENT(FXRealSpinDialDial, FXDial, FXSpinDialMap, ARRAYNUMBER(FXSpinDialMap))
157 //FXIMPLEMENT(FXRealSpinDialDial,FXDial,0,0)
158 
159 //long FXRealSpinDialDial::onDefault(FXObject*o,FXSelector s,void*p )
160 //{
161 // printf("DEFAULT!\n");
162 // if (target) return target->handle(o,s,p);
163 // return 0;
164 //}
165 long FXRealSpinDialDial::onKey(FXObject* o, FXSelector s, void* p) {
166  if (target) {
167  return target->handle(o, s, p);
168  }
169  return 0;
170 }
171 long FXRealSpinDialDial::onButtonPress(FXObject* o, FXSelector s, void* p) {
172  grabKeyboard();
173  return FXDial::onLeftBtnPress(o, s, p);
174 }
175 long FXRealSpinDialDial::onButtonRelease(FXObject* o, FXSelector s, void* p) {
176  ungrabKeyboard();
177  return FXDial::onLeftBtnRelease(o, s, p);
178 }
179 long FXRealSpinDialDial::onRightButtonPress(FXObject* /*o*/, FXSelector /*s*/, void* p) {
180  if (isEnabled()) {
181  grab();
182  grabKeyboard();
183  //if(target && target->handle(this,FXSEL(SEL_RIGHTBUTTONPRESS,message),ptr)) return 1;
184  FXEvent* event = (FXEvent*)p;
185  if (options & DIAL_HORIZONTAL) {
186  dragpoint = event->win_x;
187  } else {
188  dragpoint = event->win_y;
189  }
190  getApp()->addTimeout(this, ID_AUTOSPIN, getApp()->getScrollSpeed());
191  }
192  return 1;
193 }
194 long FXRealSpinDialDial::onRightButtonRelease(FXObject* /*o*/, FXSelector /*s*/, void* /*p*/) {
195  ungrab();
196  ungrabKeyboard();
197  getApp()->removeTimeout(this, ID_AUTOSPIN);
198  if (isEnabled()) {
199  //if(target && target->handle(this,FXSEL(SEL_RIGHTBUTTONRELEASE,message),p)) return 1;
200  }
201  return 1;
202 
203 }
204 long FXRealSpinDialDial::onAuto(FXObject* /*o*/, FXSelector /*s*/, void* /*p*/) {
205  getApp()->addTimeout(this, ID_AUTOSPIN, getApp()->getScrollSpeed());
206  setValue(getValue() + int((dragpoint - dragpos) / float(5)));
207  int v = getValue();
208  if (target) {
209  target->handle(this, FXSEL(SEL_CHANGED, message), &v);
210  }
211  return 1;
212 }
213 
214 long FXRealSpinDialDial::onMotion(FXObject* o, FXSelector s, void* p) {
215  if (!isEnabled()) {
216  return 0;
217  }
218  if (target && target->handle(this, FXSEL(SEL_MOTION, message), p)) {
219  return 1;
220  }
221 
222  FXbool bJump = FALSE;
223  FXEvent* e = (FXEvent*)p;
224  if (!(flags & FLAG_PRESSED)) { // not doing clickdrag
225  dragpos = e->win_y;
226  }
227  FXWindow* rootWin = getApp()->getRootWindow();
228  FXint x = e->root_x, y = e->root_y;
229  if (e->root_x >= rootWin->getWidth() - 1) {
230  x -= 40;
231  dragpoint -= 40;
232  bJump = TRUE;
233  } else if (e->root_x <= 10) {
234  x += 40;
235  dragpoint += 40;
236  bJump = TRUE;
237  }
238  if (e->root_y >= rootWin->getHeight() - 1) {
239  y -= 40;
240  dragpoint -= 40;
241  bJump = TRUE;
242  } else if (e->root_y <= 10) {
243  y += 40;
244  dragpoint += 40;
245  bJump = TRUE;
246  }
247  if (bJump) {
248  rootWin->setCursorPosition(x, y);
249  return 1;
250  } else {
251  return FXDial::onMotion(o, s, p);
252  }
253 }
254 
255 }
256 
257 /*******************************************************************************/
258 /* Custom FXArrowButton subclass */
259 /*******************************************************************************/
260 namespace FX {
261 class FXRealSpinDialBtn : public FXArrowButton {
262  FXDECLARE(FXRealSpinDialBtn)
263 protected:
265 private:
268 public:
269  //long onDefault(FXObject*,FXSelector,void* );
270  long onKey(FXObject*, FXSelector, void*);
271  long onButtonPress(FXObject*, FXSelector, void*);
272  long onButtonRelease(FXObject*, FXSelector, void*);
273  enum {
274  ID_AUTOSPIN = FXDial::ID_LAST,
276  };
277 public:
278 
280  FXRealSpinDialBtn(FXComposite* p, FXObject* tgt = NULL, FXSelector sel = 0,
281  FXuint opts = ARROW_NORMAL,
282  FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0,
283  FXint pl = DEFAULT_PAD, FXint pr = DEFAULT_PAD, FXint pt = DEFAULT_PAD, FXint pb = DEFAULT_PAD):
284  FXArrowButton(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {}
285 
286 };
287 
288 FXDEFMAP(FXRealSpinDialBtn) FXSpinDialBtnMap[] = {
289  FXMAPFUNC(SEL_KEYPRESS, 0, FXRealSpinDialBtn::onKey),
290  FXMAPFUNC(SEL_KEYRELEASE, 0, FXRealSpinDialBtn::onKey),
291  FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, FXRealSpinDialBtn::onButtonPress),
292  FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, FXRealSpinDialBtn::onButtonRelease),
293 
294 
295  //FXMAPFUNC(SEL_KEYPRESS,0, FXRealSpinDialBtn::onKeyPress),
296  //FXMAPFUNC(SEL_KEYRELEASE,0,FXRealSpinDialBtn::onKeyRelease),
297 };
298 FXIMPLEMENT(FXRealSpinDialBtn, FXArrowButton, FXSpinDialBtnMap, ARRAYNUMBER(FXSpinDialBtnMap))
299 //FXIMPLEMENT(FXRealSpinDialBtn,FXDial,0,0)
300 
301 //long FXRealSpinDialBtn::onDefault(FXObject*o,FXSelector s,void*p )
302 //{
303 // printf("DEFAULT!\n");
304 // if (target) return target->handle(o,s,p);
305 // return 0;
306 //}
307 long FXRealSpinDialBtn::onKey(FXObject* o, FXSelector s, void* p) {
308  if (target) {
309  return target->handle(o, s, p);
310  }
311  return 0;
312 }
313 long FXRealSpinDialBtn::onButtonPress(FXObject* o, FXSelector s, void* p) {
314  grabKeyboard();
315  return FXArrowButton::onLeftBtnPress(o, s, p);
316 }
317 long FXRealSpinDialBtn::onButtonRelease(FXObject* o, FXSelector s, void* p) {
318  ungrabKeyboard();
319  return FXArrowButton::onLeftBtnRelease(o, s, p);
320 }
321 
322 
323 }
324 
325 
326 /*******************************************************************************/
327 /* FXTextField subclass */
328 /*******************************************************************************/
329 
330 namespace FX {
331 class FXRealSpinDialText : public FXTextField {
332  FXDECLARE(FXRealSpinDialText)
333 protected:
335 private:
338 public:
339  long onCmdSetRealValue(FXObject*, FXSelector, void*);
340  long onMotion(FXObject*, FXSelector, void*);
341  enum {
342  ID_LAST = FXTextField::ID_LAST
343  };
344  enum {
345  FLAG_FMTSTRING = 0x1
346  };
347 public:
348 
350  FXRealSpinDialText(FXComposite* p, FXint ncols, FXObject* tgt = NULL, FXSelector sel = 0,
351  FXuint opts = TEXTFIELD_NORMAL,
352  FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0, FXint
353  pl = DEFAULT_PAD, FXint pr = DEFAULT_PAD, FXint pt = DEFAULT_PAD, FXint pb = DEFAULT_PAD
354  ) :
355  FXTextField(p, ncols, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
356  precision(3),
357  exponent(FALSE),
358  flags(0) {}
359 
360  void setNumberFormat(FXint prec, FXbool bExp = FALSE) {
361  precision = prec;
362  exponent = bExp;
363  flags &= ~FLAG_FMTSTRING;
364  }
365  FXint getNumberFormatPrecision() const {
366  return precision;
367  }
368  FXbool getNumberFormatExponent() const {
369  return exponent;
370  }
371  void setFormatString(const FXchar* fmt) {
372  fmtString = fmt;
373  flags |= FLAG_FMTSTRING;
374  }
375  FXString getNumberFormatString() const {
376  return fmtString;
377  }
378 
379 protected:
380  FXint precision;
381  FXbool exponent;
382  FXString fmtString;
383  FXuint flags;
384 };
385 
386 FXDEFMAP(FXRealSpinDialText) FXSpinDialTextMap[] = {
387  FXMAPFUNC(SEL_MOTION, 0, FXRealSpinDialText::onMotion),
388  FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETREALVALUE, FXRealSpinDialText::onCmdSetRealValue),
389 };
390 FXIMPLEMENT(FXRealSpinDialText, FXTextField, FXSpinDialTextMap, ARRAYNUMBER(FXSpinDialTextMap))
391 
392 long FXRealSpinDialText::onMotion(FXObject* o, FXSelector s, void* ptr) {
393  // Forward motion events so we can monitor key state. We don't get the modifier
394  // keys themselves if we aren't focused, so this seems the best we can do.
395  if (!isEnabled()) {
396  return 0;
397  }
398  if (target && target->handle(this, FXSEL(SEL_MOTION, message), ptr)) {
399  return 1;
400  }
401  return FXTextField::onMotion(o, s, ptr);
402 }
403 long FXRealSpinDialText::onCmdSetRealValue(FXObject* /*o*/, FXSelector /*s*/, void* ptr) {
404  // setText(FXStringVal(*((FXdouble*)ptr)));
405  if (flags & FLAG_FMTSTRING) {
406  setText(FXStringFormat(fmtString.text(), *((FXdouble*)ptr)));
407  } else {
408  setText(FXStringVal(*((FXdouble*)ptr), precision, exponent));
409  }
410  return 1;
411 }
412 
413 }
414 
415 /*******************************************************************************/
416 /* FXRealSpinDial */
417 /*******************************************************************************/
418 
419 namespace FX {
420 
421 // Message map
422 FXDEFMAP(FXRealSpinDial) FXRealSpinDialMap[] = {
423  FXMAPFUNC(SEL_KEYPRESS, 0, FXRealSpinDial::onKeyPress),
424  FXMAPFUNC(SEL_KEYRELEASE, 0, FXRealSpinDial::onKeyRelease),
425  FXMAPFUNC(SEL_MOTION, 0, FXRealSpinDial::onMotion),
426  FXMAPFUNC(SEL_MOTION, FXRealSpinDial::ID_ENTRY, FXRealSpinDial::onMotion),
427  FXMAPFUNC(SEL_MOTION, FXRealSpinDial::ID_DIAL, FXRealSpinDial::onMotion),
429  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_ENTRY, FXRealSpinDial::onCmdEntry),
430  FXMAPFUNC(SEL_CHANGED, FXRealSpinDial::ID_ENTRY, FXRealSpinDial::onChgEntry),
431  FXMAPFUNC(SEL_UPDATE, FXRealSpinDial::ID_DIAL, FXRealSpinDial::onUpdDial),
432  FXMAPFUNC(SEL_CHANGED, FXRealSpinDial::ID_DIAL, FXRealSpinDial::onChgDial),
433  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_DIAL, FXRealSpinDial::onChgDial),
434  FXMAPFUNC(SEL_MOUSEWHEEL, FXRealSpinDial::ID_ENTRY, FXRealSpinDial::onMouseWheel),
435  FXMAPFUNC(SEL_MOUSEWHEEL, FXRealSpinDial::ID_DIAL, FXRealSpinDial::onMouseWheel),
438  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_SETVALUE, FXRealSpinDial::onCmdSetValue),
439  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_SETINTVALUE, FXRealSpinDial::onCmdSetIntValue),
440  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_GETINTVALUE, FXRealSpinDial::onCmdGetIntValue),
441  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_SETINTRANGE, FXRealSpinDial::onCmdSetIntRange),
442  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_GETINTRANGE, FXRealSpinDial::onCmdGetIntRange),
443  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_SETREALVALUE, FXRealSpinDial::onCmdSetRealValue),
444  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_GETREALVALUE, FXRealSpinDial::onCmdGetRealValue),
445  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_SETREALRANGE, FXRealSpinDial::onCmdSetRealRange),
446  FXMAPFUNC(SEL_COMMAND, FXRealSpinDial::ID_GETREALRANGE, FXRealSpinDial::onCmdGetRealRange),
451 };
452 
453 
454 // Object implementation
455 FXIMPLEMENT(FXRealSpinDial, FXPacker, FXRealSpinDialMap, ARRAYNUMBER(FXRealSpinDialMap))
456 
457 
458 // Construct spinner out of two buttons and a text field
460  flags = (flags | FLAG_ENABLED | FLAG_SHOWN) & ~FLAG_UPDATE;
461  textField = 0;
462  dial = 0;
463  upButton = 0;
464  downButton = 0;
465  range[0] = -DBL_MAX;
466  range[1] = DBL_MAX;
467  incr[0] = 0.1;
468  incr[1] = 1.0;
469  incr[2] = 10;
470  pos = 1;
471  dialpos = 0;
472 }
473 
474 
475 // Construct spinner out of dial and a text field
476 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):
477  FXPacker(p, opts & ~(FRAME_RIDGE), x, y, w, h, 0, 0, 0, 0, 0, 0) {
478  flags = (flags | FLAG_ENABLED | FLAG_SHOWN) & ~FLAG_UPDATE;
479  target = tgt;
480  message = sel;
481  dial = new FXRealSpinDialDial(this, this, ID_DIAL, DIAL_VERTICAL, 0, 0, 0, 0, 0, 0, 0, 0);
482  dial->setNotchSpacing(450);
483  dial->setRevolutionIncrement(DIALINCR);
484  upButton = new FXRealSpinDialBtn(this, this, ID_INCREMENT, FRAME_RAISED | FRAME_THICK | ARROW_UP | ARROW_REPEAT, 0, 0, 0, 0, 0, 0, 0, 0);
485  downButton = new FXRealSpinDialBtn(this, this, ID_DECREMENT, FRAME_RAISED | FRAME_THICK | ARROW_DOWN | ARROW_REPEAT, 0, 0, 0, 0, 0, 0, 0, 0);
486  // flag SPINDIAL_NOMAX collides with flag TEXTFIELD_PASSWORD
487  // flag SPINDIAL_NOMIN collides with flag TEXTFIELD_INTEGER
488  textField = new FXRealSpinDialText(this, cols, this, ID_ENTRY, (opts & ~(SPINDIAL_NOMAX | SPINDIAL_NOMIN)) | TEXTFIELD_REAL | JUSTIFY_RIGHT, 0, 0, 0, 0, pl, pr, pt, pb);
489  textField->setText("0");
490  range[0] = (options & SPINDIAL_NOMIN) ? -DBL_MAX : 0;
491  range[1] = (options & SPINDIAL_NOMAX) ? DBL_MAX : 100;
492  dial->setRange(INTMIN, INTMAX);
493  dialpos = dial->getValue();
494  incr[0] = 0.1;
495  incr[1] = 1.0;
496  incr[2] = 10;
497  pos = 0;
498  keystate = 0;
499 }
500 
501 
502 // Get default width
504  FXint tw = 0;
505  if (!(options & SPINDIAL_NOTEXT)) {
506  tw = textField->getDefaultWidth();
507  }
508  return tw + DIALWIDTH + GAPWIDTH + (border << 1);
509 }
510 
511 
512 // Get default height
514  return textField->getDefaultHeight() + (border << 1);
515 }
516 
517 
518 // Create window
520  FXPacker::create();
521 }
522 
523 
524 // Enable the widget
526  if (!(flags & FLAG_ENABLED)) {
527  FXPacker::enable();
528  textField->enable();
529  dial->enable();
530  }
531 }
532 
533 
534 // Disable the widget
536  if (flags & FLAG_ENABLED) {
537  FXPacker::disable();
538  textField->disable();
539  dial->disable();
540  }
541 }
542 
543 
544 // Recompute layout
546  FXint dialHeight, buttonHeight, textHeight;
547 
548  textHeight = height - 2 * border;
549  dialHeight = textHeight;
550  buttonHeight = textHeight >> 1;
551 
552  FXuint hideOpts = SPINDIAL_NOTEXT | SPINDIAL_NODIAL | SPINDIAL_NOBUTTONS;
553  if ((options & hideOpts) == hideOpts) {
554  flags &= ~FLAG_DIRTY;
555  return; // nothing to layout
556  }
557 
558  FXint right = width - border;
559 
560  if (options & SPINDIAL_NOTEXT) {
561  // Dial takes up the extra space if shown, otherwise spinbuttons
562  if (!(options & SPINDIAL_NODIAL)) {
563  // HAS DIAL
564  int left = border;
565  if (!(options & SPINDIAL_NOBUTTONS)) {
566  FXint bw = BUTTONWIDTH;
567  upButton->position(border, border, bw, buttonHeight);
568  downButton->position(border, height - buttonHeight - border, bw, buttonHeight);
569  left += bw + GAPWIDTH;
570  }
571  dial->position(left, border, right - left, dialHeight);
572  } else {
573  upButton->position(border, border, right - border, buttonHeight);
574  downButton->position(border, height - buttonHeight - border, right - border, buttonHeight);
575  }
576  } else {
577  // dial/buttons are default width, text stretches to fill the rest
578  if (!(options & SPINDIAL_NODIAL)) {
579  FXint w = DIALWIDTH;
580  dial->position(right - w, border, w, dialHeight);
581  right -= w + GAPWIDTH;
582  }
583  if (!(options & SPINDIAL_NOBUTTONS)) {
584  FXint w = BUTTONWIDTH;
585  upButton->position(right - w, border, w, buttonHeight);
586  downButton->position(right - w, height - buttonHeight - border, w, buttonHeight);
587  right -= w + GAPWIDTH;
588  }
589  textField->position(border, border, right - border, textHeight);
590  }
591  flags &= ~FLAG_DIRTY;
592 }
593 
594 
595 // Respond to dial message
596 long FXRealSpinDial::onUpdDial(FXObject* sender, FXSelector, void*) {
597  if (isEnabled() && ((options & SPINDIAL_CYCLIC) || (pos <= range[1]))) {
598  sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
599  } else {
600  sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), NULL);
601  }
602  return 1;
603 }
604 
605 
606 // Respond to dial message
607 long FXRealSpinDial::onChgDial(FXObject* /*p*/, FXSelector /*sel*/, void* /*ptr*/) {
608  if (!isEnabled()) {
609  return 0;
610  }
611  FXdouble newpos;
612  FXdouble inc;
613  if (FXApp::instance()->getKeyState(CONTROLMASK)) {
614  inc = incr[0];
615  } else if (FXApp::instance()->getKeyState(SHIFTMASK)) {
616  inc = incr[2];
617  } else {
618  inc = incr[1];
619  }
620  FXint dialdelta = dial->getValue() - dialpos;
621  if (options & SPINDIAL_LOG) {
622  newpos = pos * pow(inc , DIALMULT * FXdouble(dialdelta) / DIALINCR);
623  } else {
624  newpos = pos + DIALMULT * inc * (dialdelta) / DIALINCR;
625  }
626  // Now clamp newpos.
627  if (dialdelta > 0) {
628  if (options & SPINDIAL_LOG) {
629  if (options & SPINDIAL_CYCLIC && newpos > range[1]) {
630  FXdouble lr0 = log(range[0]), lr1 = log(range[1]), lnp = log(newpos);
631  newpos = exp(lr0 + fmod(lnp - lr0, lr1 - lr0));
632  }
633  } else {
634  if (options & SPINDIAL_CYCLIC) {
635  newpos = range[0] + fmod(newpos - range[0], range[1] - range[0] + 1);
636  }
637  }
638  } else {
639  if (options & SPINDIAL_LOG) {
640  if (options & SPINDIAL_CYCLIC && newpos < range[0]) {
641  FXdouble lr0 = log(range[0]), lr1 = log(range[1]), lpos = log(pos);
642  FXdouble span = lr1 - lr0;
643  newpos = exp(lr0 + fmod(lpos - lr0 + 1 + (span - inc), span));
644  }
645  } else {
646  if (options & SPINDIAL_CYCLIC) {
647  newpos = range[0] + fmod(pos + (range[1] - range[0] + 1 + (newpos - pos) - range[0]) , range[1] - range[0] + 1);
648  }
649  }
650  }
651  setValue(newpos);
652  if (target) {
653  target->handle(this, FXSEL(SEL_COMMAND, message), (void*)&pos);
654  }
655  dialpos = dial->getValue();
656  return 1;
657 }
658 
659 // Respond to dial message
660 long FXRealSpinDial::onCmdDial(FXObject*, FXSelector /*sel*/, void*) {
661  if (!isEnabled()) {
662  return 0;
663  }
664  // if(target) target->handle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
665  dialpos = dial->getValue() % DIALINCR;
666  dial->setValue(dialpos);
667  return 1;
668 }
669 
670 
671 // Respond to increment message
672 long FXRealSpinDial::onUpdIncrement(FXObject* sender, FXSelector, void*) {
673  if (isEnabled() && ((options & REALSPIN_CYCLIC) || (pos < range[1]))) {
674  sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
675  } else {
676  sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), NULL);
677  }
678  return 1;
679 }
680 
681 
682 // Respond to increment message
683 long FXRealSpinDial::onCmdIncrement(FXObject*, FXSelector, void*) {
684  if (!isEnabled()) {
685  return 0;
686  }
687  FXint mode;
688  if (keystate & CONTROLMASK) {
689  mode = SPINDIAL_INC_FINE;
690  } else if (keystate & SHIFTMASK) {
691  mode = SPINDIAL_INC_COARSE;
692  } else {
693  mode = SPINDIAL_INC_NORMAL;
694  }
695  increment(mode);
696  if (target) {
697  target->handle(this, FXSEL(SEL_COMMAND, message), (void*)&pos);
698  }
699  return 1;
700 }
701 
702 
703 // Disable decrement if at low end already
704 long FXRealSpinDial::onUpdDecrement(FXObject* sender, FXSelector, void*) {
705  if (isEnabled() && ((options & REALSPIN_CYCLIC) || (range[0] < pos))) {
706  sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
707  } else {
708  sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), NULL);
709  }
710  return 1;
711 }
712 
713 
714 // Respond to decrement message
715 long FXRealSpinDial::onCmdDecrement(FXObject*, FXSelector, void*) {
716  if (!isEnabled()) {
717  return 0;
718  }
719  FXint mode;
720  if (keystate & CONTROLMASK) {
721  mode = SPINDIAL_INC_FINE;
722  } else if (keystate & SHIFTMASK) {
723  mode = SPINDIAL_INC_COARSE;
724  } else {
725  mode = SPINDIAL_INC_NORMAL;
726  }
727  decrement(mode);
728  if (target) {
729  target->handle(this, FXSEL(SEL_COMMAND, message), (void*)&pos);
730  }
731  return 1;
732 }
733 
734 
735 
736 // Update from text field
737 long FXRealSpinDial::onUpdEntry(FXObject*, FXSelector, void*) {
738  return target && target->handle(this, FXSEL(SEL_UPDATE, message), NULL);
739 }
740 
741 long FXRealSpinDial::onMouseWheel(FXObject* /*o*/, FXSelector /*s*/, void* p) {
742  FXint mode;
743  keystate = ((FXEvent*)p)->state;
744  if (keystate & CONTROLMASK) {
745  mode = SPINDIAL_INC_FINE;
746  } else if (keystate & SHIFTMASK) {
747  mode = SPINDIAL_INC_COARSE;
748  } else {
749  mode = SPINDIAL_INC_NORMAL;
750  }
751  if (((FXEvent*)p)->code > 0) {
752  increment(mode);
753  } else {
754  decrement(mode);
755  }
756  if (target) {
757  target->handle(this, FXSEL(SEL_COMMAND, message), (void*)&pos);
758  }
759  return 1;
760 }
761 
762 // Text field changed
763 long FXRealSpinDial::onChgEntry(FXObject*, FXSelector, void*) {
764  register FXdouble value = FXDoubleVal(textField->getText());
765  if (value < range[0]) {
766  value = range[0];
767  }
768  if (value > range[1]) {
769  value = range[1];
770  }
771  if (value != pos) {
772  pos = value;
773  if (target) {
774  target->handle(this, FXSEL(SEL_CHANGED, message), (void*)&pos);
775  }
776  }
777  return 1;
778 }
779 
780 
781 // Text field command
782 long FXRealSpinDial::onCmdEntry(FXObject*, FXSelector, void*) {
783  textField->setText(FXStringVal(pos)); // Put back adjusted value
784  if (target) {
785  target->handle(this, FXSEL(SEL_COMMAND, message), (void*)&pos);
786  }
787  return 1;
788 }
789 
790 
791 // Keyboard press
792 long FXRealSpinDial::onKeyPress(FXObject* sender, FXSelector sel, void* ptr) {
793  FXEvent* event = (FXEvent*)ptr;
794  if (!isEnabled()) {
795  return 0;
796  }
797  keystate = event->state;
798  if (target && target->handle(this, FXSEL(SEL_KEYPRESS, message), ptr)) {
799  return 1;
800  }
801  FXint mode;
802  if (keystate & CONTROLMASK) {
803  mode = SPINDIAL_INC_FINE;
804  } else if (keystate & SHIFTMASK) {
805  mode = SPINDIAL_INC_COARSE;
806  } else {
807  mode = SPINDIAL_INC_NORMAL;
808  }
809  switch (event->code) {
810  case KEY_Up:
811  case KEY_KP_Up:
812  increment(mode);
813  if (target) {
814  target->handle(this, FXSEL(SEL_COMMAND, message), (void*)&pos);
815  }
816  return 1;
817  case KEY_Down:
818  case KEY_KP_Down:
819  decrement(mode);
820  if (target) {
821  target->handle(this, FXSEL(SEL_COMMAND, message), (void*)&pos);
822  }
823  return 1;
824  default:
825  return textField->handle(sender, sel, ptr);
826  }
827 }
828 
829 
830 // Keyboard release
831 long FXRealSpinDial::onKeyRelease(FXObject* sender, FXSelector sel, void* ptr) {
832  FXEvent* event = (FXEvent*)ptr;
833  if (!isEnabled()) {
834  return 0;
835  }
836  keystate = event->state;
837  if (target && target->handle(this, FXSEL(SEL_KEYRELEASE, message), ptr)) {
838  return 1;
839  }
840  switch (event->code) {
841  case KEY_Up:
842  case KEY_KP_Up:
843  case KEY_Down:
844  case KEY_KP_Down:
845  return 1;
846  default:
847  return textField->handle(sender, sel, ptr);
848  }
849 }
850 
851 // Mouse motion
852 long FXRealSpinDial::onMotion(FXObject* /*sender*/, FXSelector /*sel*/, void* ptr) {
853  if (!isEnabled()) {
854  return 0;
855  }
856  keystate = ((FXEvent*)ptr)->state;
857  return 0;
858 }
859 
860 // Update value from a message
861 long FXRealSpinDial::onCmdSetValue(FXObject*, FXSelector, void* ptr) {
862  setValue((FXdouble)(size_t)ptr);
863  return 1;
864 }
865 
866 
867 // Update value from a message
868 long FXRealSpinDial::onCmdSetIntValue(FXObject*, FXSelector, void* ptr) {
869  setValue(FXdouble(*((FXint*)ptr)));
870  return 1;
871 }
872 
873 
874 // Obtain value from spinner
875 long FXRealSpinDial::onCmdGetIntValue(FXObject*, FXSelector, void* ptr) {
876  *((FXint*)ptr) = (FXint)getValue();
877  return 1;
878 }
879 
880 
881 // Update range from a message
882 long FXRealSpinDial::onCmdSetIntRange(FXObject*, FXSelector, void* ptr) {
883  FXdouble lo = (FXdouble)((FXint*)ptr)[0];
884  FXdouble hi = (FXdouble)((FXint*)ptr)[1];
885  setRange(lo, hi);
886  return 1;
887 }
888 
889 
890 // Get range with a message
891 long FXRealSpinDial::onCmdGetIntRange(FXObject*, FXSelector, void* ptr) {
892  ((FXdouble*)ptr)[0] = range[0];
893  ((FXdouble*)ptr)[1] = range[1];
894  return 1;
895 }
896 
897 
898 // Update value from a message
899 long FXRealSpinDial::onCmdSetRealValue(FXObject*, FXSelector, void* ptr) {
900  setValue(*((FXdouble*)ptr));
901  return 1;
902 }
903 
904 
905 // Obtain value from spinner
906 long FXRealSpinDial::onCmdGetRealValue(FXObject*, FXSelector, void* ptr) {
907  *((FXdouble*)ptr) = getValue();
908  return 1;
909 }
910 
911 
912 // Update range from a message
913 long FXRealSpinDial::onCmdSetRealRange(FXObject*, FXSelector, void* ptr) {
914  setRange(((FXdouble*)ptr)[0], ((FXdouble*)ptr)[1]);
915  return 1;
916 }
917 
918 
919 // Get range with a message
920 long FXRealSpinDial::onCmdGetRealRange(FXObject*, FXSelector, void* ptr) {
921  getRange(((FXdouble*)ptr)[0], ((FXdouble*)ptr)[1]);
922  return 1;
923 }
924 
925 
926 
927 // Increment spinner
928 void FXRealSpinDial::increment(FXint incMode) {
929  FXdouble inc = incr[incMode + 1];
930  FXdouble newpos;
931  if (range[0] < range[1]) {
932  if (options & SPINDIAL_LOG) {
933  newpos = pos * inc;
934  if (options & SPINDIAL_CYCLIC && newpos > range[1]) {
935  // can have a huge magnitude disparity here, so better to work in log space
936  FXdouble lr0 = log(range[0]), lr1 = log(range[1]), lnp = log(newpos);
937  newpos = exp(lr0 + fmod(lnp - lr0, lr1 - lr0));
938  }
939  } else {
940  newpos = pos + inc;
941  if (options & SPINDIAL_CYCLIC) {
942  newpos = range[0] + fmod(newpos - range[0], range[1] - range[0] + 1);
943  }
944  }
945  setValue(newpos);
946  }
947 }
948 
949 
950 // Decrement spinner
951 void FXRealSpinDial::decrement(FXint incMode) {
952  FXdouble inc = incr[incMode + 1];
953  FXdouble newpos;
954  if (range[0] < range[1]) {
955  if (options & SPINDIAL_LOG) {
956  newpos = pos / inc;
957  if (options & SPINDIAL_CYCLIC && newpos < range[0]) {
958  // can have a huge magnitude disparity here, so better to work in log space
959  FXdouble lr0 = log(range[0]), lr1 = log(range[1]), lpos = log(pos);
960  FXdouble span = lr1 - lr0;
961  newpos = exp(lr0 + fmod(lpos - lr0 + 1 + (span - inc), span));
962  }
963  } else {
964  newpos = pos - inc;
965  if (options & SPINDIAL_CYCLIC) {
966  newpos = range[0] + fmod(pos + (range[1] - range[0] + 1 + (newpos - pos) - range[0]) , range[1] - range[0] + 1);
967  }
968  }
969  setValue(newpos);
970  }
971 }
972 
973 // True if spinner is cyclic
974 FXbool FXRealSpinDial::isCyclic() const {
975  return (options & SPINDIAL_CYCLIC) != 0;
976 }
977 
978 
979 // Set spinner cyclic mode
980 void FXRealSpinDial::setCyclic(FXbool cyclic) {
981  if (cyclic) {
982  options |= SPINDIAL_CYCLIC;
983  } else {
984  options &= ~SPINDIAL_CYCLIC;
985  }
986 }
987 
988 
989 // Set spinner range; this also revalidates the position,
990 void FXRealSpinDial::setRange(FXdouble lo, FXdouble hi) {
991  if (lo > hi) {
992  fxerror("%s::setRange: trying to set negative range.\n", getClassName());
993  }
994  if (range[0] != lo || range[1] != hi) {
995  range[0] = lo;
996  range[1] = hi;
997  setValue(pos);
998  }
999 }
1000 
1001 
1002 // Set new value
1003 void FXRealSpinDial::setValue(FXdouble value) {
1004  if (value < range[0]) {
1005  value = range[0];
1006  }
1007  if (value > range[1]) {
1008  value = range[1];
1009  }
1010  if (pos != value) {
1011  textField->handle(this, FXSEL(SEL_COMMAND, ID_SETREALVALUE), &value);
1012  pos = value;
1013  }
1014 }
1015 
1016 
1017 // Change value increment
1018 void FXRealSpinDial::setIncrement(FXdouble inc) {
1019  if (inc < 0) {
1020  fxerror("%s::setIncrement: negative or zero increment specified.\n", getClassName());
1021  }
1022  incr[1] = inc;
1023 }
1025  if (inc < 0) {
1026  fxerror("%s::setIncrement: negative or zero increment specified.\n", getClassName());
1027  }
1028  incr[0] = inc;
1029 }
1031  if (inc < 0) {
1032  fxerror("%s::setIncrement: negative or zero increment specified.\n", getClassName());
1033  }
1034  incr[2] = inc;
1035 }
1036 void FXRealSpinDial::setIncrements(FXdouble fine, FXdouble inc, FXdouble coarse) {
1037  if (inc < 0) {
1038  fxerror("%s::setIncrement: negative or zero increment specified.\n", getClassName());
1039  }
1040  incr[0] = fine;
1041  incr[1] = inc;
1042  incr[2] = coarse;
1043 }
1044 
1045 
1046 // True if text supposed to be visible
1048  return textField->shown();
1049 }
1050 
1051 
1052 // Change text visibility
1054  FXuint opts = shown ? (options & ~SPINDIAL_NOTEXT) : (options | SPINDIAL_NOTEXT);
1055  if (options != opts) {
1056  options = opts;
1057  recalc();
1058  }
1059 }
1060 
1061 
1062 // Set the font used in the text field|
1063 void FXRealSpinDial::setFont(FXFont* fnt) {
1064  textField->setFont(fnt);
1065 }
1066 
1067 
1068 // Return the font used in the text field
1069 FXFont* FXRealSpinDial::getFont() const {
1070  return textField->getFont();
1071 }
1072 
1073 
1074 // Set help text
1075 void FXRealSpinDial::setHelpText(const FXString& text) {
1076  textField->setHelpText(text);
1077  dial->setHelpText(text);
1078  upButton->setHelpText(text);
1079  downButton->setHelpText(text);
1080 }
1081 
1082 
1083 // Get help text
1085  return textField->getHelpText();
1086 }
1087 
1088 
1089 // Set tip text
1090 void FXRealSpinDial::setTipText(const FXString& text) {
1091  textField->setTipText(text);
1092  dial->setTipText(text);
1093  upButton->setTipText(text);
1094  downButton->setTipText(text);
1095 }
1096 
1097 
1098 
1099 // Get tip text
1100 FXString FXRealSpinDial::getTipText() const {
1101  return textField->getTipText();
1102 }
1103 
1104 
1105 // Change spinner style
1107  FXuint opts = (options & ~SPINDIAL_MASK) | (style & SPINDIAL_MASK);
1108  if (options != opts) {
1109  if (opts & SPINDIAL_NOMIN) {
1110  range[0] = -DBL_MAX;
1111  }
1112  if (opts & SPINDIAL_NOMAX) {
1113  range[1] = DBL_MAX;
1114  }
1115  options = opts;
1116  recalc();
1117  }
1118 }
1119 
1120 
1121 // Get spinner style
1123  return (options & SPINDIAL_MASK);
1124 }
1125 
1126 
1127 // Allow editing of the text field
1128 void FXRealSpinDial::setEditable(FXbool edit) {
1129  textField->setEditable(edit);
1130 }
1131 
1132 
1133 // Return TRUE if text field is editable
1135  return textField->isEditable();
1136 }
1137 
1138 // Change color of the dial
1139 void FXRealSpinDial::setDialColor(FXColor clr) {
1140  dial->setBackColor(clr);
1141 }
1142 
1143 // Return color of the dial
1145  return dial->getBackColor();
1146 }
1147 
1148 // Change color of the up arrow
1150  upButton->setArrowColor(clr);
1151 }
1152 
1153 // Return color of the up arrow
1155  return upButton->getArrowColor();
1156 }
1157 
1158 // Change color of the down arrow
1160  downButton->setArrowColor(clr);
1161 }
1162 
1163 // Return color of the the down arrow
1165  return downButton->getArrowColor();
1166 }
1167 
1168 
1169 // Change text color
1170 void FXRealSpinDial::setTextColor(FXColor clr) {
1171  textField->setTextColor(clr);
1172 }
1173 
1174 // Return text color
1176  return textField->getTextColor();
1177 }
1178 
1179 // Change selected background color
1181  textField->setSelBackColor(clr);
1182 }
1183 
1184 // Return selected background color
1186  return textField->getSelBackColor();
1187 }
1188 
1189 // Change selected text color
1191  textField->setSelTextColor(clr);
1192 }
1193 
1194 // Return selected text color
1196  return textField->getSelTextColor();
1197 }
1198 
1199 // Changes the cursor color
1201  textField->setCursorColor(clr);
1202 }
1203 
1204 // Return the cursor color
1206  return textField->getCursorColor();
1207 }
1208 
1209 void FXRealSpinDial::setNumberFormat(FXint prec, FXbool bExp) {
1210  textField->setNumberFormat(prec, bExp);
1211 }
1212 
1215 }
1216 
1219 }
1220 
1221 void FXRealSpinDial::setFormatString(const FXchar* fmt) {
1222  textField->setFormatString(fmt);
1223 }
1224 
1226  return textField->getNumberFormatString();
1227 }
1228 
1229 // Save object to stream
1230 void FXRealSpinDial::save(FXStream& store) const {
1231  FXPacker::save(store);
1232  store << textField;
1233  store << dial;
1234  store << upButton;
1235  store << downButton;
1236  store << range[0] << range[1];
1237  store << incr[0] << incr[1] << incr[2];
1238  store << pos;
1239 }
1240 
1241 
1242 // Load object from stream
1243 void FXRealSpinDial::load(FXStream& store) {
1244  FXPacker::load(store);
1245  store >> textField;
1246  store >> dial;
1247  store >> upButton;
1248  store >> downButton;
1249  store >> range[0] >> range[1];
1250  store >> incr[0] >> incr[1] >> incr[2];
1251  store >> pos;
1252 }
1253 
1254 
1255 // Destruct spinner:- trash it!
1257  textField = 0;
1258  dial = 0;
1259  upButton = 0;
1260  downButton = 0;
1261 }
1262 
1263 }
1264 
1265 
1266 void
1268  textField->selectAll();
1269 }
1270 
1271 
1272 
1273 const FXDial&
1275  return *dial;
1276 }
1277 
1278 
long onCmdDecrement(FXObject *, FXSelector, void *)
long onCmdGetIntRange(FXObject *, FXSelector, void *)
long onCmdGetRealRange(FXObject *, FXSelector, void *)
FXRealSpinDialText(FXComposite *p, FXint ncols, FXObject *tgt=NULL, FXSelector sel=0, FXuint opts=TEXTFIELD_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)
Construct a text widget.
void selectAll()
Mark the text entry as selected.
void setFineIncrement(FXdouble increment)
Change spinner fine adjustment increment (when CTRL key held down)
long onKey(FXObject *, FXSelector, void *)
FXbool isTextVisible() const
Return TRUE if text is visible.
FXColor getTextColor() const
Return text color.
long onUpdEntry(FXObject *, FXSelector, void *)
FXRealSpinDialBtn(FXComposite *p, FXObject *tgt=NULL, FXSelector sel=0, FXuint opts=ARROW_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)
Construct a dial widget.
void setFont(FXFont *fnt)
Set the text font.
void setDialColor(FXColor clr)
Change color of the dial.
virtual FXint getDefaultHeight()
Return default height.
virtual void load(FXStream &store)
Load spinner from a stream.
#define SPINDIAL_MASK
virtual void setValue(FXdouble value)
Change current value.
long onButtonPress(FXObject *, FXSelector, void *)
long onCmdSetIntRange(FXObject *, FXSelector, void *)
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
void setCoarseIncrement(FXdouble increment)
Change spinner coarse adjustment increment (when SHIFT key held down)
FXArrowButton * downButton
virtual FXint getDefaultWidth()
Return default width.
void setSpinnerStyle(FXuint style)
Change spinner style.
void setCursorColor(FXColor clr)
Changes the cursor color.
#define DIALWIDTH
#define INTMIN
long onCmdSetValue(FXObject *, FXSelector, void *)
virtual void create()
Create server-side resources.
long onCmdSetRealRange(FXObject *, FXSelector, void *)
long onKeyPress(FXObject *, FXSelector, void *)
const FXDial & getDial() const
FXColor getUpArrowColor() const
Return color of the up arrow.
virtual void disable()
Disable spinner.
long onRightButtonRelease(FXObject *, FXSelector, void *)
FXRealSpinDialDial & operator=(const FXRealSpinDialDial &)
#define DIALINCR
FXbool isEditable() const
Return TRUE if text field is editable.
FXRealSpinDialDial(FXComposite *p, FXObject *tgt=NULL, FXSelector sel=0, FXuint opts=DIAL_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)
Construct a dial widget.
void setEditable(FXbool edit=TRUE)
Allow editing of the text field.
void setTextColor(FXColor clr)
Change text color.
long onButtonRelease(FXObject *, FXSelector, void *)
void decrement(FXint incMode=SPINDIAL_INC_NORMAL)
Decrement spinner.
FXbool getNumberFormatExponent() const
void setSelBackColor(FXColor clr)
Change selected background color.
void setRange(FXdouble lo, FXdouble hi)
Change the spinner&#39;s range.
long onCmdEntry(FXObject *, FXSelector, void *)
long onCmdSetIntValue(FXObject *, FXSelector, void *)
long onMotion(FXObject *, FXSelector, void *)
FXdouble getValue() const
Return current value.
long onButtonPress(FXObject *, FXSelector, void *)
FXArrowButton * upButton
virtual void save(FXStream &store) const
Save spinner to a stream.
FXint getNumberFormatPrecision() const
long onUpdDial(FXObject *, FXSelector, void *)
FXString getNumberFormatString() const
Return the format string for number display.
void setFormatString(const FXchar *fmt)
FXString getTipText() const
Get the tool tip message for this spinner.
void setTipText(const FXString &text)
Set the tool tip message for this spinner.
long onButtonRelease(FXObject *, FXSelector, void *)
virtual ~FXRealSpinDial()
Destructor.
FXColor getSelBackColor() const
Return selected background color.
void setCyclic(FXbool cyclic)
Set to cyclic mode, i.e. wrap around at maximum/minimum.
FXColor getSelTextColor() const
Return selected text color.
long onKeyRelease(FXObject *, FXSelector, void *)
long onUpdDecrement(FXObject *, FXSelector, void *)
#define GAPWIDTH
#define BUTTONWIDTH
long onCmdDial(FXObject *, FXSelector, void *)
void setFormatString(const FXchar *fmt)
FXColor getCursorColor() const
Return the cursor color.
void getRange(FXdouble &lo, FXdouble &hi) const
Get the spinner&#39;s current range.
long onCmdGetRealValue(FXObject *, FXSelector, void *)
FXString getNumberFormatString() const
FXColor getDownArrowColor() const
Return color of the the down arrow.
void setTextVisible(FXbool shown)
Set text visible flag.
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
long onKey(FXObject *, FXSelector, void *)
long onCmdIncrement(FXObject *, FXSelector, void *)
FXColor getDialColor() const
Return color of the dial.
long onMotion(FXObject *, FXSelector, void *)
void increment(FXint incMode=SPINDIAL_INC_NORMAL)
Increment spinner.
FXint getNumberFormatPrecision() const
Return the digits of precision used to display numbers.
long onChgEntry(FXObject *, FXSelector, void *)
FXuint getSpinnerStyle() const
Return current spinner style.
void text()
Definition: gl2psTest.c:260
long onCmdSetRealValue(FXObject *, FXSelector, void *)
FXbool getNumberFormatExponent() const
Return whether the exponent is used in number display.
void setHelpText(const FXString &text)
Set the status line help text for this spinner.
FXbool isCyclic() const
Return TRUE if in cyclic mode.
FXString getHelpText() const
Get the status line help text for this spinner.
void setDownArrowColor(FXColor clr)
Change color of the down arrow.
long onMotion(FXObject *, FXSelector, void *)
#define INTMAX
void setIncrement(FXdouble increment)
Change spinner increment.
long onCmdGetIntValue(FXObject *, FXSelector, void *)
long onUpdIncrement(FXObject *, FXSelector, void *)
void setIncrements(FXdouble fine, FXdouble norm, FXdouble coarse)
Change all spinner increment.
FXDEFMAP(FXRealSpinDialDial) FXSpinDialMap[]
virtual void layout()
Perform layout.
long onMouseWheel(FXObject *, FXSelector, void *)
FXFont * getFont() const
Get the text font.
void setSelTextColor(FXColor clr)
Change selected text color.
#define DIALMULT
Spinner control.
FXRealSpinDialText * textField
long onAuto(FXObject *, FXSelector, void *)
long onRightButtonPress(FXObject *, FXSelector, void *)
virtual void enable()
Enable spinner.
void setUpArrowColor(FXColor clr)
Change color of the up arrow.
long onCmdSetRealValue(FXObject *, FXSelector, void *)
long onChgDial(FXObject *, FXSelector, void *)