1 /********************************************************************************
2 *                                                                               *
3 *                       M e n u C o m m a n d   W i d g e t                     *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 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: FXMenuCommand.h,v 1.30 2006/01/22 17:58:06 fox Exp $                     *
23 ********************************************************************************/
24 #ifndef FXMENUCOMMAND_H
25 #define FXMENUCOMMAND_H
26 
27 #ifndef FXMENUCAPTION_H
28 #include "FXMenuCaption.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /**
35 * The menu command widget is used to invoke a command in the
36 * application from a menu.  Menu commands may reflect
37 * the state of the application by graying out, or becoming hidden.
38 * When activated, a menu command sends a SEL_COMMAND to its target.
39 */
40 class FXAPI FXMenuCommand : public FXMenuCaption {
41   FXDECLARE(FXMenuCommand)
42 protected:
43   FXString     accel;       // Accelerator string
44   FXHotKey     acckey;      // Accelerator key
45 protected:
46   FXMenuCommand();
47 private:
48   FXMenuCommand(const FXMenuCommand&);
49   FXMenuCommand &operator=(const FXMenuCommand&);
50 public:
51   long onPaint(FXObject*,FXSelector,void*);
52   long onEnter(FXObject*,FXSelector,void*);
53   long onLeave(FXObject*,FXSelector,void*);
54   long onButtonPress(FXObject*,FXSelector,void*);
55   long onButtonRelease(FXObject*,FXSelector,void*);
56   long onKeyPress(FXObject*,FXSelector,void*);
57   long onKeyRelease(FXObject*,FXSelector,void*);
58   long onHotKeyPress(FXObject*,FXSelector,void*);
59   long onHotKeyRelease(FXObject*,FXSelector,void*);
60   long onCmdAccel(FXObject*,FXSelector,void*);
61 public:
62 
63   /// Construct a menu command
64   FXMenuCommand(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0);
65 
66   /// Return default width
67   virtual FXint getDefaultWidth();
68 
69   /// Return default height
70   virtual FXint getDefaultHeight();
71 
72   /// Yes it can receive the focus
73   virtual bool canFocus() const;
74 
75   /// Move the focus to this window
76   virtual void setFocus();
77 
78   /// Remove the focus from this window
79   virtual void killFocus();
80 
81   /// Set accelerator text
82   void setAccelText(const FXString& text);
83 
84   /// Return accelarator text
getAccelText()85   FXString getAccelText() const { return accel; }
86 
87   /// Save menu to a stream
88   virtual void save(FXStream& store) const;
89 
90   /// Load menu from a stream
91   virtual void load(FXStream& store);
92 
93   /// Destructor
94   virtual ~FXMenuCommand();
95   };
96 
97 }
98 
99 #endif
100