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

FXMenuButton.h
1 /********************************************************************************
2 * *
3 * M e n u B u t t o n W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2024 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 FXMENUBUTTON_H
22 #define FXMENUBUTTON_H
23 
24 #ifndef FXLABEL_H
25 #include "FXLabel.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 class FXPopup;
32 
33 
34 // Menu button options
35 enum {
36  MENUBUTTON_AUTOGRAY = 0x00800000,
37  MENUBUTTON_AUTOHIDE = 0x01000000,
38  MENUBUTTON_TOOLBAR = 0x02000000,
39  MENUBUTTON_DOWN = 0,
40  MENUBUTTON_UP = 0x04000000,
41  MENUBUTTON_LEFT = 0x08000000,
42  MENUBUTTON_RIGHT = MENUBUTTON_LEFT|MENUBUTTON_UP,
43  MENUBUTTON_NOARROWS = 0x10000000,
44  MENUBUTTON_ATTACH_LEFT = 0,
45  MENUBUTTON_ATTACH_TOP = MENUBUTTON_ATTACH_LEFT,
46  MENUBUTTON_ATTACH_RIGHT = 0x20000000,
47  MENUBUTTON_ATTACH_BOTTOM = MENUBUTTON_ATTACH_RIGHT,
48  MENUBUTTON_ATTACH_CENTER = 0x40000000,
49  MENUBUTTON_ATTACH_BOTH = MENUBUTTON_ATTACH_CENTER|MENUBUTTON_ATTACH_RIGHT
50  };
51 
52 
53 
69 class FXAPI FXMenuButton : public FXLabel {
70  FXDECLARE(FXMenuButton)
71 protected:
72  FXPopup *pane; // Pane to pop up
73  FXint offsetx; // Shift attachment point x
74  FXint offsety; // Shift attachment point y
75  FXbool state; // Pane was popped
76 protected:
77  FXMenuButton();
78 private:
79  FXMenuButton(const FXMenuButton&);
80  FXMenuButton &operator=(const FXMenuButton&);
81 public:
82  long onPaint(FXObject*,FXSelector,void*);
83  long onUpdate(FXObject*,FXSelector,void*);
84  long onEnter(FXObject*,FXSelector,void*);
85  long onLeave(FXObject*,FXSelector,void*);
86  long onFocusIn(FXObject*,FXSelector,void*);
87  long onFocusOut(FXObject*,FXSelector,void*);
88  long onUngrabbed(FXObject*,FXSelector,void*);
89  long onMotion(FXObject*,FXSelector,void*);
90  long onButtonPress(FXObject*,FXSelector,void*);
91  long onButtonRelease(FXObject*,FXSelector,void*);
92  long onKeyPress(FXObject*,FXSelector,void*);
93  long onKeyRelease(FXObject*,FXSelector,void*);
94  long onHotKeyPress(FXObject*,FXSelector,void*);
95  long onHotKeyRelease(FXObject*,FXSelector,void*);
96  long onCmdPost(FXObject*,FXSelector,void*);
97  long onCmdUnpost(FXObject*,FXSelector,void*);
98 public:
99 
101  FXMenuButton(FXComposite* p,const FXString& text,FXIcon* ic=nullptr,FXPopup* pup=nullptr,FXuint opts=JUSTIFY_NORMAL|ICON_BEFORE_TEXT|MENUBUTTON_DOWN,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
102 
104  virtual void create();
105 
107  virtual void detach();
108 
110  virtual FXint getDefaultWidth();
111 
113  virtual FXint getDefaultHeight();
114 
116  virtual FXbool canFocus() const;
117 
119  virtual void killFocus();
120 
122  virtual FXbool contains(FXint parentx,FXint parenty) const;
123 
125  void setMenu(FXPopup *pup);
126 
128  FXPopup* getMenu() const { return pane; }
129 
131  void showMenu(FXbool shw);
132 
134  FXbool isMenuShown() const;
135 
137  void setXOffset(FXint offx){ offsetx=offx; }
138 
140  FXint getXOffset() const { return offsetx; }
141 
143  void setYOffset(FXint offy){ offsety=offy; }
144 
146  FXint getYOffset() const { return offsety; }
147 
149  void setButtonStyle(FXuint style);
150 
152  FXuint getButtonStyle() const;
153 
155  void setPopupStyle(FXuint style);
156 
158  FXuint getPopupStyle() const;
159 
161  void setAttachment(FXuint att);
162 
164  FXuint getAttachment() const;
165 
167  virtual void save(FXStream& store) const;
168 
170  virtual void load(FXStream& store);
171 
173  virtual ~FXMenuButton();
174  };
175 
176 }
177 
178 #endif
A menu button posts a popup menu when clicked.
Definition: FXMenuButton.h:69
A label widget can be used to place a text and/or icon for explanation purposes.
Definition: FXLabel.h:64
FXint getXOffset() const
Return current X offset.
Definition: FXMenuButton.h:140
Popup window is used as a container for transitional controls such as menu panes and other ephemeral ...
Definition: FXPopup.h:51
Base composite.
Definition: FXComposite.h:32
void setXOffset(FXint offx)
Set X offset where menu pops up relative to button.
Definition: FXMenuButton.h:137
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
Definition: FX4Splitter.h:28
FXint getYOffset() const
Return current Y offset.
Definition: FXMenuButton.h:146
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
void setYOffset(FXint offy)
Set Y offset where menu pops up relative to button.
Definition: FXMenuButton.h:143
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
FXPopup * getMenu() const
Return current popup menu.
Definition: FXMenuButton.h:128
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp