File: FXRealSpinner.cpp

package info (click to toggle)
gogglesmm 1.2.5-6
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 16,812 kB
  • sloc: cpp: 231,960; ansic: 893; xml: 222; makefile: 33
file content (709 lines) | stat: -rw-r--r-- 19,454 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
/********************************************************************************
*                                                                               *
*             R e a l - V a l u e d   S p i n n e r  W i d g e t                *
*                                                                               *
*********************************************************************************
* Copyright (C) 2003,2022 by Bill Baxter.   All Rights Reserved.                *
*********************************************************************************
* This library is free software; you can redistribute it and/or modify          *
* it under the terms of the GNU Lesser General Public License as published by   *
* the Free Software Foundation; either version 3 of the License, or             *
* (at your option) any later version.                                           *
*                                                                               *
* This library is distributed in the hope that it will be useful,               *
* but WITHOUT ANY WARRANTY; without even the implied warranty of                *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
* GNU Lesser General Public License for more details.                           *
*                                                                               *
* You should have received a copy of the GNU Lesser General Public License      *
* along with this program.  If not, see <http://www.gnu.org/licenses/>          *
********************************************************************************/
#include "xincs.h"
#include "fxver.h"
#include "fxdefs.h"
#include "fxmath.h"
#include "fxkeys.h"
#include "FXArray.h"
#include "FXHash.h"
#include "FXMutex.h"
#include "FXStream.h"
#include "FXString.h"
#include "FXSize.h"
#include "FXPoint.h"
#include "FXRectangle.h"
#include "FXStringDictionary.h"
#include "FXSettings.h"
#include "FXRegistry.h"
#include "FXAccelTable.h"
#include "FXEvent.h"
#include "FXWindow.h"
#include "FXApp.h"
#include "FXLabel.h"
#include "FXTextField.h"
#include "FXArrowButton.h"
#include "FXRealSpinner.h"


/*
  Notes:
  - Based on Lyle's FXSpinner.
  - Changed to use arrow buttons because getting nice operation
    with the dial was impossible.
  - Wheel mouse offers incrementation/decrementation in nice
    multiples of increment, makes it very quick to get a value.
*/

#define BUTTONWIDTH 14

#define REALSPINNER_MASK (REALSPIN_CYCLIC|REALSPIN_NOTEXT|REALSPIN_NOMAX|REALSPIN_NOMIN|REALSPIN_LOG)

using namespace FX;

/*******************************************************************************/

namespace FX {


//  Message map
FXDEFMAP(FXRealSpinner) FXRealSpinnerMap[]={
  FXMAPFUNC(SEL_KEYPRESS,0,FXRealSpinner::onKeyPress),
  FXMAPFUNC(SEL_KEYRELEASE,0,FXRealSpinner::onKeyRelease),
  FXMAPFUNC(SEL_FOCUS_SELF,0,FXRealSpinner::onFocusSelf),
  FXMAPFUNC(SEL_CHANGED,FXRealSpinner::ID_ENTRY,FXRealSpinner::onChgEntry),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_ENTRY,FXRealSpinner::onCmdEntry),
  FXMAPFUNC(SEL_MOUSEWHEEL,FXRealSpinner::ID_ENTRY,FXRealSpinner::onWheelEntry),
  FXMAPFUNC(SEL_UPDATE,FXRealSpinner::ID_INCREMENT,FXRealSpinner::onUpdIncrement),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_INCREMENT,FXRealSpinner::onCmdIncrement),
  FXMAPFUNC(SEL_UPDATE,FXRealSpinner::ID_DECREMENT,FXRealSpinner::onUpdDecrement),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_DECREMENT,FXRealSpinner::onCmdDecrement),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_SETVALUE,FXRealSpinner::onCmdSetValue),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_SETINTVALUE,FXRealSpinner::onCmdSetIntValue),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_GETINTVALUE,FXRealSpinner::onCmdGetIntValue),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_SETLONGVALUE,FXRealSpinner::onCmdSetLongValue),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_GETLONGVALUE,FXRealSpinner::onCmdGetLongValue),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_SETINTRANGE,FXRealSpinner::onCmdSetIntRange),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_GETINTRANGE,FXRealSpinner::onCmdGetIntRange),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_SETREALVALUE,FXRealSpinner::onCmdSetRealValue),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_GETREALVALUE,FXRealSpinner::onCmdGetRealValue),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_SETREALRANGE,FXRealSpinner::onCmdSetRealRange),
  FXMAPFUNC(SEL_COMMAND,FXRealSpinner::ID_GETREALRANGE,FXRealSpinner::onCmdGetRealRange),
  };


