1 #ifndef _SWELL_MENUGEN_H_
2 #define _SWELL_MENUGEN_H_
5 /* Cockos SWELL (Simple/Small Win32 Emulation Layer for Linux/OSX)
6 Copyright (C) 2006 and later, Cockos, Inc.
8 This software is provided 'as-is', without any express or implied
9 warranty. In no event will the authors be held liable for any damages
10 arising from the use of this software.
12 Permission is granted to anyone to use this software for any purpose,
13 including commercial applications, and to alter it and redistribute it
14 freely, subject to the following restrictions:
16 1. The origin of this software must not be misrepresented; you must not
17 claim that you wrote the original software. If you use this software
18 in a product, an acknowledgment in the product documentation would be
19 appreciated but is not required.
20 2. Altered source versions must be plainly marked as such, and must not be
21 misrepresented as being the original software.
22 3. This notice may not be removed or altered from any source distribution.
24 Dynamic menu generation
28 See: mac_resgen.php etc
45 typedef struct SWELL_MenuResourceIndex
48 void (*createFunc
)(HMENU hMenu
);
49 struct SWELL_MenuResourceIndex
*_next
;
50 } SWELL_MenuResourceIndex
;
51 extern SWELL_MenuResourceIndex
*SWELL_curmodule_menuresource_head
;
54 #define SWELL_MENUGEN_POPUP_PREFIX "/.BO^O:"
55 #define SWELL_MENUGEN_ENDPOPUP "EN%%%^:"
56 struct SWELL_MenuGen_Entry
58 const char *name
; // will begin with SWELL_MENUGEN_POPUP_PREFIX on submenus, and will be SWELL_MENUGEN_ENDPOPUP at the end of a submenu
63 class SWELL_MenuGenHelper
66 SWELL_MenuResourceIndex m_rec
;
67 SWELL_MenuGenHelper(SWELL_MenuResourceIndex
**h
, void (*cf
)(HMENU
), int recid
)
69 m_rec
.resid
=MAKEINTRESOURCE(recid
);
76 #define SWELL_DEFINE_MENU_RESOURCE_BEGIN(recid) \
77 static void __swell_menu_cf__##recid(HMENU hMenu); \
78 static SWELL_MenuGenHelper __swell_menu_cf_helper__##recid(&SWELL_curmodule_menuresource_head, __swell_menu_cf__##recid, recid); \
79 static void __swell_menu_cf__##recid(HMENU hMenu) { static const SWELL_MenuGen_Entry list[]={{NULL,0,0
81 #define SWELL_DEFINE_MENU_RESOURCE_END(recid) } }; SWELL_GenerateMenuFromList(hMenu,list+1,sizeof(list)/sizeof(list[0])-1); }
86 #define POPUP }, { SWELL_MENUGEN_POPUP_PREFIX
88 #define SEPARATOR NULL, 0xffff
90 #define END }, { SWELL_MENUGEN_ENDPOPUP
92 #endif//_SWELL_MENUGEN_H_