1 /********************************************************************************
2 *                                                                               *
3 *                      M e n u   T i t l e   W i d g e t                        *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 1997,2021 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify          *
9 * it under the terms of the GNU Lesser General Public License as published by   *
10 * the Free Software Foundation; either version 3 of the License, or             *
11 * (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                 *
16 * GNU Lesser General Public License for more details.                           *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public License      *
19 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
20 ********************************************************************************/
21 #ifndef FXMENUTITLE_H
22 #define FXMENUTITLE_H
23 
24 #ifndef FXMENUCAPTION_H
25 #include "FXMenuCaption.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 class FXPopup;
32 
33 
34 /**
35 * A menu title is a child of a menu bar which is responsible
36 * for popping up a pulldown menu.
37 */
38 class FXAPI FXMenuTitle : public FXMenuCaption {
FXDECLARE(FXMenuTitle)39   FXDECLARE(FXMenuTitle)
40 protected:
41   FXPopup *pane;        // Pane to pop up
42 protected:
43   FXMenuTitle(){}
44 private:
45   FXMenuTitle(const FXMenuTitle&);
46   FXMenuTitle &operator=(const FXMenuTitle&);
47 public:
48   long onPaint(FXObject*,FXSelector,void*);
49   long onEnter(FXObject*,FXSelector,void*);
50   long onLeave(FXObject*,FXSelector,void*);
51   long onLeftBtnPress(FXObject*,FXSelector,void*);
52   long onLeftBtnRelease(FXObject*,FXSelector,void*);
53   long onKeyPress(FXObject*,FXSelector,void*);
54   long onKeyRelease(FXObject*,FXSelector,void*);
55   long onHotKeyPress(FXObject*,FXSelector,void*);
56   long onHotKeyRelease(FXObject*,FXSelector,void*);
57   long onFocusUp(FXObject*,FXSelector,void*);
58   long onFocusDown(FXObject*,FXSelector,void*);
59   long onFocusIn(FXObject*,FXSelector,void*);
60   long onFocusOut(FXObject*,FXSelector,void*);
61   long onCmdPost(FXObject*,FXSelector,void*);
62   long onCmdUnpost(FXObject*,FXSelector,void*);
63 public:
64 
65   /// Constructor
66   FXMenuTitle(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXPopup* pup=NULL,FXuint opts=0);
67 
68   /// Create server-side resources
69   virtual void create();
70 
71   /// Detach server-side resources
72   virtual void detach();
73 
74   /// Return default width
75   virtual FXint getDefaultWidth();
76 
77   /// Return default height
78   virtual FXint getDefaultHeight();
79 
80   /// Yes it can receive the focus
81   virtual FXbool canFocus() const;
82 
83   /// Move the focus to this window
84   virtual void setFocus();
85 
86   /// Remove the focus from this window
87   virtual void killFocus();
88 
89   /// Set popup menu to pop up
90   void setMenu(FXPopup *menu);
91 
92   /// Return popup menu
getMenu()93   FXPopup* getMenu() const { return pane; }
94 
95   /// True if this menu or is popup logically contains the mouse
96   virtual FXbool contains(FXint parentx,FXint parenty) const;
97 
98   /// Save menu to a stream
99   virtual void save(FXStream& store) const;
100 
101   /// Load menu from a stream
102   virtual void load(FXStream& store);
103 
104   /// Destructor
105   virtual ~FXMenuTitle();
106   };
107 
108 }
109 
110 #endif
111