// Object implementation
FXIMPLEMENT(FXRealSpinner,FXPacker,FXRealSpinnerMap,ARRAYNUMBER(FXRealSpinnerMap))


// Construct spinner out of two buttons and a text field
FXRealSpinner::FXRealSpinner(){
  flags|=FLAG_ENABLED;
  textField=(FXTextField*)-1L;
  upButton=(FXArrowButton*)-1L;
  downButton=(FXArrowButton*)-1L;
  range[0]=-DBL_MAX;
  range[1]= DBL_MAX;
  incr=1.0;
  gran=0.0;
  pos=0.0;
  }


// Construct spinner out of dial and a text field
FXRealSpinner::FXRealSpinner(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):FXPacker(p,opts,x,y,w,h,0,0,0,0,0,0){
  flags|=FLAG_ENABLED;
  target=tgt;
  message=sel;
  textField=new FXTextField(this,cols,this,ID_ENTRY,TEXTFIELD_REAL|JUSTIFY_RIGHT,0,0,0,0,pl,pr,pt,pb);
  upButton=new FXArrowButton(this,this,FXRealSpinner::ID_INCREMENT,FRAME_RAISED|FRAME_THICK|ARROW_UP|ARROW_REPEAT, 0,0,0,0, 0,0,0,0);
  downButton=new FXArrowButton(this,this,FXRealSpinner::ID_DECREMENT,FRAME_RAISED|FRAME_THICK|ARROW_DOWN|ARROW_REPEAT, 0,0,0,0, 0,0,0,0);
  range[0]=(options&REALSPIN_NOMIN) ? -DBL_MAX : 0.0;
  range[1]=(options&REALSPIN_NOMAX) ?  DBL_MAX : 100.0;
  textField->setText("0");
  incr=1.0;
  gran=0.0;
  pos=0.0;
  }


// Get default width
FXint FXRealSpinner::getDefaultWidth(){
  FXint tw=0;
  if(!(options&REALSPIN_NOTEXT)) tw=textField->getDefaultWidth();
  return tw+BUTTONWIDTH+(border<<1);
  }


// Get default height
FXint FXRealSpinner::getDefaultHeight(){
  return textField->getDefaultHeight()+(border<<1);
  }


// Enable the widget
void FXRealSpinner::enable(){
  if(!(flags&FLAG_ENABLED)){
    FXPacker::enable();
    textField->enable();
    upButton->enable();
    downButton->enable();
    }
  }


// Disable the widget
void FXRealSpinner::disable(){
  if(flags&FLAG_ENABLED){
    FXPacker::disable();
    textField->disable();
    upButton->disable();
    downButton->disable();
    }
  }


// Recompute layout
void FXRealSpinner::layout(){
  FXint buttonWidth,buttonHeight,textWidth,textHeight;

  textHeight=height-2*border;
  buttonHeight=textHeight>>1;

  // Only the dial:- place dial to take up the whole space!
  if(options&REALSPIN_NOTEXT){
    buttonWidth=width-2*border;
    upButton->position(border,border,buttonWidth,buttonHeight);
    downButton->position(border,height-buttonHeight-border,buttonWidth,buttonHeight);
    }

  // Dial plus the text; dial is default width, text stretches to fill the rest
  else{
    buttonWidth=BUTTONWIDTH;
    textWidth=width-buttonWidth-2*border;
    textField->position(border,border,textWidth,textHeight);
    upButton->position(border+textWidth,border,buttonWidth,buttonHeight);
    downButton->position(border+textWidth,height-buttonHeight-border,buttonWidth,buttonHeight);
    }
  flags&=~FLAG_DIRTY;
  }


// Move the focus to this window
void FXRealSpinner::setFocus(){
  FXPacker::setFocus();
  flags&=~FLAG_UPDATE;
  }


// Remove the focus from this window
void FXRealSpinner::killFocus(){
  FXPacker::killFocus();
  flags|=FLAG_UPDATE;
  }


// Respond to increment message
long FXRealSpinner::onUpdIncrement(FXObject* sender,FXSelector,void*){
  if(isEnabled() && ((options&REALSPIN_CYCLIC) || (pos<range[1])))
    sender->handle(this,FXSEL(SEL_COMMAND,ID_ENABLE),nullptr);
  else
    sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),nullptr);
  return 1;
  }


