![]() |
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,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: FXMenuCommand.h,v 1.36 2009/01/19 22:51:50 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXMENUCOMMAND_H 00024 #define FXMENUCOMMAND_H 00025 00026 #ifndef FXMENUCAPTION_H 00027 #include "FXMenuCaption.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /** 00034 * The menu command widget is used to invoke a command in the 00035 * application from a menu. Menu commands may reflect 00036 * the state of the application by graying out, or becoming hidden. 00037 * When activated, a menu command sends a SEL_COMMAND to its target. 00038 * When passing a tab-separated list of fields in the text parameters, the caption 00039 * text is set to the first field, the accelerator to the second field, and the 00040 * help text to the third field (see description of menu caption). 00041 * If an accelerator string is given, the corresponding accelerator key combination 00042 * is parsed out and installed into the menu pane's owner's accelerator table. 00043 * Note that this means owners of menu panes should delete their menupanes properly 00044 * upon destruction. 00045 */ 00046 class FXAPI FXMenuCommand : public FXMenuCaption { 00047 FXDECLARE(FXMenuCommand) 00048 protected: 00049 FXString accel; // Accelerator string 00050 FXHotKey acckey; // Accelerator key 00051 protected: 00052 FXMenuCommand(); 00053 private: 00054 FXMenuCommand(const FXMenuCommand&); 00055 FXMenuCommand &operator=(const FXMenuCommand&); 00056 public: 00057 long onPaint(FXObject*,FXSelector,void*); 00058 long onEnter(FXObject*,FXSelector,void*); 00059 long onLeave(FXObject*,FXSelector,void*); 00060 long onButtonPress(FXObject*,FXSelector,void*); 00061 long onButtonRelease(FXObject*,FXSelector,void*); 00062 long onKeyPress(FXObject*,FXSelector,void*); 00063 long onKeyRelease(FXObject*,FXSelector,void*); 00064 long onHotKeyPress(FXObject*,FXSelector,void*); 00065 long onHotKeyRelease(FXObject*,FXSelector,void*); 00066 long onCmdAccel(FXObject*,FXSelector,void*); 00067 public: 00068 00069 /// Construct a menu command 00070 FXMenuCommand(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0); 00071 00072 /// Return default width 00073 virtual FXint getDefaultWidth(); 00074 00075 /// Return default height 00076 virtual FXint getDefaultHeight(); 00077 00078 /// Yes it can receive the focus 00079 virtual FXbool canFocus() const; 00080 00081 /// Move the focus to this window 00082 virtual void setFocus(); 00083 00084 /// Remove the focus from this window 00085 virtual void killFocus(); 00086 00087 /// Set accelerator text; update accelerator if acc is true 00088 void setAccelText(const FXString& text,FXbool acc=false); 00089 00090 /// Return accelarator text 00091 FXString getAccelText() const { return accel; } 00092 00093 /// Save menu to a stream 00094 virtual void save(FXStream& store) const; 00095 00096 /// Load menu from a stream 00097 virtual void load(FXStream& store); 00098 00099 /// Destructor 00100 virtual ~FXMenuCommand(); 00101 }; 00102 00103 } 00104 00105 #endif
![]() |