LMMS
Loading...
Searching...
No Matches
swell-dlggen.h
Go to the documentation of this file.
1/* Cockos SWELL (Simple/Small Win32 Emulation Layer for Linux/OSX)
2 Copyright (C) 2006 and later, Cockos, Inc.
3
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.
7
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:
11
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.
19
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):
21
22
23 #ifdef MAC
24
25
26 SWELL_DEFINE_DIALOG_RESOURCE_BEGIN(IDD_SOMEDIALOG,0,"Dialog Box Title",222,55,1.8) // width, height, scale (1.8 is usually good)
27
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
37
38 SWELL_DEFINE_DIALOG_RESOURCE_END(IDD_SOMEDIALOG)
39
40
41 #endif
42
43
44 This file also provides functions to dynamically create controls in a view from a win32 resource script.
45
46
47
48*/
49
50
51
52
53#ifndef _SWELL_DLGGEN_H_
54#define _SWELL_DLGGEN_H_
55
56#ifdef BEGIN
57#undef BEGIN
58#endif
59
60#ifdef END
61#undef END
62#endif
63
64
66{
67 const char *str1;
68 int flag1;
69 const char *str2;
70
71 int p1; // often used for ID
72
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
76};
77
78
79#define BEGIN {NULL,
80#define END },
81
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, "",
93#define ICON }, { "__SWELL_ICON", 0, (const char*)(INT_PTR)
94
95#define NOT
96
97// flags we may use
98#define CBS_DROPDOWNLIST 0x0003L
99#define CBS_DROPDOWN 0x0002L
100#define CBS_SORT 0x0100L
101#define ES_PASSWORD 0x0020L
102#define ES_READONLY 0x0800L
103#define ES_WANTRETURN 0x1000L
104#define ES_NUMBER 0x2000L
105
106#define SS_LEFT 0
107#define SS_CENTER 0x1L
108#define SS_RIGHT 0x2L
109#define SS_BLACKRECT 0x4L
110#define SS_BLACKFRAME (SS_BLACKRECT)
111#define SS_LEFTNOWORDWRAP 0xCL
112#define SS_ETCHEDHORZ 0x10L
113#define SS_ETCHEDVERT 0x11L
114#define SS_ETCHEDFRAME 0x12L
115#define SS_TYPEMASK 0x1FL
116#define SS_NOTIFY 0x0100L
117
118#define BS_LEFTTEXT 0x0020L
119
120#define BS_LEFT 0x100L
121#define BS_CENTER 0x300L
122#define BS_XPOSITION_MASK BS_CENTER
123
124#define BS_GROUPBOX 0x20000000
125#define BS_DEFPUSHBUTTON 0x10000000
126#define BS_PUSHBUTTON 0x8000000
127
128#define LVS_LIST 0 /* 0x0003 */
129#define LVS_NOCOLUMNHEADER 0x4000
130#define LVS_NOSORTHEADER 0x8000
131#define LVS_REPORT 0x0001
132#define LVS_TYPEMASK 0x0003
133#define LVS_SINGLESEL 0x0004
134#define LVS_OWNERDATA 0x1000
135#define LVS_SORTASCENDING 0x0010
136#define LVS_SORTDESCENDING 0x0020
137
138#define LBS_SORT 0x0002L
139#define LBS_OWNERDRAWFIXED 0x0010L
140#define LBS_EXTENDEDSEL 0x0800L
141
142#define ES_LEFT 0
143#define ES_CENTER 1
144#define ES_RIGHT 2
145#define ES_MULTILINE 4
146#define ES_AUTOHSCROLL 0x80
147
148// flags we ignore
149#define LVS_SHOWSELALWAYS 0
150#define LVS_SHAREIMAGELISTS 0
151#define ES_AUTOVSCROLL 0
152#define GROUP 0
153#define PBS_SMOOTH 0
154#define CBS_AUTOHSCROLL 0
155#define TBS_NOTICKS 0
156#define TBS_TOP 0
157#define TBS_BOTH 0
158#define LBS_NOINTEGRALHEIGHT 0
159#define TVS_HASLINES 0
160#define TVS_LINESATROOT 0
161#define TVS_SHOWSELALWAYS 0
162#define TVS_HASBUTTONS 0
163#define TVS_TRACKSELECT 0
164#define TVS_NONEVENHEIGHT 0
165#define TVS_NOTOOLTIPS 0
166#define BS_FLAT 0
167#define SS_SUNKEN 0
168#define BS_RIGHT 0
169#define WS_EX_STATICEDGE 0
170#define WS_EX_RIGHT 0
171#define SS_CENTERIMAGE 0
172#define SS_NOPREFIX 0
173#define WS_CLIPCHILDREN 0
174
175// more ignore flags for vc11+
176#define LVS_ALIGNLEFT 0 /* 0x0800 */
177
178#ifndef IDC_STATIC
179#define IDC_STATIC 0
180#endif
181
182
183
184
185#define SWELL_DLG_WS_CHILD 1
186#define SWELL_DLG_WS_RESIZABLE 2
187#define SWELL_DLG_WS_FLIPPED 4
188#define SWELL_DLG_WS_NOAUTOSIZE 8
189#define SWELL_DLG_WS_OPAQUE 16
190#define SWELL_DLG_WS_DROPTARGET 32
191
201
210
211
213 public:
215 SWELL_DialogRegHelper(SWELL_DialogResourceIndex **h, void (*cf)(HWND,int), int recid, int flags, const char *titlestr, int wid, int hei, double scale)
216 {
217 if (recid)
218 {
219 m_rec.resid=MAKEINTRESOURCE(recid);
220 m_rec.title=titlestr;
221 m_rec.windowTypeFlags=flags;
222 m_rec.createFunc=cf;
223 m_rec.width=(int)((wid)*(scale));
224 m_rec.height=(int)((hei)*(scale));
225 m_rec._next=*h;
226 *h = &m_rec;
227 }
228 }
229};
230
231#ifdef _DEBUG
232 #include "../assocarray.h"
233 class SWELL_DialogRegValidator
234 {
235 public:
236 SWELL_DialogRegValidator(const SWELL_DlgResourceEntry *recs, size_t recs_sz)
237 {
238 if (recs_sz>1)
239 {
240 // check for duplicate IDs
241 WDL_IntKeyedArray<bool> tmp;
242 for (size_t x = 0; x < recs_sz; x ++)
243 {
244 const SWELL_DlgResourceEntry *list = recs + x;
245 const int idx = strncmp(list->str1,"__SWELL_",8) ? list->flag1 : list->p1;
246 if (idx != 0 && idx != -1)
247 {
248 WDL_ASSERT(!tmp.Get(idx));
249 tmp.Insert(idx,true);
250 }
251 }
252 }
253 }
254 };
255 #define SWELL_VALIDATE_DIALOG_RESOURCE(v,r) static SWELL_DialogRegValidator v(r+1, sizeof(r)/sizeof(r[0])-1);
256#else
257 #define SWELL_VALIDATE_DIALOG_RESOURCE(v,r)
258#endif
259
260
261#define SWELL_DEFINE_DIALOG_RESOURCE_BEGIN(recid, flags, titlestr, wid, hei, scale) \
262 static void SWELL__dlg_cf__##recid(HWND view, int wflags); \
263 const float __swell_dlg_scale__##recid = (float) (scale); \
264 static SWELL_DialogRegHelper __swell_dlg_helper_##recid(&SWELL_curmodule_dialogresource_head, SWELL__dlg_cf__##recid, recid,flags,titlestr,wid,hei,scale); \
265 static const SWELL_DlgResourceEntry __swell_dlg_list__##recid[]={
266
267
268#define SWELL_DEFINE_DIALOG_RESOURCE_END(recid ) }; \
269 SWELL_VALIDATE_DIALOG_RESOURCE( __swell_dlg_validator__##recid, __swell_dlg_list__##recid) \
270 static void SWELL__dlg_cf__##recid(HWND view, int wflags) { \
271 SWELL_MakeSetCurParms(__swell_dlg_scale__##recid,__swell_dlg_scale__##recid,0,0,view,false,!(wflags&SWELL_DLG_WS_NOAUTOSIZE)); \
272 SWELL_GenerateDialogFromList(__swell_dlg_list__##recid+1,sizeof(__swell_dlg_list__##recid)/sizeof(__swell_dlg_list__##recid[0])-1); \
273 }
274
275#endif
SWELL_DialogRegHelper(SWELL_DialogResourceIndex **h, void(*cf)(HWND, int), int recid, int flags, const char *titlestr, int wid, int hei, double scale)
Definition swell-dlggen.h:215
SWELL_DialogResourceIndex m_rec
Definition swell-dlggen.h:214
VAL Get(KEY key, VAL notfound=0) const
Definition assocarray.h:328
int Insert(KEY key, VAL val)
Definition assocarray.h:53
unsigned x[BMAX+1]
Definition inflate.c:1586
@ list
Definition juce_AccessibilityRole.h:56
Definition swell-types.h:218
Definition swell-dlggen.h:203
POINT hotspot
Definition swell-dlggen.h:206
const char * resname
Definition swell-dlggen.h:205
const char * resid
Definition swell-dlggen.h:204
HCURSOR cachedCursor
Definition swell-dlggen.h:207
struct SWELL_CursorResourceIndex * _next
Definition swell-dlggen.h:208
Definition swell-dlggen.h:193
int height
Definition swell-dlggen.h:198
const char * resid
Definition swell-dlggen.h:194
struct SWELL_DialogResourceIndex * _next
Definition swell-dlggen.h:199
int windowTypeFlags
Definition swell-dlggen.h:196
const char * title
Definition swell-dlggen.h:195
void(* createFunc)(HWND, int)
Definition swell-dlggen.h:197
int width
Definition swell-dlggen.h:198
Definition swell-dlggen.h:66
int p4
Definition swell-dlggen.h:75
int flag1
Definition swell-dlggen.h:68
int p6
Definition swell-dlggen.h:75
const char * str2
Definition swell-dlggen.h:69
int p5
Definition swell-dlggen.h:75
int p1
Definition swell-dlggen.h:71
int p3
Definition swell-dlggen.h:75
int p2
Definition swell-dlggen.h:75
const char * str1
Definition swell-dlggen.h:67
void DWORD DWORD LPVOID DWORD cf
Definition swell-functions.h:807
struct HCURSOR__ * HCURSOR
Definition swell-types.h:264
struct HWND__ * HWND
Definition swell-types.h:210
#define MAKEINTRESOURCE(x)
Definition swell-types.h:1157
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
typedef int(UZ_EXP MsgFn)()
#define void
Definition unzip.h:396
#define WDL_ASSERT(x)
Definition wdltypes.h:164