// Respond to increment message
long FXRealSpinner::onCmdIncrement(FXObject*,FXSelector,void*){
  if(isEnabled() && isEditable()){
    increment(true);
    return 1;
    }
  return 0;
  }


// Disable decrement if at low end already
long FXRealSpinner::onUpdDecrement(FXObject* sender,FXSelector,void*){
  if(isEnabled() && ((options&REALSPIN_CYCLIC) || (range[0]<pos)))
    sender->handle(this,FXSEL(SEL_COMMAND,ID_ENABLE),nullptr);
  else
    sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),nullptr);
  return 1;
  }


// Respond to decrement message
long FXRealSpinner::onCmdDecrement(FXObject*,FXSelector,void*){
  if(isEnabled() && isEditable()){
    decrement(true);
    return 1;
    }
  return 0;
  }


// Rolling mouse wheel in text field behaves as if inside dial
long FXRealSpinner::onWheelEntry(FXObject*,FXSelector,void* ptr){
  if(isEnabled() && isEditable()){
    if(((FXEvent*)ptr)->code>0){
      if(((FXEvent*)ptr)->state&CONTROLMASK) incrementByAmount(incr*10.0,true);
      else increment(true);
      }
    else if(((FXEvent*)ptr)->code<0){
      if(((FXEvent*)ptr)->state&CONTROLMASK) decrementByAmount(incr*10.0,true);
      else decrement(true);
      }
    return 1;
    }
  return 0;
  }


// Text field changed
long FXRealSpinner::onChgEntry(FXObject*,FXSelector,void*){
  FXdouble value=textField->getText().toDouble();
  if(value<range[0]) value=range[0];
  if(value>range[1]) value=range[1];
  if(value!=pos){
    pos=value;
    if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)&pos);
    }
  return 1;
  }


// Text field command
long FXRealSpinner::onCmdEntry(FXObject*,FXSelector,void*){
  textField->setText(FXString::value(pos));       // Put back adjusted value
  if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);
  return 1;
  }


// Keyboard press
long FXRealSpinner::onKeyPress(FXObject* sender,FXSelector sel,void* ptr){
  FXEvent* event=(FXEvent*)ptr;
  if(isEnabled()){
    if(target && target->tryHandle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1;
    switch(event->code){
      case KEY_Up:
      case KEY_KP_Up:
        if(isEditable()){
          increment(true);
          }
        else{
          getApp()->beep();
          }
        return 1;
      case KEY_Down:
      case KEY_KP_Down:
        if(isEditable()){
          decrement(true);
          }
        else{
          getApp()->beep();
          }
        return 1;
      default:
        return textField->handle(sender,sel,ptr);
      }
    }
  return 0;
  }


// Keyboard release
long FXRealSpinner::onKeyRelease(FXObject* sender,FXSelector sel,void* ptr){
  FXEvent* event=(FXEvent*)ptr;
  if(isEnabled()){
    if(target && target->tryHandle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1;
    switch(event->code){
      case KEY_Up:
      case KEY_KP_Up:
      case KEY_Down:
      case KEY_KP_Down:
        return 1;
      default:
        return textField->handle(sender,sel,ptr);
      }
    }
  return 0;
  }


// Force focus on the text field
long FXRealSpinner::onFocusSelf(FXObject* sender,FXSelector,void* ptr){
  return textField->tryHandle(sender,FXSEL(SEL_FOCUS_SELF,0),ptr);
  }


// Update value from a message
long FXRealSpinner::onCmdSetValue(FXObject*,FXSelector,void* ptr){
  setValue((FXdouble)(FXival)ptr);
  return 1;
  }


// Update value from a message
long FXRealSpinner::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){
  setValue((FXdouble) *((FXint*)ptr));
  return 1;
  }


// Obtain value from spinner
long FXRealSpinner::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){
  *((FXint*)ptr)=(FXint)getValue();
  return 1;
  }


// Update value from a message
long FXRealSpinner::onCmdSetLongValue(FXObject*,FXSelector,void* ptr){
  setValue((FXint)*((FXlong*)ptr));
  return 1;
  }


// Obtain value with a message
long FXRealSpinner::onCmdGetLongValue(FXObject*,FXSelector,void* ptr){
  *((FXlong*)ptr)=(FXlong)getValue();
  return 1;
  }


