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

FXMenuCaption.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                         M e n u C a p t i o n   W i d g e t                   *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2009 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: FXMenuCaption.h,v 1.38 2009/01/19 22:51:50 fox Exp $                     *
00022 ********************************************************************************/
00023 #ifndef FXMENUCAPTION_H
00024 #define FXMENUCAPTION_H
00025 
00026 #ifndef FXWINDOW_H
00027 #include "FXWindow.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /// Menu Caption options
00034 enum {
00035   MENU_AUTOGRAY = 0x00008000,   /// Automatically gray out when not updated
00036   MENU_AUTOHIDE = 0x00010000    /// Automatically hide button when not updated
00037   };
00038 
00039 
00040 class FXIcon;
00041 class FXFont;
00042 
00043 
00044 /**
00045 * The menu caption is a widget which can be used as a caption above a number 
00046 * of menu commands in a menu.
00047 * When passing a tab-separated list of fields in the text parameter, the caption 
00048 * text is set to the first field, and the help string to the third field.
00049 * If the caption text contains an ampersand, the letter following it will be
00050 * underlined, and a suitable hotkey will be installed.  The actual ampersand
00051 * will be removed.
00052 * To display an ampersand in the caption, use two consecutive ampersands.
00053 */
00054 class FXAPI FXMenuCaption : public FXWindow {
00055   FXDECLARE(FXMenuCaption)
00056 protected:
00057   FXString     label;
00058   FXString     help;
00059   FXString     tip;
00060   FXIcon      *icon;
00061   FXFont      *font;
00062   FXint        hotoff;
00063   FXHotKey     hotkey;
00064   FXColor      textColor;
00065   FXColor      selbackColor;
00066   FXColor      seltextColor;
00067   FXColor      hiliteColor;
00068   FXColor      shadowColor;
00069 protected:
00070   FXMenuCaption();
00071 private:
00072   FXMenuCaption(const FXMenuCaption&);
00073   FXMenuCaption &operator=(const FXMenuCaption&);
00074 public:
00075   long onPaint(FXObject*,FXSelector,void*);
00076   long onUpdate(FXObject*,FXSelector,void*);
00077   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00078   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00079   long onCmdSetIconValue(FXObject*,FXSelector,void*);
00080   long onCmdGetIconValue(FXObject*,FXSelector,void*);
00081   long onCmdSetHelp(FXObject*,FXSelector,void*);
00082   long onCmdGetHelp(FXObject*,FXSelector,void*);
00083   long onCmdSetTip(FXObject*,FXSelector,void*);
00084   long onCmdGetTip(FXObject*,FXSelector,void*);
00085   long onQueryHelp(FXObject*,FXSelector,void*);
00086   long onQueryTip(FXObject*,FXSelector,void*);
00087 public:
00088 
00089   /// Construct a menu caption
00090   FXMenuCaption(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXuint opts=0);
00091 
00092   /// Create server-side resources
00093   virtual void create();
00094 
00095   /// Detach server-side resources
00096   virtual void detach();
00097 
00098   /// Enable the menu
00099   virtual void enable();
00100 
00101   /// Disable the menu
00102   virtual void disable();
00103 
00104   /// Return default width
00105   virtual FXint getDefaultWidth();
00106 
00107   /// Return default height
00108   virtual FXint getDefaultHeight();
00109 
00110   /// Set the text for this menu
00111   void setText(const FXString& text);
00112 
00113   /// Get the text for this menu
00114   FXString getText() const { return label; }
00115 
00116   /// Set the icon for this menu
00117   void setIcon(FXIcon* ic);
00118 
00119   /// Get the icon for this menu
00120   FXIcon* getIcon() const { return icon; }
00121 
00122   /// Set the text font
00123   void setFont(FXFont* fnt);
00124 
00125   /// Return the text font
00126   FXFont* getFont() const { return font; }
00127 
00128   /// Set menu caption style
00129   void setMenuStyle(FXuint style);
00130 
00131   /// Get menu caption style
00132   FXuint getMenuStyle() const;
00133 
00134   /// Return the current text color
00135   void setTextColor(FXColor clr);
00136 
00137   /// Get the current text color
00138   FXColor getTextColor() const { return textColor; }
00139 
00140   /// Return the selection background color
00141   void setSelBackColor(FXColor clr);
00142 
00143   /// Return the selection background color
00144   FXColor getSelBackColor() const { return selbackColor; }
00145 
00146   /// Return the selection text color
00147   void setSelTextColor(FXColor clr);
00148 
00149   /// Return the selection text color
00150   FXColor getSelTextColor() const { return seltextColor; }
00151 
00152   /// Change highlight color
00153   void setHiliteColor(FXColor clr);
00154 
00155   /// Get highlight color
00156   FXColor getHiliteColor() const { return hiliteColor; }
00157 
00158   /// Change shadow color
00159   void setShadowColor(FXColor clr);
00160 
00161   /// Get shadow color
00162   FXColor getShadowColor() const { return shadowColor; }
00163 
00164   /// Set the status line help text for this menu
00165   void setHelpText(const FXString& text);
00166 
00167   /// Get the status line help text for this menu
00168   const FXString& getHelpText() const { return help; }
00169 
00170   /// Set the tool tip message for this menu
00171   void setTipText(const FXString& text){ tip=text; }
00172 
00173   /// Get the tool tip message for this menu
00174   const FXString& getTipText() const { return tip; }
00175 
00176   /// Save menu to a stream
00177   virtual void save(FXStream& store) const;
00178 
00179   /// Load menu from a stream
00180   virtual void load(FXStream& store);
00181 
00182   /// Destructor
00183   virtual ~FXMenuCaption();
00184   };
00185 
00186 }
00187 
00188 #endif

Copyright © 1997-2009 Jeroen van der Zijp