Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

MyThumbWheel.h

00001 /*
00002  *
00003  *  Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved. 
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  Further, this software is distributed without any warranty that it is
00016  *  free of the rightful claim of any third person regarding infringement
00017  *  or the like.  Any license provided herein, whether implied or
00018  *  otherwise, applies only to this software file.  Patent licenses, if
00019  *  any, provided herein do not apply to combinations of this program with
00020  *  other software, or any other product whatsoever.
00021  * 
00022  *  You should have received a copy of the GNU Lesser General Public
00023  *  License along with this library; if not, write to the Free Software
00024  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  *  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
00027  *  Mountain View, CA  94043, or:
00028  * 
00029  *  http://www.sgi.com 
00030  * 
00031  *  For further information regarding this notice, see: 
00032  * 
00033  *  http://oss.sgi.com/projects/GenInfo/NoticeExplan/
00034  *
00035  */
00036 
00037 //  -*- C++ -*-
00038 
00039 /*
00040  * Copyright (C) 1990-93   Silicon Graphics, Inc.
00041  *
00042  _______________________________________________________________________
00043  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00044  |
00045  |   $Revision: 1.1 $
00046  |
00047  |   Description:
00048  |      This file contains the MyThumbWheel class which is a GL wheel 
00049  |  viewed on it's side. It is mostly used to control things like rotation
00050  |  where a thumb wheel is better than a regular slider.
00051  |      
00052  |   Classes:
00053  |      MyThumbWheel
00054  |      
00055  |   Author(s)  : Alain Dumesny
00056  |
00057  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00058  _______________________________________________________________________
00059  */
00060 
00061 #ifndef  _SO_XT_THUMB_WHEEL_
00062 #define  _SO_XT_THUMB_WHEEL_
00063 
00064 #include <Inventor/Xt/SoXtGLWidget.h>
00065 #include <Inventor/misc/SoCallbackList.h>
00066 
00067 
00068 class SoXtMouse;
00069 class MyFloatCallbackList;
00070 
00071 // callback function prototypes
00072 typedef void MyThumbWheelCB(void *userData, float val);
00073 
00075 //
00076 //  Class: MyThumbWheel
00077 //
00078 //
00080 
00081 // C-api: prefix=MyThumbWhl
00082 class MyThumbWheel : public SoXtGLWidget {
00083 
00084   public:
00085     
00086     MyThumbWheel(SbBool horizontal = TRUE);
00087     MyThumbWheel(
00088         Widget parent = NULL,
00089         const char *name = NULL, 
00090         SbBool buildInsideParent = TRUE, 
00091         SbBool horizontal = TRUE);
00092     ~MyThumbWheel();
00093     
00094     //
00095     // Routines to specify the wheel value (a rotation given in radians) and get
00096     // the current wheel value.
00097     //
00098     // NOTE: setValue() will call valueChanged callbacks if the value differs.
00099     //
00100     void        setValue(float radians);
00101     float       getValue()                      { return value; }
00102     
00103     //
00104     // Those routines are used to register callbacks for the different thumb wheel
00105     // actions.
00106     //
00107     // NOTE: the start and finish callbacks are only to signal when the mouse
00108     // goes down and up. No valid callback data is passed (NULL passed).
00109     //
00110     // C-api: name=addStartCB
00111     void        addStartCallback(
00112                         MyThumbWheelCB *f,
00113                         void *userData = NULL);
00114     // C-api: name=addValueChangedCB
00115     void        addValueChangedCallback(
00116                         MyThumbWheelCB *f,
00117                         void *userData = NULL);
00118     // C-api: name=addFinishCB
00119     void        addFinishCallback(
00120                         MyThumbWheelCB *f,
00121                         void *userData = NULL);
00122 
00123     // C-api: name=removeStartCB
00124     void        removeStartCallback(
00125                         MyThumbWheelCB *f,
00126                         void *userData = NULL);
00127     // C-api: name=removeValueChangedCB
00128     void        removeValueChangedCallback(
00129                         MyThumbWheelCB *f,
00130                         void *userData = NULL);
00131     // C-api: name=removeFinishCB
00132     void        removeFinishCallback(
00133                         MyThumbWheelCB *f,
00134                         void *userData = NULL);
00135 
00136     // true while the value is changing interactively
00137     SbBool  isInteractive()                     { return interactive; }
00138   
00139   protected:
00140 
00141     // This constructor takes a boolean whether to build the widget now.
00142     // Subclasses can pass FALSE, then call SoXtPushButton::buildWidget()
00143     // when they are ready for it to be built.
00144     SoEXTENDER
00145     MyThumbWheel(
00146         Widget parent,
00147         const char *name, 
00148         SbBool buildInsideParent,
00149         SbBool horizontal, 
00150         SbBool buildNow);
00151 
00152     Widget          buildWidget(Widget parent);
00153     
00154   private:
00155     // redefine these to do thumb wheel specific things
00156     virtual void    redraw();
00157     virtual void    processEvent(XAnyEvent *anyevent);
00158     virtual void    sizeChanged(const SbVec2s &newSize);
00159     
00160     // local variables
00161     SbBool      horizontal;
00162     float       value;
00163     int         lastPosition;
00164     SoXtMouse   *mouse;
00165     
00166     // callback variables
00167     MyFloatCallbackList *startCallbacks;
00168     MyFloatCallbackList *changedCallbacks;
00169     MyFloatCallbackList *finishCallbacks;
00170     SbBool      interactive;
00171 
00172     // this is called by both constructors
00173     void constructorCommon(SbBool horizontal, SbBool buildNow);
00174 };
00175 
00176 #endif  /* _SO_XT_THUMB_WHEEL_ */

Generated on Fri Oct 26 23:38:09 2001 for bicobj-intersection by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001