// Update range from a message
long FXRealSpinner::onCmdSetIntRange(FXObject*,FXSelector,void* ptr){
  setRange((FXdouble)((FXint*)ptr)[0],(FXdouble)((FXint*)ptr)[1]);
  return 1;
  }


// Get range with a message
long FXRealSpinner::onCmdGetIntRange(FXObject*,FXSelector,void* ptr){
  ((FXint*)ptr)[0]=(FXint)range[0];
  ((FXint*)ptr)[1]=(FXint)range[1];
  return 1;
  }


// Update value from a message
long FXRealSpinner::onCmdSetRealValue(FXObject*,FXSelector,void* ptr){
  setValue(*((FXdouble*)ptr));
  return 1;
  }


// Obtain value from spinner
long FXRealSpinner::onCmdGetRealValue(FXObject*,FXSelector,void* ptr){
  *((FXdouble*)ptr)=getValue();
  return 1;
  }


// Update range from a message
long FXRealSpinner::onCmdSetRealRange(FXObject*,FXSelector,void* ptr){
  setRange(((FXdouble*)ptr)[0],((FXdouble*)ptr)[1]);
  return 1;
  }


// Get range with a message
long FXRealSpinner::onCmdGetRealRange(FXObject*,FXSelector,void* ptr){
  ((FXdouble*)ptr)[0]=range[0];
  ((FXdouble*)ptr)[1]=range[1];
  return 1;
  }


// Increment spinner
void FXRealSpinner::increment(FXbool notify){
  incrementByAmount(incr,notify);
  }


// Increment spinner by certain amount
void FXRealSpinner::incrementByAmount(FXdouble amount,FXbool notify){
  if(range[0]<range[1] && 0.0<amount){
    FXdouble value;
    if(options&REALSPIN_LOG){
      value=pos*amount;
      }
    else{
      value=pos+amount;
      if(0.0<gran) value=gran*Math::round(value/gran);
      if(options&REALSPIN_CYCLIC){
        value=value-Math::floor((value-range[0])/(range[1]-range[0]))*(range[1]-range[0]);
        }
      }
    setValue(value,notify);
    }
  }


// Decrement spinner
void FXRealSpinner::decrement(FXbool notify){
  decrementByAmount(incr,notify);
  }


// Decrement spinner by certain amount
void FXRealSpinner::decrementByAmount(FXdouble amount,FXbool notify){
  if(range[0]<range[1] && 0.0<amount){
    FXdouble value;
    if(options&REALSPIN_LOG){
      value=pos/amount;
      }
    else{
      value=pos-amount;
      if(0.0<gran) value=gran*Math::round(value/gran);
      if(options&REALSPIN_CYCLIC){
        value=value-Math::floor((value-range[0])/(range[1]-range[0]))*(range[1]-range[0]);
        }
      }
    setValue(value,notify);
    }
  }


// True if spinner is cyclic
FXbool FXRealSpinner::isCyclic() const {
  return (options&REALSPIN_CYCLIC)!=0;
  }


// Set spinner cyclic mode
void FXRealSpinner::setCyclic(FXbool cyclic){
  options^=((0-cyclic)^options)&REALSPIN_CYCLIC;
  }


// Set spinner range; this also revalidates the position,
void FXRealSpinner::setRange(FXdouble lo,FXdouble hi,FXbool notify){
  if(lo>hi){ fxerror("%s::setRange: trying to set negative range.\n",getClassName()); }
  if(range[0]!=lo || range[1]!=hi){
    range[0]=lo;
    range[1]=hi;
    setValue(pos,notify);
    }
  }


// Set new value
void FXRealSpinner::setValue(FXdouble value,FXbool notify){
  if(value<range[0]) value=range[0];
  if(value>range[1]) value=range[1];
  if(pos!=value){
    pos=value;
    textField->setText(FXString::value(value));
    if(notify && target){target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)&pos);}
    }
  }


// Change value increment
void FXRealSpinner::setIncrement(FXdouble inc){
  if(inc<=0.0){ fxerror("%s::setIncrement: negative or zero increment specified.\n",getClassName()); }
  incr=inc;
  }



// Change spinner granularity
void FXRealSpinner::setGranularity(FXdouble gr){
  if(gr<0.0){ fxerror("%s::setGranularity: negative granularity specified.\n",getClassName()); }
  gran=gr;
  }


// True if text supposed to be visible
FXbool FXRealSpinner::isTextVisible() const {
  return textField->shown();
  }


