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

FXMenuCommand.h

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,2004 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.26 2004/02/08 17:17:33 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 */
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-2004 Jeroen van der Zijp