update plists MACOSX_DEPLOYMENT_TARGET = 10.7.0
[wdl/wdl-ol.git] / WDL / swell / swell-menugen.h
blobfba87c0b2ca29b63ee233d4df659ee7a7e23c96d
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
26 Usage:
28 See: mac_resgen.php etc
33 #include "swell.h"
36 #ifdef BEGIN
37 #undef BEGIN
38 #endif
40 #ifdef END
41 #undef END
42 #endif
45 typedef struct SWELL_MenuResourceIndex
47 const char *resid;
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
59 unsigned short idx;
60 unsigned short flags;
63 class SWELL_MenuGenHelper
65 public:
66 SWELL_MenuResourceIndex m_rec;
67 SWELL_MenuGenHelper(SWELL_MenuResourceIndex **h, void (*cf)(HMENU), int recid)
69 m_rec.resid=MAKEINTRESOURCE(recid);
70 m_rec.createFunc=cf;
71 m_rec._next=*h;
72 *h = &m_rec;
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); }
84 #define GRAYED 1
85 #define INACTIVE 2
86 #define POPUP }, { SWELL_MENUGEN_POPUP_PREFIX
87 #define MENUITEM }, {
88 #define SEPARATOR NULL, 0xffff
89 #define BEGIN
90 #define END }, { SWELL_MENUGEN_ENDPOPUP
92 #endif//_SWELL_MENUGEN_H_