// Change text visibility
void FXRealSpinner::setTextVisible(FXbool flag){
  FXuint opts=(((0-flag)^options)&REALSPIN_NOTEXT)^options;
  if(options!=opts){
    options=opts;
    recalc();
    }
  }


// Set the font used in the text field|
void FXRealSpinner::setFont(FXFont *fnt){
  textField->setFont(fnt);
  }


// Return the font used in the text field
FXFont *FXRealSpinner::getFont() const {
  return textField->getFont();
  }


// Set help text
void FXRealSpinner::setHelpText(const FXString&  text){
  textField->setHelpText(text);
  upButton->setHelpText(text);
  downButton->setHelpText(text);
  }


// Get help text
const FXString& FXRealSpinner::getHelpText() const {
  return textField->getHelpText();
  }


// Set tip text
void FXRealSpinner::setTipText(const FXString&  text){
  textField->setTipText(text);
  upButton->setTipText(text);
  downButton->setTipText(text);
  }


// Get tip text
const FXString& FXRealSpinner::getTipText() const {
  return textField->getTipText();
  }


// Change spinner style
void FXRealSpinner::setSpinnerStyle(FXuint style){
  FXuint opts=((style^options)&REALSPINNER_MASK)^options;
  if(options!=opts){
    if(opts&REALSPIN_NOMIN) range[0]=-DBL_MAX;
    if(opts&REALSPIN_NOMAX) range[1]=DBL_MAX;
    options=opts;
    recalc();
    }
  }


// Get spinner style
FXuint FXRealSpinner::getSpinnerStyle() const {
  return (options&REALSPINNER_MASK);
  }


// Allow editing of the text field
void FXRealSpinner::setEditable(FXbool edit){
  textField->setEditable(edit);
  }


// Return true if text field is editable
FXbool FXRealSpinner::isEditable() const {
  return textField->isEditable();
  }

// Change color of the up arrow
void FXRealSpinner::setUpArrowColor(FXColor clr){
  upButton->setArrowColor(clr);
  }

// Return color of the up arrow
FXColor FXRealSpinner::getUpArrowColor() const {
  return upButton->getArrowColor();
  }

// Change color of the down arrow
void FXRealSpinner::setDownArrowColor(FXColor clr){
  downButton->setArrowColor(clr);
  }

// Return color of the the down arrow
FXColor FXRealSpinner::getDownArrowColor() const {
  return downButton->getArrowColor();
  }

// Change text color
void FXRealSpinner::setTextColor(FXColor clr){
  textField->setTextColor(clr);
  }

// Return text color
FXColor FXRealSpinner::getTextColor() const {
  return textField->getTextColor();
  }

// Change selected background color
void FXRealSpinner::setSelBackColor(FXColor clr){
  textField->setSelBackColor(clr);
  }

// Return selected background color
FXColor FXRealSpinner::getSelBackColor() const {
  return textField->getSelBackColor();
  }

// Change selected text color
void FXRealSpinner::setSelTextColor(FXColor clr){
  textField->setSelTextColor(clr);
  }

// Return selected text color
FXColor FXRealSpinner::getSelTextColor() const {
  return textField->getSelTextColor();
  }

// Changes the cursor color
void FXRealSpinner::setCursorColor(FXColor clr){
  textField->setCursorColor(clr);
  }

// Return the cursor color
FXColor FXRealSpinner::getCursorColor() const {
  return textField->getCursorColor();
  }


// Change number of columns
void FXRealSpinner::setNumColumns(FXint ncols){
  textField->setNumColumns(ncols);
  }


// Return number of columns
FXint FXRealSpinner::getNumColumns() const {
  return textField->getNumColumns();
  }


// Save object to stream
void FXRealSpinner::save(FXStream& store) const {
  FXPacker::save(store);
  store << textField;
  store << upButton;
  store << downButton;
  store << range[0] << range[1];
  store << incr;
  store << gran;
  store << pos;
  }


// Load object from stream
void FXRealSpinner::load(FXStream& store){
  FXPacker::load(store);
  store >> textField;
  store >> upButton;
  store >> downButton;
  store >> range[0] >> range[1];
  store >> incr;
  store >> gran;
  store >> pos;
  }


// Destruct spinner:- trash it!
FXRealSpinner::~FXRealSpinner(){
  textField=(FXTextField*)-1L;
  upButton=(FXArrowButton*)-1L;
  downButton=(FXArrowButton*)-1L;
  }

}