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,2008 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.34 2008/01/04 15:18:22 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 */
00039 class FXAPI FXMenuCommand : public FXMenuCaption {
00040   FXDECLARE(FXMenuCommand)
00041 protected:
00042   FXString     accel;       // Accelerator string
00043   FXHotKey     acckey;      // Accelerator key
00044 protected:
00045   FXMenuCommand();
00046 private:
00047   FXMenuCommand(const FXMenuCommand&);
00048   FXMenuCommand &operator=(const FXMenuCommand&);
00049 public:
00050   long onPaint(FXObject*,FXSelector,void*);
00051   long onEnter(FXObject*,FXSelector,void*);
00052   long onLeave(FXObject*,FXSelector,void*);
00053   long onButtonPress(FXObject*,FXSelector,void*);
00054   long onButtonRelease(FXObject*,FXSelector,void*);
00055   long onKeyPress(FXObject*,FXSelector,void*);
00056   long onKeyRelease(FXObject*,FXSelector,void*);
00057   long onHotKeyPress(FXObject*,FXSelector,void*);
00058   long onHotKeyRelease(FXObject*,FXSelector,void*);
00059   long onCmdAccel(FXObject*,FXSelector,void*);
00060 public:
00061 
00062   /// Construct a menu command
00063   FXMenuCommand(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0);
00064 
00065   /// Return default width
00066   virtual FXint getDefaultWidth();
00067 
00068   /// Return default height
00069   virtual FXint getDefaultHeight();
00070 
00071   /// Yes it can receive the focus
00072   virtual FXbool canFocus() const;
00073 
00074   /// Move the focus to this window
00075   virtual void setFocus();
00076 
00077   /// Remove the focus from this window
00078   virtual void killFocus();
00079 
00080   /// Set accelerator text
00081   void setAccelText(const FXString& text);
00082 
00083   /// Return accelarator text
00084   FXString getAccelText() const { return accel; }
00085 
00086   /// Save menu to a stream
00087   virtual void save(FXStream& store) const;
00088 
00089   /// Load menu from a stream
00090   virtual void load(FXStream& store);
00091 
00092   /// Destructor
00093   virtual ~FXMenuCommand();
00094   };
00095 
00096 }
00097 
00098 #endif

Copyright © 1997-2007 Jeroen van der Zijp