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

FXMenuCommand.h

Go to the documentation of this file.
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,2006 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.30 2006/01/22 17:58:06 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 /**
00035 * The menu command widget is used to invoke a command in the
00036 * application from a menu.  Menu commands may reflect
00037 * the state of the application by graying out, or becoming hidden.
00038 * When activated, a menu command sends a SEL_COMMAND to its target.
00039 */
00040 class FXAPI FXMenuCommand : public FXMenuCaption {
00041   FXDECLARE(FXMenuCommand)
00042 protected:
00043   FXString     accel;       // Accelerator string
00044   FXHotKey     acckey;      // Accelerator key
00045 protected:
00046   FXMenuCommand();
00047 private:
00048   FXMenuCommand(const FXMenuCommand&);
00049   FXMenuCommand &operator=(const FXMenuCommand&);
00050 public:
00051   long onPaint(FXObject*,FXSelector,void*);
00052   long onEnter(FXObject*,FXSelector,void*);
00053   long onLeave(FXObject*,FXSelector,void*);
00054   long onButtonPress(FXObject*,FXSelector,void*);
00055   long onButtonRelease(FXObject*,FXSelector,void*);
00056   long onKeyPress(FXObject*,FXSelector,void*);
00057   long onKeyRelease(FXObject*,FXSelector,void*);
00058   long onHotKeyPress(FXObject*,FXSelector,void*);
00059   long onHotKeyRelease(FXObject*,FXSelector,void*);
00060   long onCmdAccel(FXObject*,FXSelector,void*);
00061 public:
00062 
00063   /// Construct a menu command
00064   FXMenuCommand(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0);
00065 
00066   /// Return default width
00067   virtual FXint getDefaultWidth();
00068 
00069   /// Return default height
00070   virtual FXint getDefaultHeight();
00071 
00072   /// Yes it can receive the focus
00073   virtual bool canFocus() const;
00074 
00075   /// Move the focus to this window
00076   virtual void setFocus();
00077 
00078   /// Remove the focus from this window
00079   virtual void killFocus();
00080 
00081   /// Set accelerator text
00082   void setAccelText(const FXString& text);
00083 
00084   /// Return accelarator text
00085   FXString getAccelText() const { return accel; }
00086 
00087   /// Save menu to a stream
00088   virtual void save(FXStream& store) const;
00089 
00090   /// Load menu from a stream
00091   virtual void load(FXStream& store);
00092 
00093   /// Destructor
00094   virtual ~FXMenuCommand();
00095   };
00096 
00097 }
00098 
00099 #endif

Copyright © 1997-2005 Jeroen van der Zijp