Mercurial > dwindows
annotate winmain.c @ 2131:fc29c4c2d386
Mac: Changes for supporting Big Sur. These changes don't actually work.
The Xcode beta SDK is listed as 10.16, although it has been reported that
Big Sur will be 11.0 not 10.16. The 10.16 SDK does not include constants
for either 10.16 or 11.0 so I am writing the code as if it will be 11.0.
The 10.16 SDK complains that NSBox's setBorderType is deprecated and it
seems like the styles don't apply to the box type I am using anyway,
so might want to just remove the setBorderType from NSBox and see if
it still works on other versions of MacOS, but committing for now so
I have this record of it.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 30 Jun 2020 20:10:23 +0000 |
parents | aedf5903db0a |
children | 05dd5189099f |
rev | line source |
---|---|
3 | 1 /* Dynamic Windows stub file to allow Win32 applications |
2 * to use the main() entry point instead of WinMain(). | |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
3 * |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
4 * (C) 2000-2012 Brian Smith <brian@dbsoft.org> |
3 | 5 */ |
6 | |
7 #include <windows.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <stdio.h> | |
11 #include <process.h> | |
12 | |
49
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
13 #ifndef NODW |
3 | 14 void Win32_Set_Instance(HINSTANCE hInstance); |
49
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
15 #endif |
3 | 16 |
17 char **_convertargs(int *count, char *start, HINSTANCE DWInstance) | |
18 { | |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
19 char *tmp, *argstart, **argv; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
20 int loc = 0, inquotes = 0; |
3 | 21 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
22 (*count) = 1; |
3 | 23 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
24 tmp = start; |
3 | 25 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
26 /* Count the number of entries */ |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
27 if(*start) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
28 { |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
29 (*count)++; |
3 | 30 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
31 while(*tmp) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
32 { |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
33 if(*tmp == '"' && inquotes) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
34 inquotes = 0; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
35 else if(*tmp == '"' && !inquotes) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
36 inquotes = 1; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
37 else if(*tmp == ' ' && !inquotes) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
38 { |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
39 /* Push past any white space */ |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
40 while(*(tmp+1) == ' ') |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
41 tmp++; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
42 /* If we aren't at the end of the command |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
43 * line increment the count. |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
44 */ |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
45 if(*(tmp+1)) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
46 (*count)++; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
47 } |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
48 tmp++; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
49 } |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
50 } |
3 | 51 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
52 argv = (char **)malloc(sizeof(char *) * ((*count)+1)); |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
53 argv[0] = malloc(260); |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
54 GetModuleFileNameA(DWInstance, argv[0], 260); |
3 | 55 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
56 argstart = tmp = start; |
3 | 57 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
58 if(*start) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
59 { |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
60 loc = 1; |
3 | 61 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
62 while(*tmp) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
63 { |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
64 if(*tmp == '"' && inquotes) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
65 { |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
66 *tmp = 0; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
67 inquotes = 0; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
68 } |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
69 else if(*tmp == '"' && !inquotes) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
70 { |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
71 argstart = tmp+1; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
72 inquotes = 1; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
73 } |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
74 else if(*tmp == ' ' && !inquotes) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
75 { |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
76 *tmp = 0; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
77 argv[loc] = strdup(argstart); |
3 | 78 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
79 /* Push past any white space */ |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
80 while(*(tmp+1) == ' ') |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
81 tmp++; |
3 | 82 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
83 /* Move the start pointer */ |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
84 argstart = tmp+1; |
3 | 85 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
86 /* If we aren't at the end of the command |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
87 * line increment the count. |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
88 */ |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
89 if(*(tmp+1)) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
90 loc++; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
91 } |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
92 tmp++; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
93 } |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
94 if(*argstart) |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
95 argv[loc] = strdup(argstart); |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
96 } |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
97 argv[loc+1] = NULL; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
98 return argv; |
3 | 99 } |
100 | |
101 /* Ok this is a really big hack but what the hell ;) */ | |
102 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) | |
103 { | |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
104 char **argv; |
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
105 int argc; |
3 | 106 |
49
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
107 #ifndef NODW |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
108 Win32_Set_Instance(hInstance); |
49
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
109 #endif |
3 | 110 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
111 argv = _convertargs(&argc, lpCmdLine, hInstance); |
3 | 112 |
1802
aedf5903db0a
Add DW_FCF_TEXTURED window style; relevant only for Mac port.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1620
diff
changeset
|
113 return main(argc, argv); |
3 | 114 } |