home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / inventor / noodle / NoodleSlider.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.4 KB  |  80 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18. |   Description:
  19. |      A component class that creates a more functionally extensive
  20. |      slider than that given by motif.
  21. |
  22. |   Author(s)          : Paul Isaacs
  23. |
  24. */
  25.  
  26.  
  27. #ifndef _NOODLE_SLIDER_
  28. #define _NOODLE_SLIDER_
  29.  
  30. #include <Xm/Xm.h>
  31. #include <Inventor/Xt/SoXtComponent.h>
  32. #include <Inventor/misc/SoCallbackList.h>
  33.  
  34. class NoodleSlider : public SoXtComponent {
  35.   public:
  36.     NoodleSlider( 
  37.     Widget parent = NULL,
  38.     const char *name = NULL, 
  39.     SbBool buildInsideParent = TRUE,
  40.     int startingMin = -1000, 
  41.     int startingMax = 1000);
  42.     ~NoodleSlider();
  43.  
  44.       // add callbacks to the slider to be called when the value changes,
  45.       // either from the slider or the text widget.
  46.       void addValueChangedCallback(SoCallbackListCB *f, void *userData = NULL);
  47.       void removeValueChangedCallback(SoCallbackListCB *f,void *userData =NULL);
  48.  
  49.       // return the current value, min, or max.
  50.       float   getValue();
  51.       float   getMin();
  52.       float   getMax();
  53.  
  54.       // set the value, min, or max.
  55.       void    setValue(  float newVal );
  56.       void    setMin( float newVal );
  57.       void    setMax( float newVal );
  58.  
  59.   // internal:
  60.       static  void valueWidgetCallback(Widget w,
  61.                       void *client_data, void *call_data );
  62.       static  void sliderWidgetCallback(Widget w,
  63.                       void *client_data, void *call_data );
  64.       Widget buildWidget( Widget parent, int startingMin, int startingMax);
  65.  
  66.   private:
  67.       Widget      _form;
  68.       Widget      _value;
  69.       Widget      _slider;
  70.  
  71.       float convertSliderToFloat( int sliderValue );
  72.       int convertFloatToSlider( float floatValue );
  73.       short getNumDecimals();
  74.       void      initLayout();
  75.  
  76.       SoCallbackList *valueChangedCallbacks;
  77. };
  78.  
  79. #endif /* _NOODLE_SLIDER_ */
  80.