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

FXArrowButton.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                     A r r o w   B u t t o n   W i d g e t                     *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXArrowButton.h,v 1.47 2009/01/06 13:07:21 fox Exp $                     *
00022 ********************************************************************************/
00023 #ifndef FXARROWBUTTON_H
00024 #define FXARROWBUTTON_H
00025 
00026 #ifndef FXFRAME_H
00027 #include "FXFrame.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 // Arrow style options
00034 enum {
00035   ARROW_NONE     = 0,   // No arrow
00036   ARROW_UP       = 0x00080000,  // Arrow points up
00037   ARROW_DOWN     = 0x00100000,  // Arrow points down
00038   ARROW_LEFT     = 0x00200000,  // Arrow points left
00039   ARROW_RIGHT    = 0x00400000,  // Arrow points right
00040   ARROW_AUTO     = 0x00800000,  // Automatically fire when hovering mouse over button
00041   ARROW_REPEAT   = 0x01000000,  // Button repeats if held down
00042   ARROW_AUTOGRAY = 0x02000000,  // Automatically gray out when not updated
00043   ARROW_AUTOHIDE = 0x04000000,  // Automatically hide when not updated
00044   ARROW_TOOLBAR  = 0x08000000,  // Button is toolbar-style
00045   ARROW_NORMAL   = FRAME_RAISED|FRAME_THICK|ARROW_UP
00046   };
00047 
00048 
00049 /**
00050 * Button with an arrow; the arrow can point in any direction.
00051 * When clicked, the arrow button sends a SEL_COMMAND to its target.
00052 * When ARROW_REPEAT is passed, the arrow button sends a SEL_COMMAND
00053 * repeatedly while the button is pressed.
00054 * The option ARROW_AUTO together with ARROW_REPEAT makes the arrow
00055 * button work in repeat mode simply by hovering the cursor over it.
00056 */
00057 class FXAPI FXArrowButton : public FXFrame {
00058   FXDECLARE(FXArrowButton)
00059 protected:
00060   FXColor   arrowColor;     // Arrow color
00061   FXint     arrowSize;      // Arrow size
00062   FXString  tip;            // Tooltip value
00063   FXString  help;           // Help value
00064   FXbool    state;          // State of button
00065   FXbool    fired;          // Timer has fired
00066 protected:
00067   FXArrowButton();
00068 private:
00069   FXArrowButton(const FXArrowButton&);
00070   FXArrowButton &operator=(const FXArrowButton&);
00071 public:
00072   long onPaint(FXObject*,FXSelector,void*);
00073   long onUpdate(FXObject*,FXSelector,void*);
00074   long onEnter(FXObject*,FXSelector,void*);
00075   long onLeave(FXObject*,FXSelector,void*);
00076   long onLeftBtnPress(FXObject*,FXSelector,void*);
00077   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00078   long onUngrabbed(FXObject*,FXSelector,void*);
00079   long onRepeat(FXObject*,FXSelector,void*);
00080   long onAuto(FXObject*,FXSelector,void*);
00081   long onKeyPress(FXObject*,FXSelector,void*);
00082   long onKeyRelease(FXObject*,FXSelector,void*);
00083   long onHotKeyPress(FXObject*,FXSelector,void*);
00084   long onHotKeyRelease(FXObject*,FXSelector,void*);
00085   long onCmdSetHelp(FXObject*,FXSelector,void*);
00086   long onCmdGetHelp(FXObject*,FXSelector,void*);
00087   long onCmdSetTip(FXObject*,FXSelector,void*);
00088   long onCmdGetTip(FXObject*,FXSelector,void*);
00089   long onQueryHelp(FXObject*,FXSelector,void*);
00090   long onQueryTip(FXObject*,FXSelector,void*);
00091 public:
00092   enum {
00093     ID_REPEAT=FXFrame::ID_LAST,
00094     ID_AUTO,
00095     ID_LAST
00096     };
00097 public:
00098 
00099   /// Construct arrow button
00100   FXArrowButton(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=ARROW_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);
00101 
00102   /// Get default width
00103   virtual FXint getDefaultWidth();
00104 
00105   /// Get default height
00106   virtual FXint getDefaultHeight();
00107 
00108   /// Enable the button
00109   virtual void enable();
00110 
00111   /// Disable the button
00112   virtual void disable();
00113 
00114   /// Returns true because a button can receive focus
00115   virtual FXbool canFocus() const;
00116 
00117   /// Set the button state (where true means the button is down)
00118   void setState(FXbool s);
00119 
00120   /// Get the button state (where true means the button is down)
00121   FXbool getState() const { return state; }
00122 
00123   /// Set status line help text for this arrow button
00124   void setHelpText(const FXString& text){ help=text; }
00125 
00126   /// Get status line help text for this arrow button
00127   const FXString& getHelpText() const { return help; }
00128 
00129   /// Set tool tip message for this arrow button
00130   void setTipText(const FXString& text){ tip=text; }
00131 
00132   /// Get tool tip message for this arrow button
00133   const FXString& getTipText() const { return tip; }
00134 
00135   /// Set the arrow style flags
00136   void setArrowStyle(FXuint style);
00137 
00138   /// Get the arrow style flags
00139   FXuint getArrowStyle() const;
00140 
00141   /// Set the default arrow size
00142   void setArrowSize(FXint size);
00143 
00144   /// Get the default arrow size
00145   FXint getArrowSize() const { return arrowSize; }
00146 
00147   /// Set the current justification mode.
00148   void setJustify(FXuint mode);
00149 
00150   /// Get the current justification mode.
00151   FXuint getJustify() const;
00152 
00153   /// Get the fill color for the arrow
00154   FXColor getArrowColor() const { return arrowColor; }
00155 
00156   /// Set the fill color for the arrow
00157   void setArrowColor(FXColor clr);
00158 
00159   /// Save label to a stream
00160   virtual void save(FXStream& store) const;
00161 
00162   /// Load label from a stream
00163   virtual void load(FXStream& store);
00164 
00165   /// Destructor
00166   virtual ~FXArrowButton();
00167   };
00168 
00169 }
00170 
00171 #endif

Copyright © 1997-2009 Jeroen van der Zijp