Merge pull request #113 from tesselode/fix-multi-targets
[wdl/wdl-ol.git] / WDL / swell / swell-dlggen.h
blob301777d19e665af5cb6de0c3fcab93234dc95c89
1 /* Cockos SWELL (Simple/Small Win32 Emulation Layer for Linux/OSX)
2 Copyright (C) 2006 and later, Cockos, Inc.
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
20 DialogBox emulation is here. To declare the resource at a global level, use (in any source file that includes this file and resource.h):
23 #ifdef MAC
26 SWELL_DEFINE_DIALOG_RESOURCE_BEGIN(IDD_SOMEDIALOG,0,"Dialog Box Title",222,55,1.8) // width, height, scale (1.8 is usually good)
28 BEGIN
29 DEFPUSHBUTTON "OK",IDOK,117,33,47,14
30 CONTROL "Expand MIDI tracks to new REAPER tracks ",IDC_CHECK1,
31 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,7,214,10
32 CONTROL "Merge MIDI tempo map to project tempo map at ",
33 IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,19,
34 214,10
35 PUSHBUTTON "Cancel",IDCANCEL,168,33,50,14
36 END
38 SWELL_DEFINE_DIALOG_RESOURCE_END(IDD_SOMEDIALOG)
41 #endif
44 This file also provides functions to dynamically create controls in a view from a win32 resource script.
53 #ifndef _SWELL_DLGGEN_H_
54 #define _SWELL_DLGGEN_H_
56 #ifdef BEGIN
57 #undef BEGIN
58 #endif
60 #ifdef END
61 #undef END
62 #endif
65 struct SWELL_DlgResourceEntry
67 const char *str1;
68 int flag1;
69 const char *str2;
71 int p1; // often used for ID
73 // todo: see at runtime if some of these can be short instead of int (p2-p6 probably can, but not completely sure) -- i.e. do we use any
74 // big values in flags. note: it can't be unsigned short, because we want negative values.
75 int p2, p3, p4, p5, p6; // meaning is dependent on class
79 #define BEGIN {NULL,
80 #define END },
82 #define PUSHBUTTON }, { "__SWELL_BUTTON", 0,
83 #define DEFPUSHBUTTON }, { "__SWELL_BUTTON", 1,
84 #define EDITTEXT }, { "__SWELL_EDIT", 0, "",
85 #define CTEXT }, { "__SWELL_LABEL", 0,
86 #define LTEXT }, { "__SWELL_LABEL", -1,
87 #define RTEXT }, { "__SWELL_LABEL", 1,
88 #define CONTROL }, {
89 #define COMBOBOX }, { "__SWELL_COMBO", 0, "",
90 #define GROUPBOX }, { "__SWELL_GROUP", 0,
91 #define CHECKBOX }, { "__SWELL_CHECKBOX", 0,
92 #define LISTBOX }, { "__SWELL_LISTBOX", 0, "",
94 #define NOT
96 // flags we may use
97 #define CBS_DROPDOWNLIST 0x0003L
98 #define CBS_DROPDOWN 0x0002L
99 #define CBS_SORT 0x0100L
100 #define ES_PASSWORD 0x0020L
101 #define ES_READONLY 0x0800L
102 #define ES_WANTRETURN 0x1000L
103 #define ES_NUMBER 0x2000L
105 #define SS_LEFT 0
106 #define SS_CENTER 0x1L
107 #define SS_RIGHT 0x2L
108 #define SS_BLACKRECT 0x4L
109 #define SS_BLACKFRAME (SS_BLACKRECT)
110 #define SS_LEFTNOWORDWRAP 0xCL
111 #define SS_TYPEMASK 0x1FL
112 #define SS_NOTIFY 0x0100L
114 #define BS_CENTER 0x0300L
115 #define BS_LEFTTEXT 0x0020L
116 #define BS_LEFT 0x100L
117 #define BS_GROUPBOX 0x20000000
118 #define BS_DEFPUSHBUTTON 0x10000000
119 #define BS_PUSHBUTTON 0x8000000
121 #define LVS_LIST 0 /* 0x0003 */
122 #define LVS_NOCOLUMNHEADER 0x4000
123 #define LVS_NOSORTHEADER 0x8000
124 #define LVS_REPORT 0x0001
125 #define LVS_TYPEMASK 0x0003
126 #define LVS_SINGLESEL 0x0004
127 #define LVS_OWNERDATA 0x1000
128 #define LVS_SORTASCENDING 0x0010
129 #define LVS_SORTDESCENDING 0x0020
131 #define LBS_SORT 0x0002L
132 #define LBS_OWNERDRAWFIXED 0x0010L
133 #define LBS_EXTENDEDSEL 0x0800L
135 #define ES_LEFT 0
136 #define ES_CENTER 1
137 #define ES_RIGHT 2
138 #define ES_MULTILINE 4
139 #define ES_AUTOHSCROLL 0x80
141 // flags we ignore
142 #define LVS_SHOWSELALWAYS 0
143 #define LVS_SHAREIMAGELISTS 0
144 #define ES_AUTOVSCROLL 0
145 #define GROUP 0
146 #define PBS_SMOOTH 0
147 #define CBS_AUTOHSCROLL 0
148 #define TBS_NOTICKS 0
149 #define TBS_TOP 0
150 #define TBS_BOTH 0
151 #define LBS_NOINTEGRALHEIGHT 0
152 #define TVS_HASLINES 0
153 #define TVS_LINESATROOT 0
154 #define TVS_SHOWSELALWAYS 0
155 #define TVS_HASBUTTONS 0
156 #define BS_FLAT 0
157 #define TVS_DISABLEDRAGDROP 0
158 #define TVS_TRACKSELECT 0
159 #define TVS_NONEVENHEIGHT 0
160 #define SS_SUNKEN 0
161 #define BS_RIGHT 0
162 #define WS_EX_STATICEDGE 0
163 #define WS_EX_RIGHT 0
164 #define SS_CENTERIMAGE 0
165 #define SS_NOPREFIX 0
168 #ifndef IDC_STATIC
169 #define IDC_STATIC 0
170 #endif
175 #define SWELL_DLG_WS_CHILD 1
176 #define SWELL_DLG_WS_RESIZABLE 2
177 #define SWELL_DLG_WS_FLIPPED 4
178 #define SWELL_DLG_WS_NOAUTOSIZE 8
179 #define SWELL_DLG_WS_OPAQUE 16
180 #define SWELL_DLG_WS_DROPTARGET 32
182 typedef struct SWELL_DialogResourceIndex
184 const char *resid;
185 const char *title;
186 int windowTypeFlags;
187 void (*createFunc)(HWND, int);
188 int width,height;
189 struct SWELL_DialogResourceIndex *_next;
190 } SWELL_DialogResourceIndex;
192 typedef struct SWELL_CursorResourceIndex
194 const char *resid;
195 const char *resname;
196 POINT hotspot;
197 HCURSOR cachedCursor;
198 struct SWELL_CursorResourceIndex *_next;
199 } SWELL_CursorResourceIndex;
203 static inline HWND __SWELL_MakeButton(int def, const char *label, int idx, int x, int y, int w, int h, int flags=0, int exstyle=0)
205 return SWELL_MakeButton(def,label,idx,x,y,w,h,flags);
207 static inline HWND __SWELL_MakeEditField(int idx, int x, int y, int w, int h, int flags=0)
209 return SWELL_MakeEditField(idx,x,y,w,h,flags);
211 static inline HWND __SWELL_MakeLabel(int align, const char *label, int idx, int x, int y, int w, int h, int flags=0, int exflags=0)
213 return SWELL_MakeLabel(align,label,idx,x,y,w,h,flags);
215 static inline HWND __SWELL_MakeCombo(int idx, int x, int y, int w, int h, int flags=0)
217 return SWELL_MakeCombo(idx,x,y,w,h,flags);
219 static inline HWND __SWELL_MakeListBox(int idx, int x, int y, int w, int h, int styles=0)
221 return SWELL_MakeListBox(idx,x,y,w,h,styles);
224 static inline HWND __SWELL_MakeControl(const char *cname, int idx, const char *classname, int style, int x, int y, int w, int h, int exstyle=0)
226 return SWELL_MakeControl(cname,idx,classname,style,x,y,w,h,exstyle);
229 static inline HWND __SWELL_MakeGroupBox(const char *name, int idx, int x, int y, int w, int h, int style=0)
231 return SWELL_MakeGroupBox(name,idx,x,y,w,h,style);
234 class SWELL_DialogRegHelper {
235 public:
236 SWELL_DialogResourceIndex m_rec;
237 SWELL_DialogRegHelper(SWELL_DialogResourceIndex **h, void (*cf)(HWND,int), int recid, int flags, const char *titlestr, int wid, int hei, double scale)
239 if (recid)
241 m_rec.resid=MAKEINTRESOURCE(recid);
242 m_rec.title=titlestr;
243 m_rec.windowTypeFlags=flags;
244 m_rec.createFunc=cf;
245 m_rec.width=(int)((wid)*(scale));
246 m_rec.height=(int)((hei)*(scale));
247 m_rec._next=*h;
248 *h = &m_rec;
253 #define SWELL_DEFINE_DIALOG_RESOURCE_BEGIN(recid, flags, titlestr, wid, hei, scale) \
254 static void SWELL__dlg_cf__##recid(HWND view, int wflags); \
255 static SWELL_DialogRegHelper __swell_dlg_helper_##recid(&SWELL_curmodule_dialogresource_head, SWELL__dlg_cf__##recid, recid,flags,titlestr,wid,hei,scale); \
256 void SWELL__dlg_cf__##recid(HWND view, int wflags) { \
257 SWELL_MakeSetCurParms(scale,scale,0,0,view,false,!(wflags&SWELL_DLG_WS_NOAUTOSIZE)); \
258 static const SWELL_DlgResourceEntry list[]={
261 #define SWELL_DEFINE_DIALOG_RESOURCE_END(recid ) }; SWELL_GenerateDialogFromList(list+1,sizeof(list)/sizeof(list[0])-1); }
265 #endif