Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXMenuCommand.h
Go to the documentation of this file.
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 */
42 protected:
43  FXString accel; // Accelerator string
44  FXHotKey acckey; // Accelerator key
45 protected:
46  FXMenuCommand();
47 private:
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
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
unsigned int FXuint
Definition: fxdefs.h:396
FXuint FXHotKey
Definition: fxdefs.h:457
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
The menu caption is a widget which can be used as a caption above a number of menu commands in a menu...
Definition: FXMenuCaption.h:56
The menu command widget is used to invoke a command in the application from a menu.
Definition: FXMenuCommand.h:40
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp