1 /******************************************************************************** 2 * * 3 * A r r o w B u t t o n W i d g e t * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 1998,2005 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or * 9 * modify it under the terms of the GNU Lesser General Public * 10 * License as published by the Free Software Foundation; either * 11 * version 2.1 of the License, or (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 16 * Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public * 19 * License along with this library; if not, write to the Free Software * 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 21 ********************************************************************************* 22 * $Id: FXArrowButton.h,v 1.37 2005/01/16 16:06:06 fox Exp $ * 23 ********************************************************************************/ 24 #ifndef FXARROWBUTTON_H 25 #define FXARROWBUTTON_H 26 27 #ifndef FXFRAME_H 28 #include "FXFrame.h" 29 #endif 30 31 namespace FX { 32 33 34 // Arrow style options 35 enum { 36 ARROW_NONE = 0, // No arrow 37 ARROW_UP = 0x00080000, // Arrow points up 38 ARROW_DOWN = 0x00100000, // Arrow points down 39 ARROW_LEFT = 0x00200000, // Arrow points left 40 ARROW_RIGHT = 0x00400000, // Arrow points right 41 ARROW_AUTO = 0x00800000, // Automatically fire when hovering mouse over button 42 ARROW_REPEAT = 0x01000000, // Button repeats if held down 43 ARROW_AUTOGRAY = 0x02000000, // Automatically gray out when not updated 44 ARROW_AUTOHIDE = 0x04000000, // Automatically hide when not updated 45 ARROW_TOOLBAR = 0x08000000, // Button is toolbar-style 46 ARROW_NORMAL = FRAME_RAISED|FRAME_THICK|ARROW_UP 47 }; 48 49 50 /** 51 * Button with an arrow; the arrow can point in any direction. 52 * When clicked, the arrow button sends a SEL_COMMAND to its target. 53 * When ARROW_REPEAT is passed, the arrow button sends a SEL_COMMAND 54 * repeatedly while the button is pressed. 55 * The option ARROW_AUTO together with ARROW_REPEAT makes the arrow 56 * button work in repeat mode simply by hovering the cursor over it. 57 */ 58 class FXAPI FXArrowButton : public FXFrame { 59 FXDECLARE(FXArrowButton) 60 protected: 61 FXColor arrowColor; // Arrow color 62 FXint arrowSize; // Arrow size 63 FXString tip; // Tooltip value 64 FXString help; // Help value 65 FXbool state; // State of button 66 FXbool fired; // Timer has fired 67 protected: 68 FXArrowButton(); 69 private: 70 FXArrowButton(const FXArrowButton&); 71 FXArrowButton &operator=(const FXArrowButton&); 72 public: 73 long onPaint(FXObject*,FXSelector,void*); 74 long onUpdate(FXObject*,FXSelector,void*); 75 long onEnter(FXObject*,FXSelector,void*); 76 long onLeave(FXObject*,FXSelector,void*); 77 long onLeftBtnPress(FXObject*,FXSelector,void*); 78 long onLeftBtnRelease(FXObject*,FXSelector,void*); 79 long onUngrabbed(FXObject*,FXSelector,void*); 80 long onRepeat(FXObject*,FXSelector,void*); 81 long onAuto(FXObject*,FXSelector,void*); 82 long onKeyPress(FXObject*,FXSelector,void*); 83 long onKeyRelease(FXObject*,FXSelector,void*); 84 long onHotKeyPress(FXObject*,FXSelector,void*); 85 long onHotKeyRelease(FXObject*,FXSelector,void*); 86 long onCmdSetHelp(FXObject*,FXSelector,void*); 87 long onCmdGetHelp(FXObject*,FXSelector,void*); 88 long onCmdSetTip(FXObject*,FXSelector,void*); 89 long onCmdGetTip(FXObject*,FXSelector,void*); 90 long onQueryHelp(FXObject*,FXSelector,void*); 91 long onQueryTip(FXObject*,FXSelector,void*); 92 public: 93 enum { 94 ID_REPEAT=FXFrame::ID_LAST, 95 ID_AUTO, 96 ID_LAST 97 }; 98 public: 99 100 /// Construct arrow button 101 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); 102 103 /// Get default width 104 virtual FXint getDefaultWidth(); 105 106 /// Get default height 107 virtual FXint getDefaultHeight(); 108 109 /// Enable the button 110 virtual void enable(); 111 112 /// Disable the button 113 virtual void disable(); 114 115 /// Returns true because a button can receive focus 116 virtual FXbool canFocus() const; 117 118 /// Set the button state (where TRUE means the button is down) 119 void setState(FXbool s); 120 121 /// Get the button state (where TRUE means the button is down) getState()122 FXbool getState() const { return state; } 123 124 /// Set status line help text for this arrow button setHelpText(const FXString & text)125 void setHelpText(const FXString& text){ help=text; } 126 127 /// Get status line help text for this arrow button getHelpText()128 const FXString& getHelpText() const { return help; } 129 130 /// Set tool tip message for this arrow button setTipText(const FXString & text)131 void setTipText(const FXString& text){ tip=text; } 132 133 /// Get tool tip message for this arrow button getTipText()134 const FXString& getTipText() const { return tip; } 135 136 /// Set the arrow style flags 137 void setArrowStyle(FXuint style); 138 139 /// Get the arrow style flags 140 FXuint getArrowStyle() const; 141 142 /// Set the default arrow size 143 void setArrowSize(FXint size); 144 145 /// Get the default arrow size getArrowSize()146 FXint getArrowSize() const { return arrowSize; } 147 148 /// Set the current justification mode. 149 void setJustify(FXuint mode); 150 151 /// Get the current justification mode. 152 FXuint getJustify() const; 153 154 /// Get the fill color for the arrow getArrowColor()155 FXColor getArrowColor() const { return arrowColor; } 156 157 /// Set the fill color for the arrow 158 void setArrowColor(FXColor clr); 159 160 /// Save label to a stream 161 virtual void save(FXStream& store) const; 162 163 /// Load label from a stream 164 virtual void load(FXStream& store); 165 166 /// Destructor 167 virtual ~FXArrowButton(); 168 }; 169 170 } 171 172 #endif 173