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