1 /********************************************************************************
2 *                                                                               *
3 *                         M e n u C a p t i o n   W i d g e t                   *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 1997,2005 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: FXMenuCaption.h,v 1.30 2005/01/16 16:06:06 fox Exp $                     *
23 ********************************************************************************/
24 #ifndef FXMENUCAPTION_H
25 #define FXMENUCAPTION_H
26 
27 #ifndef FXWINDOW_H
28 #include "FXWindow.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Menu Caption options
35 enum {
36   MENU_AUTOGRAY = 0x00008000,   /// Automatically gray out when not updated
37   MENU_AUTOHIDE = 0x00010000    /// Automatically hide button when not updated
38   };
39 
40 
41 class FXIcon;
42 class FXFont;
43 
44 
45 /**
46 * The menu caption is a widget which can be used as a caption
47 * above a number of menu commands in a menu.
48 */
49 class FXAPI FXMenuCaption : public FXWindow {
50   FXDECLARE(FXMenuCaption)
51 protected:
52   FXString     label;
53   FXString     help;
54   FXIcon      *icon;
55   FXFont      *font;
56   FXint        hotoff;
57   FXHotKey     hotkey;
58   FXColor      textColor;
59   FXColor      selbackColor;
60   FXColor      seltextColor;
61   FXColor      hiliteColor;
62   FXColor      shadowColor;
63 protected:
64   FXMenuCaption();
65 private:
66   FXMenuCaption(const FXMenuCaption&);
67   FXMenuCaption &operator=(const FXMenuCaption&);
68 public:
69   long onPaint(FXObject*,FXSelector,void*);
70   long onUpdate(FXObject*,FXSelector,void*);
71   long onCmdGetStringValue(FXObject*,FXSelector,void*);
72   long onCmdSetStringValue(FXObject*,FXSelector,void*);
73   long onCmdSetIconValue(FXObject*,FXSelector,void*);
74   long onCmdGetIconValue(FXObject*,FXSelector,void*);
75   long onCmdSetHelp(FXObject*,FXSelector,void*);
76   long onCmdGetHelp(FXObject*,FXSelector,void*);
77   long onQueryHelp(FXObject*,FXSelector,void*);
78 public:
79 
80   /// Construct a menu caption
81   FXMenuCaption(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXuint opts=0);
82 
83   /// Create server-side resources
84   virtual void create();
85 
86   /// Detach server-side resources
87   virtual void detach();
88 
89   /// Enable the menu
90   virtual void enable();
91 
92   /// Disable the menu
93   virtual void disable();
94 
95   /// Return default width
96   virtual FXint getDefaultWidth();
97 
98   /// Return default height
99   virtual FXint getDefaultHeight();
100 
101   /// Set the text for this menu
102   void setText(const FXString& text);
103 
104   /// Get the text for this menu
getText()105   FXString getText() const { return label; }
106 
107   /// Set the icon for this menu
108   void setIcon(FXIcon* ic);
109 
110   /// Get the icon for this menu
getIcon()111   FXIcon* getIcon() const { return icon; }
112 
113   /// Set the text font
114   void setFont(FXFont* fnt);
115 
116   /// Return the text font
getFont()117   FXFont* getFont() const { return font; }
118 
119   /// Set menu caption style
120   void setMenuStyle(FXuint style);
121 
122   /// Get menu caption style
123   FXuint getMenuStyle() const;
124 
125   /// Get the current text color
getTextColor()126   FXColor getTextColor() const { return textColor; }
127 
128   /// Return the current text color
129   void setTextColor(FXColor clr);
130 
131   /// Return the selection background color
getSelBackColor()132   FXColor getSelBackColor() const { return selbackColor; }
133 
134   /// Return the selection background color
135   void setSelBackColor(FXColor clr);
136 
137   /// Return the selection text color
getSelTextColor()138   FXColor getSelTextColor() const { return seltextColor; }
139 
140   /// Return the selection text color
141   void setSelTextColor(FXColor clr);
142 
143   /// Change highlight color
144   void setHiliteColor(FXColor clr);
145 
146   /// Get highlight color
getHiliteColor()147   FXColor getHiliteColor() const { return hiliteColor; }
148 
149   /// Change shadow color
150   void setShadowColor(FXColor clr);
151 
152   /// Get shadow color
getShadowColor()153   FXColor getShadowColor() const { return shadowColor; }
154 
155   /// Set the status line help text for this menu
156   void setHelpText(const FXString& text);
157 
158   /// Get the status line help text for this menu
getHelpText()159   const FXString& getHelpText() const { return help; }
160 
161   /// Save menu to a stream
162   virtual void save(FXStream& store) const;
163 
164   /// Load menu from a stream
165   virtual void load(FXStream& store);
166 
167   /// Destructor
168   virtual ~FXMenuCaption();
169   };
170 
171 }
172 
173 #endif
174