X11workbench Toolkit  1.0
menu_popup.h
1 // _ //
3 // _ __ ___ ___ _ __ _ _ _ __ ___ _ __ _ _ _ __ | |__ //
4 // | '_ ` _ \ / _ \| '_ \ | | | | | '_ \ / _ \ | '_ \ | | | || '_ \ | '_ \ //
5 // | | | | | || __/| | | || |_| | | |_) || (_) || |_) || |_| || |_) |_| | | | //
6 // |_| |_| |_| \___||_| |_| \__,_|_____ | .__/ \___/ | .__/ \__,_|| .__/(_)_| |_| //
7 // |_____||_| |_| |_| //
8 // //
9 // generic popup menu implementation //
10 // //
12 
13 /*****************************************************************************
14 
15  X11workbench - X11 programmer's 'work bench' application and toolkit
16  Copyright (c) 2010-2018 by Bob Frazier (aka 'Big Bad Bombastic Bob')
17  all rights reserved
18 
19  DISCLAIMER: The X11workbench application and toolkit software are supplied
20  'as-is', with no warranties, either implied or explicit.
21  Any claims to alleged functionality or features should be
22  considered 'preliminary', and might not function as advertised.
23 
24  BSD-like license:
25 
26  There is no restriction as to what you can do with this software, so long
27  as you include the above copyright notice and DISCLAIMER for any distributed
28  work that is equal to or derived from this one, along with this paragraph
29  that explains the terms of the license if the source is also being made
30  available. A "derived work" describes a work that uses a significant portion
31  of the source files or algorithms that are included with this one.
32  Specifically excluded from this are files that were generated by the software,
33  or anything that is included with the software that is part of another package
34  (such as files that were created or added during the 'configure' process).
35  Specifically included is the use of part or all of any of the X11 workbench
36  toolkit source or header files in your distributed application. If you do not
37  ship the source, the above copyright statement is still required to be placed
38  in a reasonably prominent place, such as documentation, splash screens, and/or
39  'about the application' dialog boxes.
40 
41  Use and distribution are in accordance with GPL, LGPL, and/or the above
42  BSD-like license. See COPYING and README files for more information.
43 
44 
45  Additional information at http://sourceforge.net/projects/X11workbench
46 
47 ******************************************************************************/
48 
61 #ifndef MENU_POPUP_H_INCLUDED
62 #define MENU_POPUP_H_INCLUDED
63 
64 #include "menu_bar.h"
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif // __cplusplus
69 
70 
71 #define MENU_POPUP_WINDOW_TAG (*((const unsigned int *)"MWMP"))
72 
108 typedef struct __WBMenuPopupWindow__
109 {
110  unsigned int ulTag;
111  Window wSelf;
112  Window wBar;
113  Window wOwner;
114 
116 
117  int iX;
118  int iY;
119  int iWidth;
120  int iHeight;
121 
122  int iColumns;
123  int iVisible;
124  int iTop;
125  int iSelected;
126  int iFlags;
127 
129 
130 
148 WBMenuPopupWindow *MBCreateMenuPopupWindow(Window wIDBar, Window wIDOwner, WBMenu *pMenu,
149  int iX, int iY, int iFlags);
150  // pass 'iX and 'iY' for the menu's origin location. 'pMenu' points to the popup menu and
151  // it must contain a list of popup menus that it makes use of.
152 
164 int MBMenuDoModal(WBMenuPopupWindow *pMenuPopupWindow);
165 
176 void MBDestroyMenuPopupWindow(WBMenuPopupWindow *pMenuPopupWindow);
177 
188 WBMenuPopupWindow *MBFindMenuPopupWindow(WBMenu *pSubMenu); // find first (active) window that uses sub-menu 'pMenu'
189 
190 
201 static __inline__ WBMenuPopupWindow *MBGetMenuPopupWindowStruct(Window wID)
202 {
203  WBMenuPopupWindow *pRval = (WBMenuPopupWindow *)WBGetWindowData(wID, 0); // offset 0 for window-specific structs
204 
205  if(pRval && pRval->ulTag == MENU_POPUP_WINDOW_TAG)
206  return(pRval);
207 
208  return(NULL);
209 }
210 
211 
212 #ifdef __cplusplus
213 };
214 #endif // __cplusplus
215 
216 
217 #endif // MENU_POPUP_H_INCLUDED
218 
structure for managing menu items
Definition: menu.h:185
int iX
popup menu 'X' position within the owner's client area
Definition: menu_popup.h:117
int iFlags
flags that determine behavior (reserved)
Definition: menu_popup.h:126
void * WBGetWindowData(Window wID, int iIndex)
Gets the data associated with this window and the specified index.
WBMenuPopupWindow * MBFindMenuPopupWindow(WBMenu *pSubMenu)
Find the first WBMenuPopupWindow that references a WBMenu.
Definition: menu_popup.c:457
structure for managing a popup menu window
Definition: menu_popup.h:108
int iWidth
popup menu width
Definition: menu_popup.h:119
int iVisible
total number of visible menu items (including separators)
Definition: menu_popup.h:123
int iHeight
popup menu height
Definition: menu_popup.h:120
int iTop
index of the 'top' visible menu item (zero-based) for scrolling menus
Definition: menu_popup.h:124
int iY
popup menu 'Y' position within the owner's client area
Definition: menu_popup.h:118
WBMenu * pMenu
a pointer to the associated WBMenu structure
Definition: menu_popup.h:115
void MBDestroyMenuPopupWindow(WBMenuPopupWindow *pMenuPopupWindow)
Destroy a WBMenuPopupWindow structure.
Definition: menu_popup.c:477
int iColumns
total number of columns (currently 1)
Definition: menu_popup.h:122
int MBMenuDoModal(WBMenuPopupWindow *pMenuPopupWindow)
display a Menu Popup window in a 'modal' loop
Definition: menu_popup.c:469
unsigned int ulTag
tag indicating I'm a 'Menu Popup' window
Definition: menu_popup.h:110
WBMenuPopupWindow * MBCreateMenuPopupWindow(Window wIDBar, Window wIDOwner, WBMenu *pMenu, int iX, int iY, int iFlags)
Create a WBMenuPopupWindow object and associated window.
Definition: menu_popup.c:199
int iSelected
currently selected menu (for display purposes)
Definition: menu_popup.h:125
Window wOwner
window ID for the owner window
Definition: menu_popup.h:113
Window wBar
window ID for the associated Menu Bar window
Definition: menu_popup.h:112
Window wSelf
window ID for the Menu Popup window
Definition: menu_popup.h:111
static __inline__ WBMenuPopupWindow * MBGetMenuPopupWindowStruct(Window wID)
Get the associated WBMenuPopupWindow structure from a Menu Popup window's window ID.
Definition: menu_popup.h:201