Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXColorBar.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                         C o l o r B a r   W i d g e t                         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2001,2004 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXColorBar.h,v 1.16 2004/02/08 17:17:33 fox Exp $                        *
00023 ********************************************************************************/
00024 #ifndef FXCOLORBAR_H
00025 #define FXCOLORBAR_H
00026 
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// Color bar orientation
00035 enum {
00036   COLORBAR_HORIZONTAL = 0,            /// Color bar shown horizontally
00037   COLORBAR_VERTICAL   = 0x00008000    /// Color bar shown vertically
00038   };
00039 
00040 
00041 class FXImage;
00042 
00043 
00044 /**
00045 * A color bar is a widget which controls the brightness (value) of a
00046 * color by means of the hue, saturation, value specification system.
00047 */
00048 class FXAPI FXColorBar : public FXFrame {
00049   FXDECLARE(FXColorBar)
00050 protected:
00051   FXImage  *bar;          // Intensity bar
00052   FXfloat   hsv[3];       // Hue, saturation, value
00053   FXString  tip;          // Tooltip value
00054   FXString  help;         // Help value
00055 protected:
00056   FXColorBar();
00057   void updatebar();
00058 private:
00059   FXColorBar(const FXColorBar&);
00060   FXColorBar &operator=(const FXColorBar&);
00061 public:
00062   long onPaint(FXObject*,FXSelector,void*);
00063   long onLeftBtnPress(FXObject*,FXSelector,void*);
00064   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00065   long onMotion(FXObject*,FXSelector,void*);
00066   long onCmdSetHelp(FXObject*,FXSelector,void*);
00067   long onCmdGetHelp(FXObject*,FXSelector,void*);
00068   long onCmdSetTip(FXObject*,FXSelector,void*);
00069   long onCmdGetTip(FXObject*,FXSelector,void*);
00070   long onQueryHelp(FXObject*,FXSelector,void*);
00071   long onQueryTip(FXObject*,FXSelector,void*);
00072 public:
00073 
00074   /// Construct color bar
00075   FXColorBar(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=FRAME_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);
00076 
00077   /// Create server-side resources
00078   virtual void create();
00079 
00080   /// Detach server-side resources
00081   virtual void detach();
00082 
00083   /// Return default width
00084   virtual FXint getDefaultWidth();
00085 
00086   /// Return default height
00087   virtual FXint getDefaultHeight();
00088 
00089   /// Perform layout
00090   virtual void layout();
00091 
00092   /// Change hue
00093   void setHue(FXfloat h);
00094 
00095   /// Return hue
00096   FXfloat getHue() const { return hsv[0]; }
00097 
00098   /// Change saturation
00099   void setSat(FXfloat s);
00100 
00101   /// Return saturation
00102   FXfloat getSat() const { return hsv[1]; }
00103 
00104   /// Change value
00105   void setVal(FXfloat v);
00106 
00107   /// Return value
00108   FXfloat getVal() const { return hsv[2]; }
00109 
00110   /// Change the color bar style
00111   FXuint getBarStyle() const;
00112 
00113   /// Get the color bar style
00114   void setBarStyle(FXuint style);
00115 
00116   /// Set status line help text for this color bar
00117   void setHelpText(const FXString& text){ help=text; }
00118 
00119   /// Get status line help text for this color bar
00120   FXString getHelpText() const { return help; }
00121 
00122   /// Set tool tip message for this color bar
00123   void setTipText(const FXString& text){ tip=text; }
00124 
00125   /// Get tool tip message for this color bar
00126   FXString getTipText() const { return tip; }
00127 
00128   /// Save color bar to a stream
00129   virtual void save(FXStream& store) const;
00130 
00131   /// Load color bar from a stream
00132   virtual void load(FXStream& store);
00133 
00134   /// Destructor
00135   virtual ~FXColorBar();
00136   };
00137 
00138 }
00139 
00140 #endif

Copyright © 1997-2004 Jeroen van der Zijp