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

MyColorSlider.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,91,92   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 MyColorSlider class which is an MySlider
00049  |  (GL slider within an GLX widget) with build in policies. You can only
00050  |  build a set of pre-defined color sliders (see Type enum below).
00051  |
00052  |   Classes:
00053  |      MyColorSlider
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_COLOR_SLIDER_
00062 #define  _SO_XT_COLOR_SLIDER_
00063 
00064 #include "MySlider.h"
00065 
00066 class SbColor;
00067 class SbVec2f;
00068 
00069 
00071 //
00072 //  Class: MyColorSlider
00073 //
00074 //      This class defines the color slider which is a set of predefined
00075 //  sliders (R, G, B, H, S, V,..) with special behaviors.
00076 //
00078 
00079 // C-api: prefix=SoXtColSldr
00080 class MyColorSlider : public MySlider {
00081     
00082  public:
00083     
00084     //
00085     // list of color sliders types
00086     //
00087     enum Type {
00088         RED_SLIDER, 
00089         GREEN_SLIDER, 
00090         BLUE_SLIDER, 
00091         HUE_SLIDER, 
00092         SATURATION_SLIDER, 
00093         VALUE_SLIDER, 
00094         INTENSITY_SLIDER // independent of the slider value
00095     };
00096     
00097     // Constructor/Destructor
00098     MyColorSlider(
00099         Widget parent = NULL,
00100         const char *name = NULL, 
00101         SbBool buildInsideParent = TRUE, 
00102         MyColorSlider::Type type = INTENSITY_SLIDER);
00103     ~MyColorSlider();
00104     
00105     //
00106     // Routine used to specify the slider value and also the top region
00107     // color (WYSIWYGmode in most cases). Users should call this routine 
00108     // instead of the base class setValue() routine if they want the color 
00109     // slider top region to correctly reflect the current color.
00110     // (code is optimized for WYSIWYGmode off)
00111     //
00112     // NOTE: routine expects
00113     //      an rgb color for R, G or B slider type
00114     //      an hsv color for H, S, or V slider type
00115     //      an rgb color for Intensity slider type
00116     //
00117     // NOTE: if calling setBaseColor() changes the thumb position the
00118     // valueChanged callbacks will be called with the new value.
00119     //
00120     // C-api: name=setBaseCol
00121     void        setBaseColor(const float rgbOrHsv[3]);
00122     // C-api: name=getBaseCol
00123     const float *getBaseColor()         { return color; }
00124     
00125     //
00126     // This routine sets the WYSIWYG (What You See Is What You Get) mode
00127     // to be true or false (default FALSE). Immediate mode.
00128     // This has no effect on monochrome sliders.
00129     //
00130     void        setWYSIWYG(SbBool trueOrFalse);    // default FALSE
00131     SbBool      isWYSIWYG()             { return WYSIWYGmode; }
00132     
00133     // returns the type of the slider
00134     MyColorSlider::Type getType()       { return type; }
00135     
00136   protected:
00137 
00138     // This constructor takes a boolean whether to build the widget now.
00139     // Subclasses can pass FALSE, then call MySlider::buildWidget()
00140     // when they are ready for it to be built.
00141     SoEXTENDER
00142     MyColorSlider(
00143         Widget parent,
00144         const char *name, 
00145         SbBool buildInsideParent, 
00146         MyColorSlider::Type type, 
00147         SbBool buildNow);
00148     
00149     // redefine this routine to cache slider top geometry
00150     virtual void    sizeChanged(const SbVec2s &newSize);
00151     
00152     // redefine this routine to do the actual slider top region drawing.
00153     // This routine is automatically called by the MySlider::redraw() routine.
00154     virtual void    drawSliderTopRegion();
00155     
00156   private:
00157     
00158     // local vars
00159     Boolean             WYSIWYGmode;
00160     Type                type;
00161     float               color[3];
00162     SbColor             *defaultColors, *colors;
00163     SbVec2f             *geometry;
00164     
00165     // routine that make the default and WYSIWYG colors
00166     void    makeDefaultColors();
00167     void    makeWYSIWYGcolors();
00168     
00169     static void     sliderChangedCB(void *, float val);
00170 
00171     // this is called by both constructors
00172     void constructorCommon(MyColorSlider::Type type, SbBool buildNow);
00173 };
00174 
00175 
00176 #endif  /* _SO_XT_COLOR_SLIDER_ */

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