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