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

FXCheckButton.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                    C h e c k   B u t t o n   W i d g e t                      *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2006 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: FXCheckButton.h,v 1.32 2006/01/22 17:57:59 fox Exp $                     *
00023 ********************************************************************************/
00024 #ifndef FXCHECKBUTTON_H
00025 #define FXCHECKBUTTON_H
00026 
00027 #ifndef FXLABEL_H
00028 #include "FXLabel.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// CheckButton styles
00035 enum {
00036   CHECKBUTTON_AUTOGRAY = 0x00800000,    /// Automatically gray out when not updated
00037   CHECKBUTTON_AUTOHIDE = 0x01000000,    /// Automatically hide when not updated
00038   CHECKBUTTON_PLUS     = 0x02000000,    /// Draw a + for unchecked and - for checked
00039   CHECKBUTTON_NORMAL   = JUSTIFY_NORMAL|ICON_BEFORE_TEXT
00040   };
00041 
00042 
00043 /**
00044 * A Check Button is a tri-state button.  Normally, it is either
00045 * TRUE or FALSE, and toggles between TRUE or FALSE whenever it is pressed.
00046 * A third state MAYBE may be set to indicate that no selection has been made yet
00047 * by the user, or that the state is ambiguous.
00048 * When pressed, the Check Button sends a SEL_COMMAND to its target, and the
00049 * message data represents the state of the check button.
00050 * The option CHECKBUTTON_AUTOGRAY (CHECKBUTTON_AUTOHIDE) causes the button to be
00051 * grayed out (hidden) if its handler does not respond to the SEL_UPDATE message.
00052 * With the CHECKBUTTON_PLUS option, the Check Button will draw a + or - sign instead
00053 * of a check.  You can use this to make collapsable panels, by hooking up a Check
00054 * Button to a layout manager via the ID_TOGGLE_SHOWN message.  This will give a
00055 * similar visual element as collapsing folders in a Tree List.
00056 */
00057 class FXAPI FXCheckButton : public FXLabel {
00058   FXDECLARE(FXCheckButton)
00059 protected:
00060   FXColor  checkColor;  // Color of check mark
00061   FXColor  boxColor;    // Color of check box
00062   FXbool   check;       // Check state
00063   FXbool   oldcheck;    // Old check state
00064 protected:
00065   FXCheckButton();
00066 private:
00067   FXCheckButton(const FXCheckButton&);
00068   FXCheckButton &operator=(const FXCheckButton&);
00069 public:
00070   long onPaint(FXObject*,FXSelector,void*);
00071   long onUpdate(FXObject*,FXSelector,void*);
00072   long onEnter(FXObject*,FXSelector,void*);
00073   long onLeave(FXObject*,FXSelector,void*);
00074   long onFocusIn(FXObject*,FXSelector,void*);
00075   long onFocusOut(FXObject*,FXSelector,void*);
00076   long onUngrabbed(FXObject*,FXSelector,void*);
00077   long onLeftBtnPress(FXObject*,FXSelector,void*);
00078   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00079   long onKeyPress(FXObject*,FXSelector,void*);
00080   long onKeyRelease(FXObject*,FXSelector,void*);
00081   long onHotKeyPress(FXObject*,FXSelector,void*);
00082   long onHotKeyRelease(FXObject*,FXSelector,void*);
00083   long onCheck(FXObject*,FXSelector,void*);
00084   long onUncheck(FXObject*,FXSelector,void*);
00085   long onUnknown(FXObject*,FXSelector,void*);
00086   long onCmdSetValue(FXObject*,FXSelector,void*);
00087   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00088   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00089 public:
00090 
00091   /// Construct new check button
00092   FXCheckButton(FXComposite* p,const FXString& text,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=CHECKBUTTON_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);
00093 
00094   /// Returns true because a check button can receive focus
00095   virtual bool canFocus() const;
00096 
00097   /// Get default width
00098   virtual FXint getDefaultWidth();
00099 
00100   /// Get default height
00101   virtual FXint getDefaultHeight();
00102 
00103   /// Set check button state (TRUE, FALSE or MAYBE)
00104   void setCheck(FXbool state=TRUE,FXbool notify=FALSE);
00105 
00106   /// Get check button state (TRUE, FALSE or MAYBE)
00107   FXbool getCheck() const { return check; }
00108 
00109   /// Change check button style
00110   void setCheckButtonStyle(FXuint style);
00111 
00112   /// Return current check button style
00113   FXuint getCheckButtonStyle() const;
00114 
00115   /// Get the box background color
00116   FXColor getBoxColor() const { return boxColor; }
00117 
00118   /// Set the box background color
00119   void setBoxColor(FXColor clr);
00120 
00121   /// Get the box check color
00122   FXColor getCheckColor() const { return checkColor; }
00123 
00124   /// Set the box check color
00125   void setCheckColor(FXColor clr);
00126 
00127   /// Save check button to a stream
00128   virtual void save(FXStream& store) const;
00129 
00130   /// Load check button from a stream
00131   virtual void load(FXStream& store);
00132   };
00133 
00134 }
00135 
00136 #endif

Copyright © 1997-2005 Jeroen van der Zijp