![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * M e n u C o m m a n d W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2002 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: FXMenuCommand.h,v 1.22 2002/03/12 07:11:30 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXMENUCOMMAND_H 00025 #define FXMENUCOMMAND_H 00026 00027 #ifndef FXMENUCAPTION_H 00028 #include "FXMenuCaption.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /// States the menu command can be in 00035 enum { 00036 MENUSTATE_NORMAL = 0, /// Normal, unchecked state 00037 MENUSTATE_CHECKED = 1, /// Checked with a checkmark 00038 MENUSTATE_RCHECKED = 2 /// Checked with a bullet 00039 }; 00040 00041 00042 /** 00043 * The menu command widget is used to invoke a command in the 00044 * application from a menu. Menu commands may reflect 00045 * the state of the application by graying out, becoming hidden, 00046 * or by a check mark or bullit. 00047 */ 00048 class FXAPI FXMenuCommand : public FXMenuCaption { 00049 FXDECLARE(FXMenuCommand) 00050 protected: 00051 FXuchar state; // State of menu 00052 FXString accel; // Accelerator string 00053 FXHotKey acckey; // Accelerator key 00054 protected: 00055 FXMenuCommand(); 00056 void drawCheck(FXDCWindow& dc,FXint x,FXint y); 00057 void drawBullit(FXDCWindow& dc,FXint x,FXint y); 00058 private: 00059 FXMenuCommand(const FXMenuCommand&); 00060 FXMenuCommand &operator=(const FXMenuCommand&); 00061 public: 00062 long onPaint(FXObject*,FXSelector,void*); 00063 long onEnter(FXObject*,FXSelector,void*); 00064 long onLeave(FXObject*,FXSelector,void*); 00065 long onButtonPress(FXObject*,FXSelector,void*); 00066 long onButtonRelease(FXObject*,FXSelector,void*); 00067 long onKeyPress(FXObject*,FXSelector,void*); 00068 long onKeyRelease(FXObject*,FXSelector,void*); 00069 long onHotKeyPress(FXObject*,FXSelector,void*); 00070 long onHotKeyRelease(FXObject*,FXSelector,void*); 00071 long onCheck(FXObject*,FXSelector,void*); 00072 long onUncheck(FXObject*,FXSelector,void*); 00073 long onCmdSetValue(FXObject*,FXSelector,void*); 00074 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00075 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00076 long onCmdAccel(FXObject*,FXSelector,void*); 00077 public: 00078 00079 /// Construct a menu command 00080 FXMenuCommand(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0); 00081 00082 /// Return default width 00083 virtual FXint getDefaultWidth(); 00084 00085 /// Return default height 00086 virtual FXint getDefaultHeight(); 00087 00088 /// Yes it can receive the focus 00089 virtual FXbool canFocus() const; 00090 00091 /// Move the focus to this window 00092 virtual void setFocus(); 00093 00094 /// Remove the focus from this window 00095 virtual void killFocus(); 00096 00097 /// Place checkmark next to text 00098 void check(); 00099 00100 /// Uncheck the item 00101 void uncheck(); 00102 00103 /// Return TRUE if checked 00104 FXint isChecked() const; 00105 00106 /// Place radio bullit next to text 00107 void checkRadio(); 00108 00109 /// Uncheck radio bullit 00110 void uncheckRadio(); 00111 00112 /// Return TRUE if radio-checked 00113 FXint isRadioChecked() const; 00114 00115 /// Set accelerator text 00116 void setAccelText(const FXString& text); 00117 00118 /// Return accelarator text 00119 FXString getAccelText() const { return accel; } 00120 00121 /// Save menu to a stream 00122 virtual void save(FXStream& store) const; 00123 00124 /// Load menu from a stream 00125 virtual void load(FXStream& store); 00126 00127 /// Destructor 00128 virtual ~FXMenuCommand(); 00129 }; 00130 00131 } 00132 00133 #endif