annotate ios/dw.m @ 2459:ddc6d49d1110

iOS: Reorganize the code so retval doesn't get clobbered without the returns.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 14 Apr 2021 01:27:00 +0000
parents 689261c29745
children 79c7bf492bc1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 * Dynamic Windows:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3 * A GTK like implementation of the iOS GUI
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 *
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5 * (C) 2011-2021 Brian Smith <brian@dbsoft.org>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6 * (C) 2011-2018 Mark Hessling <mark@rexx.org>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7 *
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
8 * Requires 13.0 or later.
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9 * clang -g -o dwtest -D__IOS__ -I. dwtest.c ios/dw.m -framework UIKit -framework WebKit -framework Foundation -framework UserNotifications
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11 #import <Foundation/Foundation.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12 #import <UIKit/UIKit.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
13 #import <WebKit/WebKit.h>
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
14 #import <AudioToolbox/AudioToolbox.h>
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
15 #import <UserNotifications/UserNotifications.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
16 #include "dw.h"
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
17 #include <sys/utsname.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
18 #include <sys/socket.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
19 #include <sys/un.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
20 #include <sys/mman.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21 #include <sys/time.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
22 #include <sys/stat.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
23 #include <math.h>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
24
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
25 /* Macros to handle local auto-release pools */
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
26 #define DW_LOCAL_POOL_IN NSAutoreleasePool *localpool = nil; \
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
27 if(DWThread != (DWTID)-1 && pthread_self() != DWThread) \
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
28 localpool = [[NSAutoreleasePool alloc] init];
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
29 #define DW_LOCAL_POOL_OUT if(localpool) [localpool drain];
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
30
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
31 /* Macros to encapsulate running functions on the main thread */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
32 #define DW_FUNCTION_INIT
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33 #define DW_FUNCTION_DEFINITION(func, rettype, ...) void _##func(NSPointerArray *_args); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
34 rettype API func(__VA_ARGS__) { \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 DW_LOCAL_POOL_IN; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36 NSPointerArray *_args = [[NSPointerArray alloc] initWithOptions:NSPointerFunctionsOpaqueMemory]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 [_args addPointer:(void *)_##func];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38 #define DW_FUNCTION_ADD_PARAM1(param1) [_args addPointer:(void *)&param1];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39 #define DW_FUNCTION_ADD_PARAM2(param1, param2) [_args addPointer:(void *)&param1]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40 [_args addPointer:(void *)&param2];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
41 #define DW_FUNCTION_ADD_PARAM3(param1, param2, param3) [_args addPointer:(void *)&param1]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
42 [_args addPointer:(void *)&param2]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
43 [_args addPointer:(void *)&param3];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
44 #define DW_FUNCTION_ADD_PARAM4(param1, param2, param3, param4) [_args addPointer:(void *)&param1]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
45 [_args addPointer:(void *)&param2]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
46 [_args addPointer:(void *)&param3]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47 [_args addPointer:(void *)&param4];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 #define DW_FUNCTION_ADD_PARAM5(param1, param2, param3, param4, param5) [_args addPointer:(void *)&param1]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 [_args addPointer:(void *)&param2]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 [_args addPointer:(void *)&param3]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51 [_args addPointer:(void *)&param4]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52 [_args addPointer:(void *)&param5];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53 #define DW_FUNCTION_ADD_PARAM6(param1, param2, param3, param4, param5, param6) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
54 [_args addPointer:(void *)&param1]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
55 [_args addPointer:(void *)&param2]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
56 [_args addPointer:(void *)&param3]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57 [_args addPointer:(void *)&param4]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
58 [_args addPointer:(void *)&param5]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
59 [_args addPointer:(void *)&param6];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
60 #define DW_FUNCTION_ADD_PARAM7(param1, param2, param3, param4, param5, param6, param7) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
61 [_args addPointer:(void *)&param1]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
62 [_args addPointer:(void *)&param2]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
63 [_args addPointer:(void *)&param3]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
64 [_args addPointer:(void *)&param4]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
65 [_args addPointer:(void *)&param5]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
66 [_args addPointer:(void *)&param6]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
67 [_args addPointer:(void *)&param7];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
68 #define DW_FUNCTION_ADD_PARAM8(param1, param2, param3, param4, param5, param6, param7, param8) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
69 [_args addPointer:(void *)&param1]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
70 [_args addPointer:(void *)&param2]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
71 [_args addPointer:(void *)&param3]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
72 [_args addPointer:(void *)&param4]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
73 [_args addPointer:(void *)&param5]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
74 [_args addPointer:(void *)&param6]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
75 [_args addPointer:(void *)&param7]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
76 [_args addPointer:(void *)&param8];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
77 #define DW_FUNCTION_ADD_PARAM9(param1, param2, param3, param4, param5, param6, param7, param8, param9) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
78 [_args addPointer:(void *)&param1]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
79 [_args addPointer:(void *)&param2]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
80 [_args addPointer:(void *)&param3]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
81 [_args addPointer:(void *)&param4]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82 [_args addPointer:(void *)&param5]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
83 [_args addPointer:(void *)&param6]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
84 [_args addPointer:(void *)&param7]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
85 [_args addPointer:(void *)&param8]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
86 [_args addPointer:(void *)&param9];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
87 #define DW_FUNCTION_RESTORE_PARAM1(param1, vartype1) vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
88 #define DW_FUNCTION_RESTORE_PARAM2(param1, vartype1, param2, vartype2) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
89 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
90 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
91 #define DW_FUNCTION_RESTORE_PARAM3(param1, vartype1, param2, vartype2, param3, vartype3) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
92 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
93 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
94 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
95 #define DW_FUNCTION_RESTORE_PARAM4(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
96 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
97 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
98 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
99 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
100 #define DW_FUNCTION_RESTORE_PARAM5(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
101 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
102 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
103 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
104 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
105 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
106 #define DW_FUNCTION_RESTORE_PARAM6(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
107 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
108 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
109 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
110 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
111 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
112 vartype6 param6 = *((vartype6 *)[_args pointerAtIndex:6]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
113 #define DW_FUNCTION_RESTORE_PARAM7(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
114 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
115 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
116 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
117 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
118 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
119 vartype6 param6 = *((vartype6 *)[_args pointerAtIndex:6]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
120 vartype7 param7 = *((vartype7 *)[_args pointerAtIndex:7]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
121 #define DW_FUNCTION_RESTORE_PARAM8(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
122 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
123 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
124 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
125 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
126 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
127 vartype6 param6 = *((vartype6 *)[_args pointerAtIndex:6]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
128 vartype7 param7 = *((vartype7 *)[_args pointerAtIndex:7]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
129 vartype8 param8 = *((vartype8 *)[_args pointerAtIndex:8]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
130 #define DW_FUNCTION_RESTORE_PARAM9(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9) \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
131 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
132 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
133 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
134 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
135 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
136 vartype6 param6 = *((vartype6 *)[_args pointerAtIndex:6]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
137 vartype7 param7 = *((vartype7 *)[_args pointerAtIndex:7]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
138 vartype8 param8 = *((vartype8 *)[_args pointerAtIndex:8]); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
139 vartype9 param9 = *((vartype9 *)[_args pointerAtIndex:9]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
140 #define DW_FUNCTION_END }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
141 #define DW_FUNCTION_NO_RETURN(func) [DWObj safeCall:@selector(callBack:) withObject:_args]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
142 [_args release]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
143 DW_LOCAL_POOL_OUT; } \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
144 void _##func(NSPointerArray *_args) {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
145 #define DW_FUNCTION_RETURN(func, rettype) [DWObj safeCall:@selector(callBack:) withObject:_args]; {\
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
146 void *tmp = [_args pointerAtIndex:[_args count]-1]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
147 rettype myreturn = *((rettype *)tmp); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
148 free(tmp); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
149 return myreturn; } \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
150 [_args release]; \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
151 DW_LOCAL_POOL_OUT; } \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
152 void _##func(NSPointerArray *_args) {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
153 #define DW_FUNCTION_RETURN_THIS(_retvar) { void *_myreturn = malloc(sizeof(_retvar)); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
154 memcpy(_myreturn, (void *)&_retvar, sizeof(_retvar)); \
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
155 [_args addPointer:_myreturn]; }}
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
156 #define DW_FUNCTION_RETURN_NOTHING }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
157
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
158 unsigned long _dw_colors[] =
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
159 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
160 0x00000000, /* 0 black */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
161 0x000000bb, /* 1 red */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
162 0x0000bb00, /* 2 green */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
163 0x0000aaaa, /* 3 yellow */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
164 0x00cc0000, /* 4 blue */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
165 0x00bb00bb, /* 5 magenta */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166 0x00bbbb00, /* 6 cyan */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
167 0x00bbbbbb, /* 7 white */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
168 0x00777777, /* 8 grey */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
169 0x000000ff, /* 9 bright red */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
170 0x0000ff00, /* 10 bright green */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
171 0x0000eeee, /* 11 bright yellow */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 0x00ff0000, /* 12 bright blue */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173 0x00ff00ff, /* 13 bright magenta */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
174 0x00eeee00, /* 14 bright cyan */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
175 0x00ffffff, /* 15 bright white */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
176 0xff000000 /* 16 default color */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
177 };
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
178
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
179 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
180 * List those icons that have transparency first
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
181 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
182 #define NUM_EXTS 8
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
183 char *_dw_image_exts[NUM_EXTS+1] =
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
184 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
185 ".png",
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
186 ".ico",
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
187 ".icns",
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
188 ".gif",
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
189 ".jpg",
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
190 ".jpeg",
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
191 ".tiff",
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
192 ".bmp",
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
193 NULL
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
194 };
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
195
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
196 char *_dw_get_image_extension(const char *filename)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
197 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
198 char *file = alloca(strlen(filename) + 6);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
199 int found_ext = 0,i;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
200
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201 /* Try various extentions */
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
202 for(i = 0; i < NUM_EXTS; i++)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
203 {
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
204 strcpy(file, filename);
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
205 strcat(file, _dw_image_exts[i]);
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
206 if(access(file, R_OK ) == 0)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
207 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
208 found_ext = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
209 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
210 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211 }
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
212 if(found_ext == 1)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
213 {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
214 return _dw_image_exts[i];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
215 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
216 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
217 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
218
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
219 /* Return the RGB color regardless if a predefined color was passed */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
220 unsigned long _dw_get_color(unsigned long thiscolor)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
221 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
222 if(thiscolor & DW_RGB_COLOR)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
223 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
224 return thiscolor & ~DW_RGB_COLOR;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
225 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
226 else if(thiscolor < 17)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
227 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
228 return _dw_colors[thiscolor];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
229 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
230 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
231 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
232
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
233 /* Thread specific storage */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
234 pthread_key_t _dw_pool_key;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
235 pthread_key_t _dw_fg_color_key;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
236 pthread_key_t _dw_bg_color_key;
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
237 static int DWOSMajor, DWOSMinor, DWOSBuild;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
238 static char _dw_bundle_path[PATH_MAX+1] = { 0 };
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
239 static char _dw_app_id[_DW_APP_ID_SIZE+1]= {0};
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
240 static int _dw_dark_mode_state = DW_FEATURE_UNSUPPORTED;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
241
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
242 /* Create a default colors for a thread */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
243 void _dw_init_colors(void)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
244 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
245 UIColor *fgcolor = [[UIColor grayColor] retain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
246 pthread_setspecific(_dw_fg_color_key, fgcolor);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
247 pthread_setspecific(_dw_bg_color_key, NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
248 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
249
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
250 typedef struct _sighandler
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
251 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
252 struct _sighandler *next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
253 ULONG message;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
254 HWND window;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
255 int id;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
256 void *signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
257 void *discfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
258 void *data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
259
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
260 } SignalHandler;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
261
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
262 static SignalHandler *DWRoot = NULL;
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
263
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
264 /* Some internal prototypes */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
265 static void _dw_do_resize(Box *thisbox, int x, int y);
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
266 void _dw_handle_resize_events(Box *thisbox);
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
267 int _dw_remove_userdata(UserData **root, const char *varname, int all);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
268 int _dw_main_iteration(NSDate *date);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
269 CGContextRef _dw_draw_context(id image, bool antialias);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 typedef id (*DWIMP)(id, SEL, ...);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
271
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
272 /* Internal function to queue a window redraw */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
273 void _dw_redraw(id window, int skip)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
274 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275 static id lastwindow = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
276 id redraw = lastwindow;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
277
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
278 if(skip && window == nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
279 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
280
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
281 lastwindow = window;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
282 if(redraw != lastwindow && redraw != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
283 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
284 dw_window_redraw(redraw);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
285 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
286 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
288 SignalHandler *_dw_get_handler(HWND window, int messageid)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
290 SignalHandler *tmp = DWRoot;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
291
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
292 /* Find any callbacks for this function */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
293 while(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
294 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
295 if(tmp->message == messageid && window == tmp->window)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
296 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297 return tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
298 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
299 tmp = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
300 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
301 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
303
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
304 typedef struct
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
305 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
306 ULONG message;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
307 char name[30];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
308
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
309 } DWSignalList;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
310
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
311 /* List of signals */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
312 #define SIGNALMAX 19
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
313
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
314 static DWSignalList DWSignalTranslate[SIGNALMAX] = {
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
315 { 1, DW_SIGNAL_CONFIGURE },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316 { 2, DW_SIGNAL_KEY_PRESS },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
317 { 3, DW_SIGNAL_BUTTON_PRESS },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318 { 4, DW_SIGNAL_BUTTON_RELEASE },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
319 { 5, DW_SIGNAL_MOTION_NOTIFY },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
320 { 6, DW_SIGNAL_DELETE },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
321 { 7, DW_SIGNAL_EXPOSE },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
322 { 8, DW_SIGNAL_CLICKED },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
323 { 9, DW_SIGNAL_ITEM_ENTER },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
324 { 10, DW_SIGNAL_ITEM_CONTEXT },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
325 { 11, DW_SIGNAL_LIST_SELECT },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 { 12, DW_SIGNAL_ITEM_SELECT },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
327 { 13, DW_SIGNAL_SET_FOCUS },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
328 { 14, DW_SIGNAL_VALUE_CHANGED },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
329 { 15, DW_SIGNAL_SWITCH_PAGE },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
330 { 16, DW_SIGNAL_TREE_EXPAND },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
331 { 17, DW_SIGNAL_COLUMN_CLICK },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332 { 18, DW_SIGNAL_HTML_RESULT },
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 { 19, DW_SIGNAL_HTML_CHANGED }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
334 };
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
335
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
336 int _dw_event_handler1(id object, UIEvent *event, int message)
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
337 {
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
338 SignalHandler *handler = _dw_get_handler(object, message);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
339 /* NSLog(@"Event handler - type %d\n", message); */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
340
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341 if(handler)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
343 switch(message)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345 /* Timer event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
346 case 0:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
347 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
348 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
349
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350 if(!timerfunc(handler->data))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351 dw_timer_disconnect(handler->id);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
353 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
354 /* Configure/Resize event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
355 case 1:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
356 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
358 CGSize size;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
359
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
360 if([object isKindOfClass:[UIWindow class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
361 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
362 UIWindow *window = object;
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
363 size = [window frame].size;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
364 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
365 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
366 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
367 UIView *view = object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
368 size = [view frame].size;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
369 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
370
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
371 if(size.width > 0 && size.height > 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
372 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
373 return sizefunc(object, size.width, size.height, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
374 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
375 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
376 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
377 case 2:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
378 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
379 int (*keypressfunc)(HWND, char, int, int, void *, char *) = handler->signalfunction;
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
380 NSString *nchar = @""; /* [event charactersIgnoringModifiers]; */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
381 unichar vk = [nchar characterAtIndex:0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
382 char *utf8 = NULL, ch = '\0';
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
383 int special = 0;
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
384
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
385 if(@available(iOS 13.4, *))
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
386 {
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
387 special = (int)[event modifierFlags];
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
388 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
389
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
390 /* Handle a valid key */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
391 if([nchar length] == 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
392 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
393 char *tmp = (char *)[nchar UTF8String];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
394 if(tmp && strlen(tmp) == 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
395 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
396 ch = tmp[0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
397 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
398 utf8 = tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
399 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
400
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
401 return keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
402 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
403 /* Button press and release event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
404 case 3:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
405 case 4:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
406 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
407 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
408 int button = 1;
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
409 CGPoint p = {0};
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
410
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
411 if([event isMemberOfClass:[UIEvent class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
412 {
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
413 UITouch *touch = [[event allTouches] anyObject];
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
414
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
415 p = [touch locationInView:[touch view]];
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
416
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
417 if(@available(ios 13.4, *))
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
418 {
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
419 if([event buttonMask] & UIEventButtonMaskSecondary)
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
420 button = 2;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
421 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
422 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
423
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
424 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
425 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
426 /* Motion notify event */
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
427 #if 0 /* Not sure if motion notify applies */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
428 case 5:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
429 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
430 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
431
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
432 return motionfunc(object, (int)p.x, (int)p.y, (int)buttonmask, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
433 }
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
434 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
435 /* Window close event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
436 case 6:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
437 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
438 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
439 return closefunc(object, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
440 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
441 /* Window expose/draw event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
442 case 7:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
443 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
444 DWExpose exp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
445 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
446 CGRect rect = [object frame];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
447
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
448 exp.x = rect.origin.x;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
449 exp.y = rect.origin.y;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
450 exp.width = rect.size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
451 exp.height = rect.size.height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
452 int result = exposefunc(object, &exp, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
453 return result;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
454 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
455 /* Clicked event for buttons and menu items */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
456 case 8:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
457 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
458 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
459
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
460 return clickfunc(object, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
461 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
462 /* Container class selection event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
463 case 9:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
464 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
465 int (*containerselectfunc)(HWND, char *, void *, void *) = handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
466 void **params = (void **)event;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
467
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
468 return containerselectfunc(handler->window, params[0], handler->data, params[1]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
469 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
470 /* Container context menu event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
471 case 10:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
472 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
473 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
474 char *text = (char *)event;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
475 void *user = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
476 LONG x,y;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
477
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
478 dw_pointer_query_pos(&x, &y);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
479
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
480 return containercontextfunc(handler->window, text, (int)x, (int)y, handler->data, user);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
481 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
482 /* Generic selection changed event for several classes */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
483 case 11:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
484 case 14:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
485 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
486 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
487 int selected = DW_POINTER_TO_INT(event);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
488
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
489 return valuechangedfunc(handler->window, selected, handler->data);;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
490 }
2429
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
491 /* Tree class selection event */
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
492 case 12:
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
493 {
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
494 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction;
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
495 char *text = NULL;
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
496 void *user = NULL;
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
497 id item = nil;
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
498
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
499 if([object isKindOfClass:[UITableView class]] && event)
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
500 {
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
501 void **params = (void **)event;
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
502
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
503 text = params[0];
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
504 user = params[1];
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
505 }
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
506
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
507 return treeselectfunc(handler->window, item, text, handler->data, user);
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
508 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
509 /* Set Focus event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
510 case 13:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
511 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
512 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
513
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
514 return setfocusfunc(handler->window, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
515 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
516 /* Notebook page change event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
517 case 15:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
518 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
519 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
520 int pageid = DW_POINTER_TO_INT(event);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
521
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
522 return switchpagefunc(handler->window, pageid, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
523 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
524 /* Tree expand event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
525 case 16:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
526 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
527 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
528
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
529 return treeexpandfunc(handler->window, (HTREEITEM)event, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
530 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
531 /* Column click event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
532 case 17:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
533 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
534 int (* API clickcolumnfunc)(HWND, int, void *) = handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
535 int column_num = DW_POINTER_TO_INT(event);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
536
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
537 return clickcolumnfunc(handler->window, column_num, handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
538 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
539 /* HTML result event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
540 case 18:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
541 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
542 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
543 void **params = (void **)event;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
544 NSString *result = params[0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
545
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
546 return htmlresultfunc(handler->window, [result length] ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, [result length] ? (char *)[result UTF8String] : NULL, params[1], handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
547 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
548 /* HTML changed event */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
549 case 19:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
550 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
551 int (* API htmlchangedfunc)(HWND, int, char *, void *) = handler->signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
552 void **params = (void **)event;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
553 NSString *uri = params[1];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
554
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
555 return htmlchangedfunc(handler->window, DW_POINTER_TO_INT(params[0]), (char *)[uri UTF8String], handler->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
556 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
557 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
558 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
559 return -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
560 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
561
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
562 /* Sub function to handle redraws */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
563 int _dw_event_handler(id object, UIEvent *event, int message)
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
564 {
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
565 int ret = _dw_event_handler1(object, event, message);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
566 if(ret != -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
567 _dw_redraw(nil, FALSE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
568 return ret;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
569 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
570
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
571 /* Subclass for the Timer type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
572 @interface DWTimerHandler : NSObject { }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
573 -(void)runTimer:(id)sender;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
574 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
575
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
576 @implementation DWTimerHandler
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
577 -(void)runTimer:(id)sender { _dw_event_handler(sender, nil, 0); }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
578 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
579
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
580 @interface DWAppDel : UIResponder <UIApplicationDelegate> { }
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
581 -(void)applicationWillTerminate:(UIApplication *)application;
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
582 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions;
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
583 @end
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
584
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
585 @implementation DWAppDel
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
586 -(void)applicationWillTerminate:(UIApplication *)application
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
587 {
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
588 /* On iOS we can't prevent temrination, but send the notificatoin anyway */
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
589 _dw_event_handler(application, nil, 6);
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
590 }
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
591 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
592 {
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
593 return true;
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
594 }
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
595 @end
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
596
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
597 static UIApplication *DWApp = nil;
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
598 static UIFont *DWDefaultFont;
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
599 static DWTimerHandler *DWHandler;
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
600 static NSMutableArray *_DWDirtyDrawables;
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
601 static DWTID DWThread = (DWTID)-1;
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
602 static HEV DWMainEvent;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
603
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
604 /* Used for doing bitblts from the main thread */
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
605 typedef struct _dw_bitbltinfo
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
606 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
607 id src;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
608 id dest;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
609 int xdest;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
610 int ydest;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
611 int width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
612 int height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
613 int xsrc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
614 int ysrc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
615 int srcwidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
616 int srcheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
617 } DWBitBlt;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
618
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
619 /* Subclass for a test object type */
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
620 @interface DWObject : NSObject
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
621 {
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
622 /* A normally hidden window, at the top of the view hierarchy.
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
623 * Since iOS messageboxes and such require a view controller,
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
624 * we show this hidden window when necessary and use it during
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
625 * the creation of alerts and dialog boxes that don't have one.
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
626 */
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
627 UIWindow *hiddenWindow;
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
628 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
629 -(void)uselessThread:(id)sender;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
630 -(void)menuHandler:(id)param;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
631 -(void)doBitBlt:(id)param;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
632 -(void)doFlush:(id)param;
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
633 -(UIWindow *)hiddenWindow;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
634 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
635
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
636 API_AVAILABLE(ios(13.0))
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
637 @interface DWMenuItem : UICommand
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
638 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
639 int check;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
640 unsigned long tag;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
641 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
642 -(void)setCheck:(int)input;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
643 -(void)setTag:(unsigned long)input;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
644 -(int)check;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
645 -(unsigned long)tag;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
646 -(void)dealloc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
647 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
648
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
649 API_AVAILABLE(ios(13.0))
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
650 @interface DWMenu : NSObject
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
651 {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
652 UIMenu *menu;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
653 }
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
654 -(void)setMenu:(UIMenu *)input;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
655 -(UIMenu *)menu;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
656 -(DWMenuItem *)itemWithTag:(unsigned long)tag;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
657 -(void)dealloc;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
658 @end
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
659
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
660
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
661 /* So basically to implement our event handlers...
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
662 * it looks like we are going to have to subclass
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
663 * basically everything. Was hoping to add methods
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
664 * to the superclasses but it looks like you can
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
665 * only add methods and no variables, which isn't
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
666 * going to work. -Brian
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
667 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
668
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 /* Subclass for a box type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
670 @interface DWBox : UIView
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
671 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
672 Box *box;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
673 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
674 UIColor *bgcolor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
675 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
676 -(id)init;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
677 -(void)dealloc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
678 -(Box *)box;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
679 -(id)contentView;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
680 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
681 -(void)setUserdata:(void *)input;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
682 -(void)drawRect:(CGRect)rect;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
683 -(BOOL)isFlipped;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
684 -(void)mouseDown:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
685 -(void)mouseUp:(UIEvent *)theEvent;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
686 -(DWMenu *)menuForEvent:(UIEvent *)theEvent;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
687 -(void)rightMouseUp:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
688 -(void)otherMouseDown:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
689 -(void)otherMouseUp:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
690 -(void)keyDown:(UIEvent *)theEvent;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
691 -(void)setColor:(unsigned long)input;
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
692 -(void)layoutSubviews;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
693 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
694
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
695 @implementation DWBox
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
696 -(id)init
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
697 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
698 self = [super init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
699
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
700 if (self)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
701 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
702 box = calloc(1, sizeof(Box));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
703 box->type = DW_VERT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
704 box->vsize = box->hsize = SIZEEXPAND;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
705 box->width = box->height = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
706 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
707 return self;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
708 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
709 -(void)dealloc
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
710 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
711 UserData *root = userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
712 if(box->items)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
713 free(box->items);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
714 free(box);
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
715 _dw_remove_userdata(&root, NULL, TRUE);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
716 dw_signal_disconnect_by_window(self);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
717 [super dealloc];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
718 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
719 -(Box *)box { return box; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
720 -(id)contentView { return self; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
722 -(void)setUserdata:(void *)input { userdata = input; }
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
723 -(void)drawRect:(CGRect)rect
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
724 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
725 if(bgcolor)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
726 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
727 [bgcolor set];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
728 UIRectFill([self bounds]);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
729 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
730 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
731 -(BOOL)isFlipped { return YES; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
732 -(void)mouseDown:(UIEvent *)theEvent { _dw_event_handler(self, (void *)1, 3); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
733 -(void)mouseUp:(UIEvent *)theEvent { _dw_event_handler(self, (void *)1, 4); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
734 -(DWMenu *)menuForEvent:(UIEvent *)theEvent { _dw_event_handler(self, (void *)2, 3); return nil; }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
735 -(void)rightMouseUp:(UIEvent *)theEvent { _dw_event_handler(self, (void *)2, 4); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
736 -(void)otherMouseDown:(UIEvent *)theEvent { _dw_event_handler(self, (void *)3, 3); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
737 -(void)otherMouseUp:(UIEvent *)theEvent { _dw_event_handler(self, (void *)3, 4); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
738 -(void)keyDown:(UIEvent *)theEvent { _dw_event_handler(self, theEvent, 2); }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
739 -(void)setColor:(unsigned long)input
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
740 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
741 id orig = bgcolor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
742
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
743 if(input == _dw_colors[DW_CLR_DEFAULT])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
744 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
745 bgcolor = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
746 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
747 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
748 {
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
749 bgcolor = [[UIColor colorWithRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
750 if(UIGraphicsGetCurrentContext())
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
751 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
752 [bgcolor set];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
753 UIRectFill([self bounds]);
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
754 }
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
755 }
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
756 [self setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
757 [orig release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
758 }
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
759 -(void)layoutSubviews { };
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
760 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
761
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
762 @interface DWWindow : UIWindow
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
763 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
764 int redraw;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
765 int shown;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
766 }
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
767 -(void)sendEvent:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
768 -(void)keyDown:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
769 -(void)mouseDragged:(UIEvent *)theEvent;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
770 -(int)redraw;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
771 -(void)setRedraw:(int)val;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
772 -(int)shown;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
773 -(void)setShown:(int)val;
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
774 -(void)layoutSubviews;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
775 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
776
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
777 @implementation DWWindow
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
778 -(void)sendEvent:(UIEvent *)theEvent
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
779 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
780 int rcode = -1;
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
781 if([theEvent type] == UIEventTypePresses)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
782 {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
783 rcode = _dw_event_handler(self, theEvent, 2);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
784 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 if ( rcode != TRUE )
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786 [super sendEvent:theEvent];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
787 }
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
788 -(void)keyDown:(UIEvent *)theEvent { }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
789 -(void)mouseDragged:(UIEvent *)theEvent { _dw_event_handler(self, theEvent, 5); }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
790 -(int)redraw { return redraw; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
791 -(void)setRedraw:(int)val { redraw = val; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
792 -(int)shown { return shown; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
793 -(void)setShown:(int)val { shown = val; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
794 -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; }
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
795 -(void)layoutSubviews { }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
796 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
797
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
798 @interface DWImage : NSObject
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
799 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
800 UIImage *image;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
801 CGContextRef cgcontext;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
802 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
803 -(id)initWithSize:(CGSize)size;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
804 -(id)initWithCGImage:(CGImageRef)cgimage;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
805 -(id)initWithUIImage:(UIImage *)newimage;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
806 -(void)setImage:(UIImage *)input;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
807 -(UIImage *)image;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
808 -(CGContextRef)cgcontext;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
809 -(void)dealloc;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
810 @end
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
811
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
812 /* Subclass for a render area type */
2436
ab36fbb50fe5 iOS: Fixes to get cachedImage functionality working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2435
diff changeset
813 @interface DWRender : UIView
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
814 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
815 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
816 UIFont *font;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
817 CGSize size;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
818 DWImage *cachedImage;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
819 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
820 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
821 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
822 -(void)setFont:(UIFont *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
823 -(UIFont *)font;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
824 -(void)setSize:(CGSize)input;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
825 -(CGSize)size;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
826 -(DWImage *)cachedImage;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
827 -(void)mouseDown:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
828 -(void)mouseUp:(UIEvent *)theEvent;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
829 -(DWMenu *)menuForEvent:(UIEvent *)theEvent;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
830 -(void)rightMouseUp:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
831 -(void)otherMouseDown:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
832 -(void)otherMouseUp:(UIEvent *)theEvent;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
833 -(void)drawRect:(CGRect)rect;
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
834 -(void)keyDown:(UIEvent *)theEvent;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
835 -(BOOL)isFlipped;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
836 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838 @implementation DWRender
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
840 -(void)setUserdata:(void *)input { userdata = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
841 -(void)setFont:(UIFont *)input { [font release]; font = input; [font retain]; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
842 -(UIFont *)font { return font; }
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
843 -(void)setSize:(CGSize)input {
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
844 size = input;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
845 if(cachedImage)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
846 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
847 DWImage *oldimage = cachedImage;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
848 UIImage *newimage;
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
849 UIGraphicsBeginImageContext(self.frame.size);
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
850 [[self layer] renderInContext:UIGraphicsGetCurrentContext()];
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
851 newimage = UIGraphicsGetImageFromCurrentImageContext();
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
852 UIGraphicsEndImageContext();
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
853 cachedImage = [[DWImage alloc] initWithUIImage:newimage];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
854 [cachedImage retain];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
855 [oldimage release];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
856 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
857 }
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
858 -(CGSize)size { return size; }
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
859 -(DWImage *)cachedImage {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
860 if(!cachedImage)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
861 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
862 UIImage *newimage;
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
863 UIGraphicsBeginImageContext(self.frame.size);
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
864 [[self layer] renderInContext:UIGraphicsGetCurrentContext()];
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
865 newimage = UIGraphicsGetImageFromCurrentImageContext();
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
866 UIGraphicsEndImageContext();
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
867 cachedImage = [[DWImage alloc] initWithUIImage:newimage];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
868 [cachedImage retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
869 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
870 /* Mark this render dirty if something is requesting it to draw */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
871 if(![_DWDirtyDrawables containsObject:self])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872 [_DWDirtyDrawables addObject:self];
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
873 return cachedImage;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
874 }
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
875 -(void)mouseDown:(UIEvent *)theEvent
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
876 {
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
877 if(![theEvent isMemberOfClass:[UIEvent class]])
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
878 _dw_event_handler(self, theEvent, 3);
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
879 }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
880 -(void)mouseUp:(UIEvent *)theEvent { _dw_event_handler(self, theEvent, 4); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
881 -(DWMenu *)menuForEvent:(UIEvent *)theEvent { _dw_event_handler(self, theEvent, 3); return nil; }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
882 -(void)rightMouseUp:(UIEvent *)theEvent { _dw_event_handler(self, theEvent, 4); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
883 -(void)otherMouseDown:(UIEvent *)theEvent { _dw_event_handler(self, theEvent, 3); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
884 -(void)otherMouseUp:(UIEvent *)theEvent { _dw_event_handler(self, theEvent, 4); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
885 -(void)mouseDragged:(UIEvent *)theEvent { _dw_event_handler(self, theEvent, 5); }
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
886 -(void)drawRect:(CGRect)rect {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
887 _dw_event_handler(self, nil, 7);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
888 if(cachedImage)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
889 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
890 [[cachedImage image] drawInRect:self.bounds];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
891 [_DWDirtyDrawables removeObject:self];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
892 [self setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
893 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
895 -(void)keyDown:(UIEvent *)theEvent { _dw_event_handler(self, theEvent, 2); }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
896 -(BOOL)isFlipped { return YES; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
897 -(void)dealloc {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898 UserData *root = userdata;
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
899 _dw_remove_userdata(&root, NULL, TRUE);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 [font release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 dw_signal_disconnect_by_window(self);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
902 [cachedImage release];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 [_DWDirtyDrawables removeObject:self];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 [super dealloc];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 -(BOOL)acceptsFirstResponder { return YES; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
908
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
909 @interface DWFontPickerDelegate : UIResponder <UIFontPickerViewControllerDelegate>
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
910 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
911 DWDialog *dialog;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
912 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
913 -(void)fontPickerViewControllerDidPickFont:(UIFontPickerViewController *)viewController;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
914 -(void)fontPickerViewControllerDidCancel:(UIFontPickerViewController *)viewController;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
915 -(void)setDialog:(DWDialog *)newdialog;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
916 @end
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
917
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
918 @implementation DWFontPickerDelegate
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
919 -(void)fontPickerViewControllerDidPickFont:(UIFontPickerViewController *)viewController
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
920 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
921 if(viewController.selectedFontDescriptor)
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
922 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
923 UIFont *font = [UIFont fontWithDescriptor:viewController.selectedFontDescriptor size:9];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
924 dw_dialog_dismiss(dialog, font);
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
925 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
926 else
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
927 dw_dialog_dismiss(dialog, NULL);
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
928 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
929 -(void)fontPickerViewControllerDidCancel:(UIFontPickerViewController *)viewController
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
930 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
931 dw_dialog_dismiss(dialog, NULL);
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
932 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
933 -(void)setDialog:(DWDialog *)newdialog { dialog = newdialog; }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
934 @end
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
935
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
936 @interface DWColorPickerDelegate : UIResponder <UIColorPickerViewControllerDelegate>
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
937 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
938 DWDialog *dialog;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
939 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
940 -(void)colorPickerViewControllerDidSelectColor:(UIColorPickerViewController *)viewController API_AVAILABLE(ios(14.0));
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
941 -(void)colorPickerViewControllerDidFinish:(UIColorPickerViewController *)viewController API_AVAILABLE(ios(14.0));
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
942 -(void)setDialog:(DWDialog *)newdialog;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
943 @end
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
944
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
945 @implementation DWColorPickerDelegate
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
946 -(void)colorPickerViewControllerDidSelectColor:(UIColorPickerViewController *)viewController API_AVAILABLE(ios(14.0))
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
947 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
948 if([viewController selectedColor])
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
949 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
950 CGFloat red, green, blue;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
951 [[viewController selectedColor] getRed:&red green:&green blue:&blue alpha:NULL];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
952 dw_dialog_dismiss(dialog, DW_UINT_TO_POINTER(DW_RGB((int)(red * 255), (int)(green *255), (int)(blue *255))));
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
953 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
954 else
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
955 dw_dialog_dismiss(dialog, NULL);
2415
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
956 [viewController dismissViewControllerAnimated:YES completion:nil];
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
957 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
958 -(void)colorPickerViewControllerDidFinish:(UIColorPickerViewController *)viewController API_AVAILABLE(ios(14.0))
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
959 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
960 dw_dialog_dismiss(dialog, NULL);
2415
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
961 [viewController dismissViewControllerAnimated:YES completion:nil];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
962 }
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
963 -(void)setDialog:(DWDialog *)newdialog { dialog = newdialog; }
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
964 @end
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
965
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
966 @interface DWDocumentPickerDelegate : UIResponder <UIDocumentPickerDelegate>
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
967 {
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
968 DWDialog *dialog;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
969 }
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
970 -(void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
971 -(void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
972 -(void)setDialog:(DWDialog *)newdialog;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
973 @end
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
974
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
975 @implementation DWDocumentPickerDelegate
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
976 -(void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
977 {
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
978 NSURL *url = [urls firstObject];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
979 char *file = NULL;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
980
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
981 if(url && [[url absoluteString] length] > 0)
2445
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
982 {
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
983 const char *tmp = [[url absoluteString] UTF8String];
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
984
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
985 if(tmp)
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
986 {
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
987 /* Strip off file:// so it looks the same as other platforms */
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
988 if(strncmp(tmp, "file://", 7) == 0)
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
989 file = strdup(&tmp[7]);
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
990 else
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
991 file = strdup(tmp);
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
992 }
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
993 }
2415
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
994 dw_dialog_dismiss(dialog, file);
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
995 }
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
996 -(void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
997 {
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
998 dw_dialog_dismiss(dialog, NULL);
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
999 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1000 -(void)setDialog:(DWDialog *)newdialog { dialog = newdialog; }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1001 @end
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1002
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1003 @implementation DWObject
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1004 -(id)init
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1005 {
2395
2618277de356 iOS: Code error cleanup reported by LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2393
diff changeset
1006 self = [super init];
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1007 /* This previously had the code in delayedIinit: */
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1008 return self;
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1009 }
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1010 -(void)delayedInit:(id)param
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1011 {
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1012 /* When DWObject is initialized, UIApplicationMain() has not yet been called...
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1013 * So the created objects can't interact with the user interface... therefore
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1014 * we wait until UIApplicationMain() has been called and run this then.
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1015 */
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1016 hiddenWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1017 [hiddenWindow setWindowLevel:UIWindowLevelAlert+1];
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1018 [hiddenWindow setHidden:YES];
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1019 [hiddenWindow setRootViewController:[UIViewController new]];
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1020 /* Handle setting the dark mode state now that DWObj is valid */
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1021 if(_dw_dark_mode_state != DW_FEATURE_UNSUPPORTED)
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1022 dw_feature_set(DW_FEATURE_DARK_MODE, _dw_dark_mode_state);
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1023 }
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1024 -(UIWindow *)hiddenWindow { return hiddenWindow; };
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1025 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1026 -(void)menuHandler:(id)param
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1027 {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1028 _dw_event_handler(param, nil, 8);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1029 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1030 -(void)callBack:(NSPointerArray *)params
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1031 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1032 void (*mycallback)(NSPointerArray *) = [params pointerAtIndex:0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1033 if(mycallback)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1034 mycallback(params);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1035 }
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1036 -(void)colorPicker:(NSMutableArray *)params
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1037 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1038 if (@available(iOS 14.0, *))
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1039 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1040 DWDialog *dialog = dw_dialog_new(NULL);
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1041 UIColorPickerViewController *picker = [[UIColorPickerViewController alloc] init];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1042 DWColorPickerDelegate *delegate = [[DWColorPickerDelegate alloc] init];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1043
2415
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1044 /* Setup our picker */
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1045 [picker setSupportsAlpha:NO];
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1046 /* Unhide our hidden window and make it key */
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1047 [hiddenWindow setHidden:NO];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1048 [hiddenWindow makeKeyAndVisible];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1049 [delegate setDialog:dialog];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1050 [picker setDelegate:delegate];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1051 /* Wait for them to pick a color */
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1052 [[hiddenWindow rootViewController] presentViewController:picker animated:YES completion:nil];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1053 [params addObject:[NSNumber numberWithUnsignedLong:DW_POINTER_TO_UINT(dw_dialog_wait(dialog))]];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1054 /* Once the dialog is gone we can rehide our window */
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1055 [hiddenWindow resignKeyWindow];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1056 [hiddenWindow setHidden:YES];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1057 [picker release];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1058 [delegate release];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1059 } else {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1060 // Fallback on earlier versions
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1061 };
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1062 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1063 -(void)fontPicker:(NSPointerArray *)params
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1064 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1065 DWDialog *dialog = dw_dialog_new(NULL);
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1066 UIFontPickerViewController *picker = [[UIFontPickerViewController alloc] init];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1067 DWFontPickerDelegate *delegate = [[DWFontPickerDelegate alloc] init];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1068 UIFont *font;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1069
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1070 /* Unhide our hidden window and make it key */
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1071 [hiddenWindow setHidden:NO];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1072 [hiddenWindow makeKeyAndVisible];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1073 [delegate setDialog:dialog];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1074 [picker setDelegate:delegate];
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
1075 /* Wait for them to pick a font */
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1076 [[hiddenWindow rootViewController] presentViewController:picker animated:YES completion:nil];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1077 font = dw_dialog_wait(dialog);
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1078 /* Once the dialog is gone we can rehide our window */
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1079 [hiddenWindow resignKeyWindow];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1080 [hiddenWindow setHidden:YES];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1081
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1082 if(font)
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1083 {
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1084 NSString *fontname = [font fontName];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1085 NSString *output = [NSString stringWithFormat:@"%d.%s", (int)[font pointSize], [fontname UTF8String]];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1086 [params addPointer:strdup([output UTF8String])];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1087 }
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1088 else
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1089 [params addPointer:NULL];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1090 [picker release];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1091 [delegate release];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
1092 }
2415
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1093 -(void)filePicker:(NSPointerArray *)params
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1094 {
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1095 DWDialog *dialog = dw_dialog_new(NULL);
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1096 UIDocumentPickerViewController *picker ;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1097 DWDocumentPickerDelegate *delegate = [[DWDocumentPickerDelegate alloc] init];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1098 UIDocumentPickerMode mode = UIDocumentPickerModeOpen;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1099 char *defpath = [params pointerAtIndex:0];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1100 char *ext = [params pointerAtIndex:1];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1101 int flags = DW_POINTER_TO_INT([params pointerAtIndex:2]);
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1102 char *file = NULL;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1103 NSArray *UTIs;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1104
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1105 /* Setup the picker */
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1106 if(flags & DW_FILE_SAVE)
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1107 mode = UIDocumentPickerModeExportToService;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1108 /* Try to generate a UTI for our passed extension */
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1109 if(ext)
2445
a773008c7c5d iOS: Make sure the plain text UTI is used with filePicker.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2444
diff changeset
1110 UTIs = [NSArray arrayWithObjects:[NSString stringWithFormat:@"public.%s", ext], @"public.text", nil];
2415
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1111 else
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1112 UTIs = @[@"public.text"];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1113 picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:UTIs inMode:mode];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1114 [picker setAllowsMultipleSelection:NO];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1115 [picker setShouldShowFileExtensions:YES];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1116 if(defpath)
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1117 [picker setDirectoryURL:[NSURL URLWithString:[NSString stringWithUTF8String:defpath]]];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1118 /* Unhide our hidden window and make it key */
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1119 [hiddenWindow setHidden:NO];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1120 [hiddenWindow makeKeyAndVisible];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1121 [delegate setDialog:dialog];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1122 [picker setDelegate:delegate];
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
1123 /* Wait for them to pick a file */
2415
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1124 [[hiddenWindow rootViewController] presentViewController:picker animated:YES completion:nil];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1125 file = dw_dialog_wait(dialog);
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1126 /* Once the dialog is gone we can rehide our window */
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1127 [hiddenWindow resignKeyWindow];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1128 [hiddenWindow setHidden:YES];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1129 [params addPointer:file];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1130 [picker release];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1131 [delegate release];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
1132 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1133 -(void)messageBox:(NSMutableArray *)params
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1134 {
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1135 __block DWDialog *dialog = dw_dialog_new(NULL);
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1136 NSInteger iResponse;
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1137 UIAlertController* alert = [UIAlertController alertControllerWithTitle:[params objectAtIndex:0]
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1138 message:[params objectAtIndex:1]
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1139 preferredStyle:[[params objectAtIndex:2] integerValue]];
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1140 UIAlertAction* action = [UIAlertAction actionWithTitle:[params objectAtIndex:3] style:UIAlertActionStyleDefault
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1141 handler:^(UIAlertAction * action) { dw_dialog_dismiss(dialog, DW_INT_TO_POINTER(1)); }];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1142 [alert addAction:action];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1143 if([params count] > 4)
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1144 {
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1145 action = [UIAlertAction actionWithTitle:[params objectAtIndex:4] style:UIAlertActionStyleDefault
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1146 handler:^(UIAlertAction * action) { dw_dialog_dismiss(dialog, DW_INT_TO_POINTER(2)); }];
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1147 [alert addAction:action];
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1148 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1149 if([params count] > 5)
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1150 {
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1151 action = [UIAlertAction actionWithTitle:[params objectAtIndex:5] style:UIAlertActionStyleDefault
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1152 handler:^(UIAlertAction * action) { dw_dialog_dismiss(dialog, DW_INT_TO_POINTER(3)); }];
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1153 [alert addAction:action];
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1154 }
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1155
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1156 /* Unhide our hidden window and make it key */
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1157 [hiddenWindow setHidden:NO];
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1158 [hiddenWindow makeKeyAndVisible];
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1159 [[hiddenWindow rootViewController] presentViewController:alert animated:YES completion:nil];
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1160 iResponse = DW_POINTER_TO_INT(dw_dialog_wait(dialog));
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1161 /* Once the dialog is gone we can rehide our window */
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
1162 [hiddenWindow resignKeyWindow];
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
1163 [hiddenWindow setHidden:YES];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1164 [params addObject:[NSNumber numberWithInteger:iResponse]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1165 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1166 -(void)safeCall:(SEL)sel withObject:(id)param
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1167 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1168 if([self respondsToSelector:sel])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1169 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1170 DWTID curr = pthread_self();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1171
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1172 if(DWThread == (DWTID)-1 || DWThread == curr)
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1173 [self performSelector:sel withObject:param];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1174 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1175 [self performSelectorOnMainThread:sel withObject:param waitUntilDone:YES];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1176 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1177 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1178 -(void)doBitBlt:(id)param
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1179 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1180 NSValue *bi = (NSValue *)param;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1181 DWBitBlt *bltinfo = (DWBitBlt *)[bi pointerValue];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1182 id bltdest = bltinfo->dest;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1183 id bltsrc = bltinfo->src;
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
1184 CGContextRef context = _dw_draw_context(bltdest, NO);
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
1185
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
1186 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
1187 UIGraphicsPushContext(context);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1188
2437
929ce3cd18ea iOS: Fix bitblt and crashes due to missing retains.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2436
diff changeset
1189 if(bltdest && [bltsrc isMemberOfClass:[DWImage class]])
929ce3cd18ea iOS: Fix bitblt and crashes due to missing retains.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2436
diff changeset
1190 {
929ce3cd18ea iOS: Fix bitblt and crashes due to missing retains.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2436
diff changeset
1191 DWImage *rep = bltsrc;
929ce3cd18ea iOS: Fix bitblt and crashes due to missing retains.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2436
diff changeset
1192 UIImage *image = [rep image];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1193 CGBlendMode op = kCGBlendModeNormal;
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1194
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1195 if(bltinfo->srcwidth != -1)
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1196 {
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1197 [image drawInRect:CGRectMake(bltinfo->xdest, bltinfo->ydest, bltinfo->width, bltinfo->height)
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1198 /*fromRect:CGRectMake(bltinfo->xsrc, bltinfo->ysrc, bltinfo->srcwidth, bltinfo->srcheight)*/
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1199 blendMode:op alpha:1.0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1200 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1201 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1202 {
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1203 [image drawAtPoint:CGPointMake(bltinfo->xdest, bltinfo->ydest)
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1204 /*fromRect:CGRectMake(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height)*/
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1205 blendMode:op alpha:1.0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1206 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1207 }
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
1208 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
1209 UIGraphicsPopContext();
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1210 free(bltinfo);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1211 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1212 -(void)doFlush:(id)param
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1213 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1214 NSEnumerator *enumerator = [_DWDirtyDrawables objectEnumerator];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1215 DWRender *rend;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1216
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1217 while(rend = [enumerator nextObject])
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
1218 [rend setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1219 [_DWDirtyDrawables removeAllObjects];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1220 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 -(void)doWindowFunc:(id)param
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223 NSValue *v = (NSValue *)param;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1224 void **params = (void **)[v pointerValue];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1225 void (* windowfunc)(void *);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1226
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1227 if(params)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1228 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1229 windowfunc = params[0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1230 if(windowfunc)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1231 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1232 windowfunc(params[1]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1233 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1234 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1235 }
2458
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1236 -(void)getUserInterfaceStyle:(id)param
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1237 {
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1238 NSMutableArray *array = param;
2459
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1239 UIUserInterfaceStyle overridestyle = [hiddenWindow overrideUserInterfaceStyle];
2458
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1240 int retval;
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1241
2459
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1242 switch(overridestyle)
2458
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1243 {
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1244 case UIUserInterfaceStyleLight:
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1245 retval = DW_DARK_MODE_DISABLED;
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1246 break;
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1247 case UIUserInterfaceStyleDark:
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1248 retval = DW_DARK_MODE_FORCED;
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1249 break;
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1250 default: /* UIUserInterfaceStyleUnspecified */
2459
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1251 {
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1252 UIUserInterfaceStyle style = [[[hiddenWindow rootViewController] traitCollection] userInterfaceStyle];
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1253
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1254 switch(style)
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1255 {
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1256 case UIUserInterfaceStyleLight:
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1257 retval = DW_DARK_MODE_BASIC;
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1258 break;
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1259 case UIUserInterfaceStyleDark:
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1260 retval = DW_DARK_MODE_FULL;
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1261 break;
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1262 default: /* UIUserInterfaceStyleUnspecified */
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1263 retval = DW_FEATURE_UNSUPPORTED;
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1264 break;
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1265 }
ddc6d49d1110 iOS: Reorganize the code so retval doesn't get clobbered without the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2458
diff changeset
1266 }
2458
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1267 }
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1268 [array addObject:[NSNumber numberWithInt:retval]];
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1269 }
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1270 -(void)setUserInterfaceStyle:(id)param
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1271 {
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1272 NSNumber *number = param;
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1273 UIUserInterfaceStyle style = [number intValue];
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1274
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1275 [hiddenWindow setOverrideUserInterfaceStyle:style];
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
1276 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279 DWObject *DWObj;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1280
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1281 /* Returns TRUE if iOS 12+ is in Dark Mode */
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1282 BOOL _dw_is_dark(void)
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1283 {
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1284 if([[[[DWObj hiddenWindow] rootViewController] traitCollection] userInterfaceStyle] == UIUserInterfaceStyleDark)
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1285 return YES;
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1286 return NO;
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1287 }
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
1288
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1289 @interface DWWebView : WKWebView <WKNavigationDelegate>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1290 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1291 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1292 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1293 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1294 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1295 -(void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296 -(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297 -(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298 -(void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1299 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1300
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1301 @implementation DWWebView : WKWebView
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1302 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1303 -(void)setUserdata:(void *)input { userdata = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1304 -(void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1305 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1306 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED), [[self URL] absoluteString] };
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1307 _dw_event_handler(self, (UIEvent *)params, 19);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1308 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1309 -(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1310 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1311 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE), [[self URL] absoluteString] };
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1312 _dw_event_handler(self, (UIEvent *)params, 19);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1313 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1314 -(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1315 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1316 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING), [[self URL] absoluteString] };
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1317 _dw_event_handler(self, (UIEvent *)params, 19);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1318 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1319 -(void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1320 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1321 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_REDIRECT), [[self URL] absoluteString] };
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1322 _dw_event_handler(self, (UIEvent *)params, 19);
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1323 }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1324 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1325 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1326
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1327 /* Subclass for a top-level window */
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
1328 @interface DWView : DWBox /* <UIWindowDelegate> */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1329 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1330 DWMenu *windowmenu;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
1331 CGSize oldsize;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1332 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1333 -(BOOL)windowShouldClose:(id)sender;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1334 -(void)setMenu:(DWMenu *)input;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1335 -(void)windowDidBecomeMain:(id)sender;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1336 -(void)menuHandler:(id)sender;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1337 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1338
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1339 @implementation DWView
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1340 -(BOOL)windowShouldClose:(id)sender
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1341 {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1342 if(_dw_event_handler(sender, nil, 6) > 0)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1343 return NO;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1344 return YES;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1345 }
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
1346 -(void)willMoveToSuperview:(UIView *)newSuperview
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
1347 {
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
1348 if(newSuperview)
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
1349 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeMain:) name:UIWindowDidBecomeKeyNotification object:[newSuperview window]];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1350 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1351 -(void)dealloc
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1352 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1353 if(windowmenu)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1354 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1355 [windowmenu release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1356 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1357 [[NSNotificationCenter defaultCenter] removeObserver:self];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1358 dw_signal_disconnect_by_window(self);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1359 [super dealloc];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1360 }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1361 -(void)windowResized:(CGSize)size;
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1362 {
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1363 if(oldsize.width != size.width || oldsize.height != size.height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1364 {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1365 _dw_do_resize(box, size.width, size.height);
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1366 _dw_event_handler([self window], nil, 1);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1367 oldsize.width = size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1368 oldsize.height = size.height;
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1369 _dw_handle_resize_events(box);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1370 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1371 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1372 -(void)showWindow
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1373 {
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
1374 CGSize size = [self frame].size;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1375
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1376 if(oldsize.width == size.width && oldsize.height == size.height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1377 {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1378 _dw_do_resize(box, size.width, size.height);
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1379 _dw_handle_resize_events(box);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1380 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1381
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1382 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1383 -(void)windowDidBecomeMain:(id)sender
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1384 {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1385 _dw_event_handler([self window], nil, 13);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1386 }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1387 -(void)setMenu:(DWMenu *)input { windowmenu = input; [windowmenu retain]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1388 -(void)menuHandler:(id)sender
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1389 {
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
1390 [DWObj menuHandler:sender];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1391 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1392 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1393
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1394 @interface DWViewController : UIViewController
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1395 -(void)viewWillLayoutSubviews;
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1396 @end
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1397
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1398
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1399 @implementation DWViewController : UIViewController {}
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1400 -(void)viewWillLayoutSubviews
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1401 {
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1402 DWWindow *window = (DWWindow *)[[self view] window];
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1403 NSArray *array = [window subviews];
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1404 DWView *view = [array firstObject];
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
1405 CGRect frame = [window frame];
2401
010ae32a5067 iOS: Hide the UITransitionView that is attached to the UIWindow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2400
diff changeset
1406 /* Hide the UITransitionView which is blocking the screen...
010ae32a5067 iOS: Hide the UITransitionView that is attached to the UIWindow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2400
diff changeset
1407 * This is probably not the correct solution, but it solves the
010ae32a5067 iOS: Hide the UITransitionView that is attached to the UIWindow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2400
diff changeset
1408 * problem for the moment. Figure out what to do with this view.
010ae32a5067 iOS: Hide the UITransitionView that is attached to the UIWindow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2400
diff changeset
1409 */
010ae32a5067 iOS: Hide the UITransitionView that is attached to the UIWindow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2400
diff changeset
1410 id object = [array lastObject];
010ae32a5067 iOS: Hide the UITransitionView that is attached to the UIWindow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2400
diff changeset
1411 if(![object isMemberOfClass:[DWView class]])
010ae32a5067 iOS: Hide the UITransitionView that is attached to the UIWindow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2400
diff changeset
1412 [object setHidden:YES];
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
1413 /* Adjust the frame to account for the status bar */
2425
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
1414 NSInteger sbheight = [[[window windowScene] statusBarManager] statusBarFrame].size.height;
2409
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
1415 frame.size.height -= sbheight;
2425
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
1416 /* Account for the special area on iPhone X and iPad Pro
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
1417 * https://blog.maxrudberg.com/post/165590234593/ui-design-for-iphone-x-bottom-elements
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
1418 */
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
1419 frame.size.height -= 24;
2409
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
1420 frame.origin.y += sbheight;
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
1421 [view setFrame:frame];
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
1422 [view windowResized:frame.size];
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1423 }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1424 @end
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1425
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1426 #define _DW_BUTTON_TYPE_NORMAL 0
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1427 #define _DW_BUTTON_TYPE_CHECK 1
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1428 #define _DW_BUTTON_TYPE_RADIO 2
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1429
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1430 /* Subclass for a button type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1431 @interface DWButton : UIButton
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1432 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1433 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1434 DWBox *parent;
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1435 int type, state;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1436 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1437 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1438 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1439 -(void)buttonClicked:(id)sender;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1440 -(void)setParent:(DWBox *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1441 -(DWBox *)parent;
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1442 -(int)type;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1443 -(void)setType:(int)input;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1444 -(int)state;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1445 -(void)setState:(int)input;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1446 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1447
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1448 @implementation DWButton
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1449 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1450 -(void)setUserdata:(void *)input { userdata = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1451 -(void)buttonClicked:(id)sender
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1452 {
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1453 /* Toggle the button */
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1454 if(type == _DW_BUTTON_TYPE_CHECK)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1455 [self setState:(state ? FALSE : TRUE)];
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1456 else if(type == _DW_BUTTON_TYPE_RADIO)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1457 [self setState:TRUE];
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1458
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1459 _dw_event_handler(self, nil, 8);
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1460
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1461 /* If it is a radio button, uncheck all the other radio buttons in the box */
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1462 if(type == _DW_BUTTON_TYPE_RADIO)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1463 {
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1464 DWBox *viewbox = [self parent];
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1465 Box *thisbox = [viewbox box];
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1466 int z;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1467
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1468 for(z=0;z<thisbox->count;z++)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1469 {
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1470 if(thisbox->items[z].type != TYPEBOX)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1471 {
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1472 id object = thisbox->items[z].hwnd;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1473
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1474 if([object isMemberOfClass:[DWButton class]])
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1475 {
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1476 DWButton *button = object;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1477
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1478 if(button != self && [button type] == _DW_BUTTON_TYPE_RADIO)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1479 {
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1480 [button setState:FALSE];
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1481 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1482 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1483 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1484 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1485 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1486 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1487 -(void)setParent:(DWBox *)input { parent = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1488 -(DWBox *)parent { return parent; }
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1489 -(int)type { return type; }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1490 -(void)setType:(int)input { type = input; [self updateImage]; }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1491 -(void)updateImage
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1492 {
2424
6b302a8c856f iOS: Fix checked image not showing due to typo in image name.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2423
diff changeset
1493 NSString *imagename = nil;
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1494
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1495 switch(type)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1496 {
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1497 case _DW_BUTTON_TYPE_CHECK:
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1498 {
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1499
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1500 if(state)
2424
6b302a8c856f iOS: Fix checked image not showing due to typo in image name.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2423
diff changeset
1501 imagename = @"checkmark.square";
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1502 else
2424
6b302a8c856f iOS: Fix checked image not showing due to typo in image name.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2423
diff changeset
1503 imagename = @"square";
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1504 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1505 break;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1506 case _DW_BUTTON_TYPE_RADIO:
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1507 {
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1508 if(state)
2424
6b302a8c856f iOS: Fix checked image not showing due to typo in image name.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2423
diff changeset
1509 imagename = @"largecircle.fill.circle";
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1510 else
2424
6b302a8c856f iOS: Fix checked image not showing due to typo in image name.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2423
diff changeset
1511 imagename = @"circle";
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1512 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1513 break;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1514 }
2424
6b302a8c856f iOS: Fix checked image not showing due to typo in image name.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2423
diff changeset
1515 if(imagename)
6b302a8c856f iOS: Fix checked image not showing due to typo in image name.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2423
diff changeset
1516 {
6b302a8c856f iOS: Fix checked image not showing due to typo in image name.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2423
diff changeset
1517 UIImage *image = [UIImage systemImageNamed:imagename];
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1518 CGSize size = [image size];
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1519 [self setImage:image forState:UIControlStateNormal];
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1520 [self setTitleEdgeInsets:UIEdgeInsetsMake(0,size.width,0,0)];
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1521 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1522 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1523 -(int)state { return state; }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
1524 -(void)setState:(int)input { state = input; [self updateImage]; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1525 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1526 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1527
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1528 /* Subclass for a progress type */
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
1529 @interface DWPercent : UIProgressView
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1530 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1531 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1532 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1533 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1534 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1535 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1536
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1537 @implementation DWPercent
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1538 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1539 -(void)setUserdata:(void *)input { userdata = input; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1540 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1541 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1542
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1543 /* Subclass for a menu item type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1544 @implementation DWMenuItem
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1545 -(void)setCheck:(int)input { check = input; }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1546 -(void)setTag:(unsigned long)input { tag = input; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1547 -(int)check { return check; }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1548 -(unsigned long)tag { return tag; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1549 -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1550 @end
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1551 /*
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1552 * Encapsulate immutable objects in our own containers,
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1553 * so we can recreate the immutable subobjects as needed.
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1554 * Currently in this category: DWMenu and DWImage
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1555 */
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1556 @implementation DWMenu
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1557 -(void)setMenu:(UIMenu *)input { menu = input; }
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1558 -(UIMenu *)menu { return menu; }
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1559 -(DWMenuItem *)itemWithTag:(unsigned long)tag
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1560 {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1561 NSArray *children = [menu children];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1562
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1563 for(DWMenuItem *menuitem in children)
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1564 {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1565 if([menuitem tag] == tag)
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1566 return menuitem;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1567 }
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1568 return nil;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1569 }
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1570 -(void)dealloc { [super dealloc]; }
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1571 @end
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1572
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1573 @implementation DWImage
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1574 -(id)initWithSize:(CGSize)size
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1575 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1576 self = [super init];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1577 if(self)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1578 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1579 CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
1580 CGContextRef cgcontext = CGBitmapContextCreate(NULL, size.width, size.height, 8, 0, rgb, kCGImageAlphaPremultipliedFirst);
2438
f273dbf1312f iOS: Fix DWImage internal core graphics context being flipped.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2437
diff changeset
1581 CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, size.height);
f273dbf1312f iOS: Fix DWImage internal core graphics context being flipped.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2437
diff changeset
1582 CGContextConcatCTM(cgcontext, flipVertical);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1583 CGImageRef cgimage = CGBitmapContextCreateImage(cgcontext);
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1584 image = [UIImage imageWithCGImage:cgimage];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1585 CGContextRelease(cgcontext);
2437
929ce3cd18ea iOS: Fix bitblt and crashes due to missing retains.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2436
diff changeset
1586 [image retain];
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1587 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1588 return self;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1589 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1590 -(id)initWithCGImage:(CGImageRef)cgimage
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1591 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1592 self = [super init];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1593 if(self)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1594 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1595 image = [UIImage imageWithCGImage:cgimage];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1596 [image retain];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1597 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1598 return self;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1599 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1600 -(id)initWithUIImage:(UIImage *)newimage
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1601 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1602 self = [super init];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1603 if(self)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1604 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1605 image = newimage;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1606 [image retain];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1607 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1608 return self;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1609 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1610 -(void)setImage:(UIImage *)input
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1611 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1612 UIImage *oldimage = image;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1613 image = input;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1614 [image retain];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1615 [oldimage release];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1616 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1617 -(UIImage *)image
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1618 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1619 /* If our CGContext has been modified... */
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1620 if(cgcontext)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1621 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1622 UIImage *oldimage = image;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1623 CGImageRef cgimage;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1624
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1625 /* Create a new UIImage from the CGContext via CGImage */
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1626 cgimage = CGBitmapContextCreateImage(cgcontext);
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1627 image = [UIImage imageWithCGImage:cgimage];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1628 CGContextRelease(cgcontext);
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1629 cgcontext = nil;
2437
929ce3cd18ea iOS: Fix bitblt and crashes due to missing retains.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2436
diff changeset
1630 [image retain];
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1631 [oldimage release];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1632 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1633 return image;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1634 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1635 -(CGContextRef)cgcontext
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1636 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1637 /* If we don't have an active context, create a bitmap
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1638 * context and copy the image from our UIImage.
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1639 */
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1640 if(!cgcontext)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1641 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1642 CGSize size = [image size];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1643 CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1644
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
1645 cgcontext = CGBitmapContextCreate(NULL, size.width, size.height, 8, 0, rgb, kCGImageAlphaPremultipliedFirst);
2438
f273dbf1312f iOS: Fix DWImage internal core graphics context being flipped.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2437
diff changeset
1646 CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, size.height);
f273dbf1312f iOS: Fix DWImage internal core graphics context being flipped.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2437
diff changeset
1647 CGContextConcatCTM(cgcontext, flipVertical);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1648 CGContextDrawImage(cgcontext, CGRectMake(0,0,size.width,size.height), [image CGImage]);
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1649 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1650 return cgcontext;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1651 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
1652 -(void)dealloc { if(cgcontext) CGContextRelease(cgcontext); if(image) [image release]; [super dealloc]; }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1653 @end
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1654
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1655 /* Subclass for a scrollbox type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1656 @interface DWScrollBox : UIScrollView
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1657 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1658 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1659 id box;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1660 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1661 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1662 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1663 -(void)setBox:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1664 -(id)box;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1665 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1666
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1667 @implementation DWScrollBox
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1668 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1669 -(void)setUserdata:(void *)input { userdata = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1670 -(void)setBox:(void *)input { box = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1671 -(id)box { return box; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1672 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1673 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1674
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1675 @interface DWEntryFieldFormatter : NSFormatter
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1676 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1677 int maxLength;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1678 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1679 - (void)setMaximumLength:(int)len;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1680 - (int)maximumLength;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1681 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1682
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1683 /* This formatter subclass will allow us to limit
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1684 * the text length in an entryfield.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1685 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1686 @implementation DWEntryFieldFormatter
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1687 -(id)init
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1688 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1689 self = [super init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1690 maxLength = INT_MAX;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1691 return self;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1692 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1693 -(void)setMaximumLength:(int)len { maxLength = len; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1694 -(int)maximumLength { return maxLength; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1695 -(NSString *)stringForObjectValue:(id)object { return (NSString *)object; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1696 -(BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error { *object = string; return YES; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1697 -(BOOL)isPartialStringValid:(NSString **)partialStringPtr
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1698 proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1699 originalString:(NSString *)origString
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1700 originalSelectedRange:(NSRange)origSelRange
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1701 errorDescription:(NSString **)error
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1702 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1703 if([*partialStringPtr length] > maxLength)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1704 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1705 return NO;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1706 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1707 return YES;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1708 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1709 -(NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes { return nil; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1710 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1711
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1712 /* Subclass for a entryfield type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1713 @interface DWEntryField : UITextField
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1714 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1715 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1716 id clickDefault;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1717 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1718 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1719 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720 -(void)setClickDefault:(id)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1722
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1723 @implementation DWEntryField
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1724 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1725 -(void)setUserdata:(void *)input { userdata = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1726 -(void)setClickDefault:(id)input { clickDefault = input; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1727 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1728 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1729
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1730 /* Subclass for a text and status text type */
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
1731 @interface DWText : UILabel
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1732 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1733 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1734 id clickDefault;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1735 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1736 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1737 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1738 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1739
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1740 @implementation DWText
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1741 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1742 -(void)setUserdata:(void *)input { userdata = input; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1743 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1744 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1745
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1746 /* Subclass for a Notebook page type */
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1747 @interface DWNotebookPage : DWBox
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1748 {
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1749 int pageid;
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1750 }
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1751 -(int)pageid;
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1752 -(void)setPageid:(int)input;
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1753 @end
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1754
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1755 /* Subclass for a Notebook control type */
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1756 @interface DWNotebook : UIView
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1757 {
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1758 UISegmentedControl *tabs;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1759 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1760 int pageid;
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1761 NSMutableArray<DWNotebookPage *> *views;
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1762 DWNotebookPage *visible;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1763 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1764 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1765 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1766 -(int)pageid;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1767 -(void)setPageid:(int)input;
2420
384d076ed52a iOS: Minor fix for initial notebook page remaining visible on page change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2419
diff changeset
1768 -(void)setVisible:(DWNotebookPage *)input;
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1769 -(UISegmentedControl *)tabs;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1770 -(NSMutableArray<DWNotebookPage *> *)views;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1771 -(void)pageChanged:(id)sender;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1772 @end
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1773
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774 @implementation DWNotebook
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1775 -(id)init {
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1776 self = [super init];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1777 tabs = [[[UISegmentedControl alloc] init] retain];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1778 views = [[[NSMutableArray alloc] init] retain];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1779 [self addSubview:tabs];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1780 return self;
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1781 }
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1782 -(void)setFrame:(CGRect)frame {
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1783 [super setFrame:frame];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1784 frame.size.height = 40;
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1785 [tabs setFrame:frame];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1786 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1787 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 -(void)setUserdata:(void *)input { userdata = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789 -(int)pageid { return pageid; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 -(void)setPageid:(int)input { pageid = input; }
2420
384d076ed52a iOS: Minor fix for initial notebook page remaining visible on page change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2419
diff changeset
1791 -(void)setVisible:(DWNotebookPage *)input { visible = input; }
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1792 -(UISegmentedControl *)tabs { return tabs; }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1793 -(NSMutableArray<DWNotebookPage *> *)views { return views; };
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
1794 -(void)pageChanged:(id)sender
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
1795 {
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1796 NSInteger intpageid = [tabs selectedSegmentIndex];
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1797
2419
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
1798 if(intpageid != -1 && intpageid < [views count])
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1799 {
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1800 DWNotebookPage *page = [views objectAtIndex:intpageid];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1801
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1802 /* Hide the previously visible page contents */
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1803 if(page != visible)
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1804 [visible setHidden:YES];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1805
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1806 /* If the new page is a valid box, lay it out */
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1807 if([page isKindOfClass:[DWBox class]])
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1808 {
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1809 Box *box = [page box];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1810 /* Start with the entire notebook size and then adjust
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1811 * it to account for the segement control's height.
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1812 */
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1813 NSInteger height = [tabs frame].size.height;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1814 CGRect frame = [self frame];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1815 frame.origin.y += height;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1816 frame.size.height -= height;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1817 [page setFrame:frame];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1818 [page setHidden:NO];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1819 visible = page;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1820 _dw_do_resize(box, frame.size.width, frame.size.height);
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1821 _dw_handle_resize_events(box);
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1822 }
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1823 _dw_event_handler(self, DW_INT_TO_POINTER(intpageid), 15);
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
1824 }
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1825 }
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1826 -(void)dealloc {
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1827 UserData *root = userdata;
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1828 _dw_remove_userdata(&root, NULL, TRUE);
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1829 dw_signal_disconnect_by_window(self);
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1830 [tabs release];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1831 [views release];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1832 [super dealloc];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
1833 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1834 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1835
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1836 @implementation DWNotebookPage
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 -(int)pageid { return pageid; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 -(void)setPageid:(int)input { pageid = input; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1839 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1840 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1841
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1842 /* Subclass for a splitbar type */
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1843 @interface DWSplitBar : UISplitViewController <UISplitViewControllerDelegate>
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1844 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1845 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1846 float percent;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1847 NSInteger Tag;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1848 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1849 -(void)splitViewDidResizeSubviews:(NSNotification *)aNotification;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1850 -(void)setTag:(NSInteger)tag;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1851 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1852 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1853 -(float)percent;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1854 -(void)setPercent:(float)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1855 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1856
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1857 @implementation DWSplitBar
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1858 -(void)splitViewDidResizeSubviews:(NSNotification *)aNotification
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1859 {
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
1860 NSArray *views = [self.view subviews];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1861 id object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1862
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1863 for(object in views)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1864 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1865 if([object isMemberOfClass:[DWBox class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1866 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1867 DWBox *view = object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1868 Box *box = [view box];
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
1869 CGSize size = [view frame].size;
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1870 _dw_do_resize(box, size.width, size.height);
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1871 _dw_handle_resize_events(box);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1872 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1873 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1874 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1875 -(void)setTag:(NSInteger)tag { Tag = tag; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1876 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1877 -(void)setUserdata:(void *)input { userdata = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1878 -(float)percent { return percent; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1879 -(void)setPercent:(float)input { percent = input; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1880 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1881 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1882
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1883 /* Subclass for a slider type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1884 @interface DWSlider : UISlider
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1885 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1886 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1887 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1888 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1889 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1890 -(void)sliderChanged:(id)sender;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1891 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1892
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1893 @implementation DWSlider
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1894 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1895 -(void)setUserdata:(void *)input { userdata = input; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1896 -(void)sliderChanged:(id)sender { int intVal = (int)[self value]; _dw_event_handler(self, DW_INT_TO_POINTER(intVal), 14); }
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1897 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1898 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1899
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1900 /* Subclass for a MLE type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1901 @interface DWMLE : UITextView
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1902 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1903 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1904 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1905 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1906 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1907 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1908
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1909 @implementation DWMLE
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1910 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1911 -(void)setUserdata:(void *)input { userdata = input; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1912 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1913 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1914
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
1915 /* TODO: UITableView does not support variable columns...
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
1916 * also OutlineView does not exist in iOS.
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
1917 */
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
1918 UITableViewCell *_dw_table_cell_view_new(UIImage *icon, NSString *text)
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
1919 {
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
1920 UITableViewCell *browsercell = [[[UITableViewCell alloc] init] autorelease];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1921 [browsercell setAutoresizesSubviews:YES];
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
1922
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1923 if(icon)
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
1924 [[browsercell imageView] setImage:icon];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1925 if(text)
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
1926 [[browsercell textLabel] setText:text];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1927 return browsercell;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1928 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1929
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1930 /* Subclass for a Container/List type */
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
1931 @interface DWContainer : UITableView <UITableViewDataSource,UITableViewDelegate>
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1932 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1933 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1934 NSMutableArray *tvcols;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1935 NSMutableArray *data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1936 NSMutableArray *types;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1937 NSPointerArray *titles;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1938 NSPointerArray *rowdatas;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1939 UIColor *fgcolor, *oddcolor, *evencolor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1940 unsigned long dw_oddcolor, dw_evencolor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1941 unsigned long _DW_COLOR_ROW_ODD, _DW_COLOR_ROW_EVEN;
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
1942 int iLastAddPoint, iLastQueryPoint;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1943 int filesystem;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1944 }
2387
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
1945 -(NSInteger)tableView:(UITableView *)aTable numberOfRowsInSection:(NSInteger)section;
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
1946 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
1947 -(void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath;
2387
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
1948 -(void)addColumn:(NSString *)input andType:(int)type;
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
1949 -(NSString *)getColumn:(int)col;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1950 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1951 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1952 -(void)setFilesystem:(int)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953 -(int)filesystem;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1954 -(int)addRow:(NSArray *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1955 -(int)addRows:(int)number;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1956 -(void)editCell:(id)input at:(int)row and:(int)col;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1957 -(void)removeRow:(int)row;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1958 -(void)setRow:(int)row title:(const char *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1959 -(void *)getRowTitle:(int)row;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1960 -(id)getRow:(int)row and:(int)col;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1961 -(int)cellType:(int)col;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1962 -(int)lastAddPoint;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1963 -(int)lastQueryPoint;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1964 -(void)setLastQueryPoint:(int)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1965 -(void)clear;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1966 -(void)setup;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
1967 -(CGSize)getsize;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1968 -(void)setForegroundColor:(UIColor *)input;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
1969 -(DWMenu *)menuForEvent:(UIEvent *)event;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1970 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1971
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1972 @implementation DWContainer
2387
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
1973 -(NSInteger)tableView:(UITableView *)aTable numberOfRowsInSection:(NSInteger)section
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
1974 {
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
1975 /* Ignoring section for now, everything in one section */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1976 if(tvcols && data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1977 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1978 int cols = (int)[tvcols count];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1979 int total = (int)[data count];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1980 if(cols && total)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1981 return total / cols;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1982 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1983 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1984 }
2387
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
1985 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1986 {
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1987 /* Not reusing cell views, so get the cell from our array */
2387
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
1988 int index = (int)(indexPath.row * [tvcols count]);
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1989 id celldata = [data objectAtIndex:index];
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1990
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1991 /* The data is already a NSTableCellView so just return that */
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1992 if([celldata isMemberOfClass:[UITableViewCell class]])
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1993 {
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1994 UITableViewCell *result = celldata;
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1995
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1996 /* Copy the alignment setting from the column,
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1997 * and set the text color from the container.
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
1998 */
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
1999 if(fgcolor)
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
2000 [[result textLabel] setTextColor:fgcolor];
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
2001
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
2002 /* Return the result */
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
2003 return result;
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
2004 }
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
2005 return nil;
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
2006 }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2007 -(void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath
2387
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2008 {
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2009 if(indexPath.row % 2 == 0)
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2010 {
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2011 if(evencolor)
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2012 [cell setBackgroundColor:evencolor];
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2013 }
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2014 else
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2015 {
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2016 if(oddcolor)
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2017 [cell setBackgroundColor:oddcolor];
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2018 }
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2019 }
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2020 -(void)addColumn:(NSString *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } }
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2021 -(NSString *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2022 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 -(void)setUserdata:(void *)input { userdata = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2024 -(void)setFilesystem:(int)input { filesystem = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2025 -(int)filesystem { return filesystem; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2026 -(void)refreshColors
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2027 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2028 UIColor *oldodd = oddcolor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2029 UIColor *oldeven = evencolor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2030 unsigned long thisodd = dw_oddcolor == DW_CLR_DEFAULT ? _DW_COLOR_ROW_ODD : dw_oddcolor;
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2031 unsigned long _odd = _dw_get_color(thisodd);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2032 unsigned long thiseven = dw_evencolor == DW_CLR_DEFAULT ? _DW_COLOR_ROW_EVEN : dw_evencolor;
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2033 unsigned long _even = _dw_get_color(thiseven);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2034
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035 /* Get the UIColor for non-default colors */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 if(thisodd != DW_RGB_TRANSPARENT)
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
2037 oddcolor = [[UIColor colorWithRed: DW_RED_VALUE(_odd)/255.0 green: DW_GREEN_VALUE(_odd)/255.0 blue: DW_BLUE_VALUE(_odd)/255.0 alpha: 1] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2039 oddcolor = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040 if(thiseven != DW_RGB_TRANSPARENT)
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
2041 evencolor = [[UIColor colorWithRed: DW_RED_VALUE(_even)/255.0 green: DW_GREEN_VALUE(_even)/255.0 blue: DW_BLUE_VALUE(_even)/255.0 alpha: 1] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2042 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2043 evencolor = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2044 [oldodd release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2045 [oldeven release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2046 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2047 -(void)setRowBgOdd:(unsigned long)oddcol andEven:(unsigned long)evencol
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2048 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2049 /* Save the set colors in case we get a theme change */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2050 dw_oddcolor = oddcol;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2051 dw_evencolor = evencol;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2052 [self refreshColors];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2053 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2054 -(void)checkDark
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2055 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2056 /* Update any system colors based on the Dark Mode */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2057 _DW_COLOR_ROW_EVEN = DW_RGB_TRANSPARENT;
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
2058 if(_dw_is_dark())
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
2059 _DW_COLOR_ROW_ODD = DW_RGB(100, 100, 100);
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
2060 else
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
2061 _DW_COLOR_ROW_ODD = DW_RGB(230, 230, 230);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2062 /* Only refresh if we've been setup already */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2063 if(titles)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2064 [self refreshColors];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2065 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2066 -(void)viewDidChangeEffectiveAppearance { [self checkDark]; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2067 -(int)insertRow:(NSArray *)input at:(int)index
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2068 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2069 if(data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2070 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2071 unsigned long start = [tvcols count] * index;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2072 NSIndexSet *set = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(start, start + [tvcols count])];
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2073 if(index < iLastAddPoint)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2074 {
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2075 iLastAddPoint++;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2076 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2077 [data insertObjects:input atIndexes:set];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2078 [titles insertPointer:NULL atIndex:index];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2079 [rowdatas insertPointer:NULL atIndex:index];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2080 [set release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2081 return (int)[titles count];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2082 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2083 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2084 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2085 -(int)addRow:(NSArray *)input
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2086 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2087 if(data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2088 {
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2089 iLastAddPoint = (int)[titles count];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2090 [data addObjectsFromArray:input];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2091 [titles addPointer:NULL];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2092 [rowdatas addPointer:NULL];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2093 return (int)[titles count];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2094 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2095 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2096 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2097 -(int)addRows:(int)number
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2098 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2099 if(tvcols)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2100 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2101 int count = (int)(number * [tvcols count]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2102 int z;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2103
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2104 iLastAddPoint = (int)[titles count];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2105
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2106 for(z=0;z<count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2107 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2108 [data addObject:[NSNull null]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2109 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2110 for(z=0;z<number;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2111 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2112 [titles addPointer:NULL];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2113 [rowdatas addPointer:NULL];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2114 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2115 return (int)[titles count];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2116 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2117 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2118 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2119 -(void)editCell:(id)input at:(int)row and:(int)col
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2120 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 if(tvcols)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2122 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2123 int index = (int)(row * [tvcols count]) + col;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2124 if(index < [data count])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2125 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126 if(!input)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2127 input = [NSNull null];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2128 [data replaceObjectAtIndex:index withObject:input];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2129 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2130 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2131 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 -(void)removeRow:(int)row
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2133 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2134 if(tvcols)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2135 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2136 int z, start, end;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2137 int count = (int)[tvcols count];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2138 void *oldtitle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2139
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2140 start = (count * row);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2141 end = start + count;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2142
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143 for(z=start;z<end;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2144 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145 [data removeObjectAtIndex:start];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2147 oldtitle = [titles pointerAtIndex:row];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2148 [titles removePointerAtIndex:row];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2149 [rowdatas removePointerAtIndex:row];
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2150 if(iLastAddPoint > 0 && iLastAddPoint > row)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2151 {
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2152 iLastAddPoint--;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2153 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2154 if(oldtitle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2155 free(oldtitle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2156 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2157 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2158 -(void)setRow:(int)row title:(const char *)input
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2159 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2160 if(titles && input)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2161 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2162 void *oldtitle = [titles pointerAtIndex:row];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2163 void *newtitle = input ? (void *)strdup(input) : NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2164 [titles replacePointerAtIndex:row withPointer:newtitle];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2165 if(oldtitle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2166 free(oldtitle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2167 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2168 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2169 -(void)setRowData:(int)row title:(void *)input { if(rowdatas && input) { [rowdatas replacePointerAtIndex:row withPointer:input]; } }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2170 -(void *)getRowTitle:(int)row { if(titles && row > -1) { return [titles pointerAtIndex:row]; } return NULL; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2171 -(void *)getRowData:(int)row { if(rowdatas && row > -1) { return [rowdatas pointerAtIndex:row]; } return NULL; }
2387
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
2172 -(id)getRow:(int)row and:(int)col { if(data && [data count]) { int index = (int)(row * [tvcols count]) + col; return [data objectAtIndex:index]; } return nil; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2173 -(int)cellType:(int)col { return [[types objectAtIndex:col] intValue]; }
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2174 -(int)lastAddPoint { return iLastAddPoint; }
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2175 -(int)lastQueryPoint { return iLastQueryPoint; }
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2176 -(void)setLastQueryPoint:(int)input { iLastQueryPoint = input; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2177 -(void)clear
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2178 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2179 if(data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2180 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2181 [data removeAllObjects];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2182 while([titles count])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2183 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2184 void *oldtitle = [titles pointerAtIndex:0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2185 [titles removePointerAtIndex:0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2186 [rowdatas removePointerAtIndex:0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2187 if(oldtitle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2188 free(oldtitle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2189 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2190 }
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
2191 iLastAddPoint = 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2192 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2193 -(void)setup
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2194 {
2389
7b06fc7c8130 iOS: Remove some legacy code from macOS 10.5 by swithing to using
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2388
diff changeset
2195 titles = [[NSPointerArray pointerArrayWithOptions:NSPointerFunctionsOpaqueMemory] retain];
7b06fc7c8130 iOS: Remove some legacy code from macOS 10.5 by swithing to using
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2388
diff changeset
2196 rowdatas = [[NSPointerArray pointerArrayWithOptions:NSPointerFunctionsOpaqueMemory] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2197 tvcols = [[[NSMutableArray alloc] init] retain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2198 data = [[[NSMutableArray alloc] init] retain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2199 types = [[[NSMutableArray alloc] init] retain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2200 if(!dw_oddcolor && !dw_evencolor)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2201 dw_oddcolor = dw_evencolor = DW_CLR_DEFAULT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2202 [self checkDark];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2203 }
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
2204 -(CGSize)getsize
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2205 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2206 int cwidth = 0, cheight = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2207
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2208 if(tvcols)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2209 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2210 int colcount = (int)[tvcols count];
2388
d84cd4227b21 iOS: Switch to UITableViewDataSource method numberOfRowsInSection:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2387
diff changeset
2211 int rowcount = (int)[self numberOfRowsInSection:0];
2426
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2212 int width = 0;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2213
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2214 if(rowcount > 0)
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2215 {
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2216 int x;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2217
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2218 for(x=0;x<rowcount;x++)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219 {
2426
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2220 UITableViewCell *cell = [data objectAtIndex:(x*colcount)];
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2221 int thiswidth = 4, thisheight = 0;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2222
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2223 if([cell imageView])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2224 {
2426
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2225 thiswidth += [[cell imageView] image].size.width;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2226 thisheight = [[cell imageView] image].size.height;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2227 }
2426
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2228 if([cell textLabel])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229 {
2426
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2230 int textheight = [[cell textLabel] intrinsicContentSize].width;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2231 thiswidth += [[cell textLabel] intrinsicContentSize].width;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2232 if(textheight > thisheight)
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2233 thisheight = textheight;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2234 }
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2235
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2236 cheight += thisheight;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2237
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2238 if(thiswidth > width)
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2239 {
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2240 width = thiswidth;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2241 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2242 }
2426
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2243 /* If the image is missing default the optimized width to 16. */
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2244 if(!width && [[types objectAtIndex:0] intValue] & DW_CFA_BITMAPORICON)
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2245 {
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2246 width = 16;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2247 }
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2248 }
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2249 if(width)
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2250 cwidth += width;
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2251 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252 cwidth += 16;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2253 cheight += 16;
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
2254 return CGSizeMake(cwidth, cheight);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2255 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2256 -(void)setForegroundColor:(UIColor *)input
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2257 {
2426
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2258 UIColor *oldfgcolor = fgcolor;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2259
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2260 fgcolor = input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2261 [fgcolor retain];
2426
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2262 [oldfgcolor release];
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2263 }
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2264 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2265 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2266 void *params[2];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2267
2426
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2268 params[0] = (void *)[self getRowTitle:(int)indexPath.row];
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2269 params[1] = (void *)[self getRowData:(int)indexPath.row];
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2270
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2271 /* If multiple selection is enabled, treat it as selectionChanged: */
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2272 if([self allowsMultipleSelection])
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2273 {
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2274 /* Handler for container class */
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2275 _dw_event_handler(self, (UIEvent *)params, 12);
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2276 /* Handler for listbox class */
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2277 _dw_event_handler(self, DW_INT_TO_POINTER((int)indexPath.row), 11);
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2278 }
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2279 else /* Otherwise treat it as doubleClicked: */
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2280 {
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2281 /* Handler for container class */
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2282 _dw_event_handler(self, (UIEvent *)params, 9);
6220f0580088 iOS: DWContainer attempt to get touch and selection handlers working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2425
diff changeset
2283 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2284 }
2458
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
2285 -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
2286 {
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
2287 if([self allowsMultipleSelection])
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
2288 [self tableView:tableView didSelectRowAtIndexPath:indexPath];
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
2289 }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
2290 -(DWMenu *)menuForEvent:(UIEvent *)event
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2291 {
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
2292 #if 0 /* TODO: Fix this */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2293 int row;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
2294 CGPoint where = [self convertPoint:[event locationInWindow] fromView:nil];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2295 row = (int)[self rowAtPoint:where];
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2296 _dw_event_handler(self, (UIEvent *)[self getRowTitle:row], 10);
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
2297 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298 return nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2300 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 /* Subclass for a Calendar type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 @interface DWCalendar : UIDatePicker
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2306 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2310 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2312 @implementation DWCalendar
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2313 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2314 -(void)setUserdata:(void *)input { userdata = input; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2315 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2316 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2317
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2318 /* Subclass for a stepper component of the spinbutton type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2319 /* This is a bad way of doing this... but I can't get the other methods to work */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2320 @interface DWStepper : UIStepper
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2321 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2322 id textfield;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2323 id parent;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2324 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2325 -(void)setTextfield:(id)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2326 -(id)textfield;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2327 -(void)setParent:(id)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 -(id)parent;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2330
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 @implementation DWStepper
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 -(void)setTextfield:(id)input { textfield = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333 -(id)textfield { return textfield; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2334 -(void)setParent:(id)input { parent = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335 -(id)parent { return parent; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2336 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2338 /* Subclass for a Spinbutton type */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339 @interface DWSpinButton : UIView <UITextFieldDelegate>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2341 void *userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2342 UITextField *textfield;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2343 DWStepper *stepper;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2344 id clickDefault;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2346 -(id)init;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347 -(void *)userdata;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2348 -(void)setUserdata:(void *)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2349 -(UITextField *)textfield;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2350 -(UIStepper *)stepper;
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2351 -(void)textFieldDidEndEditing:(UITextField *)textField;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2352 -(void)setClickDefault:(id)input;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2353 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2354
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2355 @implementation DWSpinButton
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2356 -(id)init
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2357 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2358 self = [super init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2359
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360 if(self)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2361 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2362 textfield = [[[UITextField alloc] init] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2363 [self addSubview:textfield];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2364 stepper = [[[DWStepper alloc] init] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2365 [self addSubview:stepper];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2366 [stepper setParent:self];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2367 [stepper setTextfield:textfield];
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
2368 [textfield setText:[NSString stringWithFormat:@"%ld",(long)[stepper value]]];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2369 [textfield setDelegate:self];
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2370 [stepper addTarget:self action:@selector(stepperChanged:) forControlEvents:UIControlEventValueChanged];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2371 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2372 return self;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2373 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2374 -(void *)userdata { return userdata; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2375 -(void)setUserdata:(void *)input { userdata = input; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2376 -(UITextField *)textfield { return textfield; }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2377 -(UIStepper *)stepper { return stepper; }
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2378 -(void)textFieldDidEndEditing:(UITextField *)textField
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2379 {
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
2380 long val = [[textfield text] intValue];
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
2381 [stepper setValue:(float)val];
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2382 [textfield setText:[NSString stringWithFormat:@"%d", (int)[stepper value]]];
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2383 _dw_event_handler(self, DW_INT_TO_POINTER((int)[stepper value]), 14);
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2384 }
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2385 -(void)stepperChanged:(UIStepper*)theStepper
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2386 {
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2387 [textfield setText:[NSString stringWithFormat:@"%d", (int)[theStepper value]]];
2443
42ba334cb8f7 iOS: DWSpinButton needs to generate events on stepper changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2442
diff changeset
2388 _dw_event_handler(self, DW_INT_TO_POINTER((int)[stepper value]), 14);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2389 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2390 -(void)setClickDefault:(id)input { clickDefault = input; }
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2391 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2392 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2393
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2394 API_AVAILABLE(ios(10.0))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2395 @interface DWUserNotificationCenterDelegate : NSObject <UNUserNotificationCenterDelegate>
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2396 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2397
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2398 @implementation DWUserNotificationCenterDelegate
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2399 /* Called when a notification is delivered to a foreground app. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2400 -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler API_AVAILABLE(macos(10.14))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2401 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2402 completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2403 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2404 /* Called to let your app know which action was selected by the user for a given notification. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2405 -(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler API_AVAILABLE(macos(10.14))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2406 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2407 NSScanner *objScanner = [NSScanner scannerWithString:response.notification.request.identifier];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2408 unsigned long long handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2409 HWND notification;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2410
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2411 /* Skip the dw-notification- prefix */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2412 [objScanner scanString:@"dw-notification-" intoString:nil];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2413 [objScanner scanUnsignedLongLong:&handle];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2414 notification = DW_UINT_TO_POINTER(handle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2415
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2416 if ([response.actionIdentifier isEqualToString:UNNotificationDismissActionIdentifier])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2417 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2418 /* The user dismissed the notification without taking action. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2419 dw_signal_disconnect_by_window(notification);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2420 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2421 else if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2422 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2423 /* The user launched the app. */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2424 _dw_event_handler(notification, nil, 8);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2425 dw_signal_disconnect_by_window(notification);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2426 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2427 completionHandler();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2428 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2429 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2430
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2431 @interface DWComboBox : UITextField <UIPickerViewDelegate,UIPickerViewDataSource,UITextFieldDelegate>
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2432 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2433 UIPickerView* pickerView;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2434 NSMutableArray* dataArray;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2435 UIBarStyle toolbarStyle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2436 int selectedIndex;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2437 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2438 -(void)setToolbarStyle:(UIBarStyle)style;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2439 -(void)append:(NSString *)item;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2440 -(void)insert:(NSString *)item atIndex:(int)index;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2441 -(void)clear;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2442 -(int)count;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2443 -(NSString *)getTextAtIndex:(int)index;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2444 -(void)setText:(NSString *)item atIndex:(int)index;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2445 -(void)deleteAtIndex:(int)index;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2446 -(int)selectedIndex;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2447 @end
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2448
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2449 @implementation DWComboBox
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2450 -(id)init
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2451 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2452 self = [super init];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2453 if(self)
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2454 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2455 [self setDelegate:self];
2433
87669cfe3c92 iOS: Combobox remove code to hide the input caret. Also fix the cancel button.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2432
diff changeset
2456
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2457 /* Set UI defaults */
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2458 toolbarStyle = UIBarStyleDefault;
2442
725a6fbb44cd iOS: DWComboBox needs to initialize the array so the list works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2440
diff changeset
2459 dataArray = [[NSMutableArray alloc] init];
2433
87669cfe3c92 iOS: Combobox remove code to hide the input caret. Also fix the cancel button.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2432
diff changeset
2460
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2461 /* Setup the arrow image */
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2462 UIButton *imageButton = [UIButton buttonWithType:UIButtonTypeCustom];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2463 UIImage *image = [UIImage systemImageNamed:@"chevron.down"];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2464 [imageButton setImage:image forState:UIControlStateNormal];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2465 [self setRightView:imageButton];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2466 [self setRightViewMode:UITextFieldViewModeAlways];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2467 [imageButton addTarget:self action:@selector(showPicker:) forControlEvents:UIControlEventTouchUpInside];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2468 selectedIndex = -1;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2469 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2470 return self;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2471 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2472 -(void)setToolbarStyle:(UIBarStyle)style { toolbarStyle = style; }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2473 -(void)append:(NSString *)item { if(item) [dataArray addObject:item]; }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2474 -(void)insert:(NSString *)item atIndex:(int)index { if(item) [dataArray insertObject:item atIndex:index]; }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2475 -(void)clear { [dataArray removeAllObjects]; }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2476 -(int)count { return (int)[dataArray count]; }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2477 -(NSString *)getTextAtIndex:(int)index
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2478 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2479 if(index > -1 && index < [dataArray count])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2480 return [dataArray objectAtIndex:index];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2481 return nil;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2482 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2483 -(void)setText:(NSString *)item atIndex:(int)index
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2484 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2485 if(item && index > -1 && index < [dataArray count])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2486 [dataArray replaceObjectAtIndex:index withObject:item];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2487 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2488 -(void)deleteAtIndex:(int)index { if(index > -1 && index < [dataArray count]) [dataArray removeObjectAtIndex:index]; }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2489 -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2490 -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2491 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2492 selectedIndex = (int)row;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2493 [self setText:[dataArray objectAtIndex:row]];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2494 [self sendActionsForControlEvents:UIControlEventValueChanged];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2495 _dw_event_handler(self, DW_INT_TO_POINTER(selectedIndex), 11);
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2496 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2497 -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return [dataArray count]; }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2498 -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2499 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2500 return [dataArray objectAtIndex:row];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2501 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2502 -(void)doneClicked:(id)sender
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2503 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2504 /* Hides the pickerView */
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2505 [self resignFirstResponder];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2506
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2507 if([[self text] length] == 0 || ![dataArray containsObject:[self text]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2508 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2509 selectedIndex = -1;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2510 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2511 [self sendActionsForControlEvents:UIControlEventValueChanged];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2512 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2513 -(void)cancelClicked:(id)sender
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2514 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2515 /* Hides the pickerView */
2433
87669cfe3c92 iOS: Combobox remove code to hide the input caret. Also fix the cancel button.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2432
diff changeset
2516 [self resignFirstResponder];
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2517 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2518 -(void)showPicker:(id)sender
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2519 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2520 pickerView = [[UIPickerView alloc] init];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2521 [pickerView setDataSource:self];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2522 [pickerView setDelegate:self];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2523
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2524 /* If the text field is empty show the place holder otherwise show the last selected option */
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2525 if([[self text] length] == 0 || ![dataArray containsObject:[self text]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2526 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2527 [pickerView selectRow:0 inComponent:0 animated:YES];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2528 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2529 else
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2530 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2531 if([dataArray containsObject:[self text]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2532 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2533 [pickerView selectRow:[dataArray indexOfObject:[self text]] inComponent:0 animated:YES];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2534 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2535 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2536
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2537 UIToolbar* toolbar = [[UIToolbar alloc] init];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2538 [toolbar setBarStyle:toolbarStyle];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2539 [toolbar sizeToFit];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2540
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2541 /* Space between buttons */
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2542 UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2543 target:nil
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2544 action:nil];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2545
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2546 UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2547 initWithTitle:@"Done"
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2548 style:UIBarButtonItemStyleDone
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2549 target:self
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2550 action:@selector(doneClicked:)];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2551
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2552 UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2553 initWithTitle:@"Cancel"
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2554 style:UIBarButtonItemStylePlain
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2555 target:self
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2556 action:@selector(cancelClicked:)];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2557
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2558 [toolbar setItems:[NSArray arrayWithObjects:cancelButton, flexibleSpace, doneButton, nil]];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2559
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2560 /* Custom input view */
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2561 [self setInputView:pickerView];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2562 [self setInputAccessoryView:toolbar];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2563 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2564 -(int)selectedIndex { return selectedIndex; }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2565 @end
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
2566
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2567 /* Subclass for a MDI type
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2568 * This is just a box for display purposes... but it is a
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2569 * unique class so it can be identified when creating windows.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2570 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2571 @interface DWMDI : DWBox {}
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2572 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2573
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2574 @implementation DWMDI
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2575 @end
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2576
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 /* This function adds a signal handler callback into the linked list.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2578 */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2579 void _dw_new_signal(ULONG message, HWND window, int msgid, void *signalfunction, void *discfunc, void *data)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2580 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 SignalHandler *new = malloc(sizeof(SignalHandler));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2583 new->message = message;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584 new->window = window;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2585 new->id = msgid;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2586 new->signalfunction = signalfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2587 new->discfunction = discfunc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2588 new->data = data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2589 new->next = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2590
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
2591 if (!DWRoot)
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
2592 DWRoot = new;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2593 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2594 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
2595 SignalHandler *prev = NULL, *tmp = DWRoot;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 while(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2597 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598 if(tmp->message == message &&
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 tmp->window == window &&
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 tmp->id == msgid &&
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601 tmp->signalfunction == signalfunction)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2602 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603 tmp->data = data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2604 free(new);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2605 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2606 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2607 prev = tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2608 tmp = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2609 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2610 if(prev)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 prev->next = new;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612 else
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
2613 DWRoot = new;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2617 /* Finds the message number for a given signal name */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2618 ULONG _dw_findsigmessage(const char *signame)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2619 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2620 int z;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2621
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2622 for(z=0;z<SIGNALMAX;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2623 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
2624 if(strcasecmp(signame, DWSignalTranslate[z].name) == 0)
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
2625 return DWSignalTranslate[z].message;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2626 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627 return 0L;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
2630 unsigned long _dw_foreground = 0xAAAAAA, _dw_background = 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2632 void _dw_handle_resize_events(Box *thisbox)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2633 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 int z;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2635
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636 for(z=0;z<thisbox->count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2638 id handle = thisbox->items[z].hwnd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2639
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2640 if(thisbox->items[z].type == TYPEBOX)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2641 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2642 Box *tmp = (Box *)[handle box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2643
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2644 if(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2645 {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2646 _dw_handle_resize_events(tmp);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2647 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2648 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2649 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2650 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2651 if([handle isMemberOfClass:[DWRender class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2652 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2653 DWRender *render = (DWRender *)handle;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
2654 CGSize oldsize = [render size];
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
2655 CGSize newsize = [render frame].size;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2656
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2657 /* Eliminate duplicate configure requests */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2658 if(oldsize.width != newsize.width || oldsize.height != newsize.height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2659 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2660 if(newsize.width > 0 && newsize.height > 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2661 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2662 [render setSize:newsize];
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2663 _dw_event_handler(handle, nil, 1);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2664 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2665 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2666 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2667 /* Special handling for notebook controls */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2668 else if([handle isMemberOfClass:[DWNotebook class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2669 {
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2670 DWNotebook *notebook = handle;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2671 NSInteger intpageid = [[notebook tabs] selectedSegmentIndex];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2672
2419
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2673 if(intpageid != -1 && intpageid < [[notebook views] count])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2674 {
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2675 DWNotebookPage *page = [[notebook views] objectAtIndex:intpageid];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2676
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2677 if([page isKindOfClass:[DWBox class]])
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2678 {
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2679 Box *box = [page box];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2680 _dw_handle_resize_events(box);
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2681 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2682 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2683 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2684 /* Handle laying out scrollviews... if required space is less
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2685 * than available space, then expand. Otherwise use required space.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2686 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2687 else if([handle isMemberOfClass:[DWScrollBox class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2688 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2689 DWScrollBox *scrollbox = (DWScrollBox *)handle;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2690 NSArray *subviews = [scrollbox subviews];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2691 DWBox *contentbox = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2692 Box *thisbox = [contentbox box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2693
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2694 /* Get the required space for the box */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2695 _dw_handle_resize_events(thisbox);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2696 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2697 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2698 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2699 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2700
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2701 /* This function calculates how much space the widgets and boxes require
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2702 * and does expansion as necessary.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2703 */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2704 static void _dw_resize_box(Box *thisbox, int *depth, int x, int y, int pass)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2705 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2706 /* Current item position */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2707 int z, currentx = thisbox->pad, currenty = thisbox->pad;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2708 /* Used x, y and padding maximum values...
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2709 * These will be used to find the widest or
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2710 * tallest items in a box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2711 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2712 int uymax = 0, uxmax = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2713 int upymax = 0, upxmax = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2714
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2715 /* Reset the box sizes */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2716 thisbox->minwidth = thisbox->minheight = thisbox->usedpadx = thisbox->usedpady = thisbox->pad * 2;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2717
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2718 /* Count up all the space for all items in the box */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2719 for(z=0;z<thisbox->count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2720 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2721 int itempad, itemwidth, itemheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2722
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2723 if(thisbox->items[z].type == TYPEBOX)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2724 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2725 id box = thisbox->items[z].hwnd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2726 Box *tmp = (Box *)[box box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2727
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2728 if(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2729 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2730 /* On the first pass calculate the box contents */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2731 if(pass == 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2732 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2733 (*depth)++;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2734
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2735 /* Save the newly calculated values on the box */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2736 _dw_resize_box(tmp, depth, x, y, pass);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2737
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2738 /* Duplicate the values in the item list for use below */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2739 thisbox->items[z].width = tmp->minwidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2740 thisbox->items[z].height = tmp->minheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2741
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2742 /* If the box has no contents but is expandable... default the size to 1 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2743 if(!thisbox->items[z].width && thisbox->items[z].hsize)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2744 thisbox->items[z].width = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2745 if(!thisbox->items[z].height && thisbox->items[z].vsize)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2746 thisbox->items[z].height = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2747
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2748 (*depth)--;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2749 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2750 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2751 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2752
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2753 /* Precalculate these values, since they will
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2754 * be used used repeatedly in the next section.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2755 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2756 itempad = thisbox->items[z].pad * 2;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2757 itemwidth = thisbox->items[z].width + itempad;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2758 itemheight = thisbox->items[z].height + itempad;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2759
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2760 /* Calculate the totals and maximums */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2761 if(thisbox->type == DW_VERT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2762 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2763 if(itemwidth > uxmax)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2764 uxmax = itemwidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2765
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2766 if(thisbox->items[z].hsize != SIZEEXPAND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2767 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2768 if(itemwidth > upxmax)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2769 upxmax = itemwidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2770 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2771 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2772 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2773 if(itempad > upxmax)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2774 upxmax = itempad;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2775 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2776 thisbox->minheight += itemheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2777 if(thisbox->items[z].vsize != SIZEEXPAND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2778 thisbox->usedpady += itemheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2780 thisbox->usedpady += itempad;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2781 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2782 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2783 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2784 if(itemheight > uymax)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2785 uymax = itemheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2786 if(thisbox->items[z].vsize != SIZEEXPAND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2787 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2788 if(itemheight > upymax)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2789 upymax = itemheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2790 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2791 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2792 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2793 if(itempad > upymax)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2794 upymax = itempad;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2795 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2796 thisbox->minwidth += itemwidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2797 if(thisbox->items[z].hsize != SIZEEXPAND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2798 thisbox->usedpadx += itemwidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2799 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 thisbox->usedpadx += itempad;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2801 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 /* Add the maximums which were calculated in the previous loop */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 thisbox->minwidth += uxmax;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 thisbox->minheight += uymax;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 thisbox->usedpadx += upxmax;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 thisbox->usedpady += upymax;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810 /* The second pass is for actual placement. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 if(pass > 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2812 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813 for(z=0;z<(thisbox->count);z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2814 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 int height = thisbox->items[z].height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816 int width = thisbox->items[z].width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2817 int itempad = thisbox->items[z].pad * 2;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2818 int thispad = thisbox->pad * 2;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2819
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2820 /* Calculate the new sizes */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2821 if(thisbox->items[z].hsize == SIZEEXPAND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2822 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2823 if(thisbox->type == DW_HORZ)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2824 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2825 int expandablex = thisbox->minwidth - thisbox->usedpadx;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2826
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2827 if(expandablex)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2828 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2829 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2830 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2831 width = x - (itempad + thispad + thisbox->grouppadx);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2832 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2833 if(thisbox->items[z].vsize == SIZEEXPAND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2834 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2835 if(thisbox->type == DW_VERT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2836 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837 int expandabley = thisbox->minheight - thisbox->usedpady;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2839 if(expandabley)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2840 height = (int)(((float)height / (float)expandabley) * (float)(y - thisbox->usedpady));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2843 height = y - (itempad + thispad + thisbox->grouppady);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2846 /* If the calculated size is valid... */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2847 if(height > 0 && width > 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2848 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2849 int pad = thisbox->items[z].pad;
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2850 id handle = thisbox->items[z].hwnd;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2851 CGRect rect;
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2852
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2853 rect.origin.x = currentx + pad;
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2854 rect.origin.y = currenty + pad;
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2855 rect.size.width = width;
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2856 rect.size.height = height;
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2857 [handle setFrame:rect];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2858
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2859 /* After placing a box... place its components */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2860 if(thisbox->items[z].type == TYPEBOX)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2861 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2862 id box = thisbox->items[z].hwnd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2863 Box *tmp = (Box *)[box box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2864
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2865 if(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2866 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2867 (*depth)++;
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2868 _dw_resize_box(tmp, depth, width, height, pass);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2869 (*depth)--;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2870 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2871 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2872
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2873 /* Special handling for notebook controls */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2874 if([handle isMemberOfClass:[DWNotebook class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2875 {
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2876 DWNotebook *notebook = handle;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2877 NSInteger intpageid = [[notebook tabs] selectedSegmentIndex];
2419
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2878
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2879 if(intpageid == -1)
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2880 {
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2881 if([[notebook tabs] numberOfSegments] > 0)
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2882 {
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2883 DWNotebookPage *notepage = [[notebook views] firstObject];
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2884
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2885 /* If there is no selected segment, select the first one... */
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2886 [[notebook tabs] setSelectedSegmentIndex:0];
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2887 intpageid = 0;
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2888 [notepage setHidden:NO];
2420
384d076ed52a iOS: Minor fix for initial notebook page remaining visible on page change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2419
diff changeset
2889 [notebook setVisible:notepage];
2419
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2890 }
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2891 }
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2892
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
2893 if(intpageid != -1 && intpageid < [[notebook views] count])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2894 {
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2895 DWNotebookPage *page = [[notebook views] objectAtIndex:intpageid];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2896
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2897 /* If the new page is a valid box, lay it out */
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2898 if([page isKindOfClass:[DWBox class]])
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2899 {
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2900 Box *box = [page box];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2901 /* Start with the entire notebook size and then adjust
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2902 * it to account for the segement control's height.
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2903 */
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2904 NSInteger height = [[notebook tabs] frame].size.height;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2905 CGRect frame = [notebook frame];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2906 frame.origin.y += height;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2907 frame.size.height -= height;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2908 [page setFrame:frame];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2909 _dw_do_resize(box, frame.size.width, frame.size.height);
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2910 _dw_handle_resize_events(box);
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
2911 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2912 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2913 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2914 /* Handle laying out scrollviews... if required space is less
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2915 * than available space, then expand. Otherwise use required space.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2916 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2917 else if([handle isMemberOfClass:[DWScrollBox class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2918 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2919 int depth = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2920 DWScrollBox *scrollbox = (DWScrollBox *)handle;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2921 NSArray *subviews = [scrollbox subviews];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2922 DWBox *contentbox = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2923 Box *thisbox = [contentbox box];
2448
7e1828dd4fe0 iOS: Fix scrollbox content not expanding to take the full area if smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2447
diff changeset
2924 /* We start with the content being the available size */
7e1828dd4fe0 iOS: Fix scrollbox content not expanding to take the full area if smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2447
diff changeset
2925 CGRect frame = CGRectMake(0,0,rect.size.width,rect.size.height);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2926
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2927 /* Get the required space for the box */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2928 _dw_resize_box(thisbox, &depth, x, y, 1);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2929
2448
7e1828dd4fe0 iOS: Fix scrollbox content not expanding to take the full area if smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2447
diff changeset
2930 /* Expand the content box to the size of the contents */
7e1828dd4fe0 iOS: Fix scrollbox content not expanding to take the full area if smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2447
diff changeset
2931 if(frame.size.width < thisbox->minwidth)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2932 {
2448
7e1828dd4fe0 iOS: Fix scrollbox content not expanding to take the full area if smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2447
diff changeset
2933 frame.size.width = thisbox->minwidth;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2934 }
2448
7e1828dd4fe0 iOS: Fix scrollbox content not expanding to take the full area if smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2447
diff changeset
2935 if(frame.size.height < thisbox->minheight)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2936 {
2448
7e1828dd4fe0 iOS: Fix scrollbox content not expanding to take the full area if smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2447
diff changeset
2937 frame.size.height = thisbox->minheight;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2938 }
2449
6edaa9382046 iOS: Fix scrolling the scrollbox. Make sure scrolling is enabled and set the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2448
diff changeset
2939 [scrollbox setContentSize:frame.size];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2940 [contentbox setFrame:frame];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2941
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2942 /* Layout the content of the scrollbox */
2448
7e1828dd4fe0 iOS: Fix scrollbox content not expanding to take the full area if smaller.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2447
diff changeset
2943 _dw_do_resize(thisbox, frame.size.width, frame.size.height);
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2944 _dw_handle_resize_events(thisbox);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2946 /* Special handling for spinbutton controls */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2947 else if([handle isMemberOfClass:[DWSpinButton class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2948 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2949 DWSpinButton *spinbutton = (DWSpinButton *)handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2950 UITextField *textfield = [spinbutton textfield];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2951 UIStepper *stepper = [spinbutton stepper];
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2952 NSInteger stepperwidth = [stepper intrinsicContentSize].width;
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2953 [textfield setFrame:CGRectMake(0,0,rect.size.width-stepperwidth,rect.size.height)];
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
2954 [stepper setFrame:CGRectMake(rect.size.width-stepperwidth,0,stepperwidth,rect.size.height)];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2955 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2956 else if([handle isMemberOfClass:[DWSplitBar class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2957 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2958 DWSplitBar *split = (DWSplitBar *)handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2959 float percent = [split percent];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2960
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2961 if(percent > 0 && rect.size.width > 20 && rect.size.height > 20)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2962 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2963 dw_splitbar_set(handle, percent);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2964 [split setPercent:0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2965 }
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
2966 [split splitViewDidResizeSubviews:nil];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2967 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2968
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2969 /* Advance the current position in the box */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2970 if(thisbox->type == DW_HORZ)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2971 currentx += width + (pad * 2);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2972 if(thisbox->type == DW_VERT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2973 currenty += height + (pad * 2);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2974 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2975 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2976 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2977 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2978
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2979 static void _dw_do_resize(Box *thisbox, int x, int y)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2980 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2981 if(x > 0 && y > 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2982 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2983 if(thisbox)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2984 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2985 int depth = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2986
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2987 /* Calculate space requirements */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2988 _dw_resize_box(thisbox, &depth, x, y, 1);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2989
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2990 /* Finally place all the boxes and controls */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
2991 _dw_resize_box(thisbox, &depth, x, y, 2);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2992 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2993 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2994 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2995
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2996 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2997 * Runs a message loop for Dynamic Windows.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2999 void API dw_main(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 {
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3001 /* We don't actually run a loop here,
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3002 * we launched a new thread to run the loop there.
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3003 * Just wait for dw_main_quit() on the DWMainEvent.
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3004 */
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3005 dw_event_wait(DWMainEvent, DW_TIMEOUT_INFINITE);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3006 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3007
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3008 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3009 * Causes running dw_main() to return.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3010 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3011 void API dw_main_quit(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3012 {
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3013 dw_event_post(DWMainEvent);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3014 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3015
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3016 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3017 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3018 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3019 * milliseconds: Number of milliseconds to run the loop for.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3020 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3021 void API dw_main_sleep(int milliseconds)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3022 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3023 DWTID curr = pthread_self();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3024
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3025 if(DWThread == (DWTID)-1 || DWThread == curr)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3026 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3027 DWTID orig = DWThread;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3028 NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3029
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3030 if(orig == (DWTID)-1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3031 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3032 DWThread = curr;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3033 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3034 /* Process any pending events */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3035 while(_dw_main_iteration(until))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3036 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3037 /* Just loop */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3038 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3039 if(orig == (DWTID)-1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3040 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3041 DWThread = orig;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3042 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3043 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3044 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3045 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3046 usleep(milliseconds * 1000);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3047 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3048 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3049
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3050 /* Internal version that doesn't lock the run mutex */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3051 int _dw_main_iteration(NSDate *date)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3052 {
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
3053 return [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:date];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3054 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3056 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3057 * Processes a single message iteration and returns.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3058 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3059 void API dw_main_iteration(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3060 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3061 DWTID curr = pthread_self();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3062
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3063 if(DWThread == (DWTID)-1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3064 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3065 DWThread = curr;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3066 _dw_main_iteration([NSDate distantPast]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3067 DWThread = (DWTID)-1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3068 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3069 else if(DWThread == curr)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3070 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3071 _dw_main_iteration([NSDate distantPast]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3072 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3073 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3074
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3075 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3076 * Cleanly terminates a DW session, should be signal handler safe.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3077 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3078 void API dw_shutdown(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3079 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3080 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3081
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3082 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3083 * Cleanly terminates a DW session, should be signal handler safe.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3084 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3085 * exitcode: Exit code reported to the operating system.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3086 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087 void API dw_exit(int exitcode)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089 dw_shutdown();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 exit(exitcode);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094 * Free's memory allocated by dynamic windows.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096 * ptr: Pointer to dynamic windows allocated
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3097 * memory to be free()'d.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3098 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3099 void API dw_free(void *ptr)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3100 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3101 free(ptr);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3102 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3103
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3104 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3105 * Returns a pointer to a static buffer which containes the
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3106 * current user directory. Or the root directory (C:\ on
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3107 * OS/2 and Windows).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3108 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3109 char *dw_user_dir(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3110 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3111 static char _user_dir[PATH_MAX+1] = { 0 };
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3112
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3113 if(!_user_dir[0])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3114 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3115 char *home = getenv("HOME");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3116
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3117 if(home)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3118 strncpy(_user_dir, home, PATH_MAX);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3119 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3120 strcpy(_user_dir, "/");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3121 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3122 return _user_dir;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 * Returns a pointer to a static buffer which containes the
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127 * private application data directory.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3128 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3129 char * API dw_app_dir(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3130 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3131 return _dw_bundle_path;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3132 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3133
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3134 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3135 * Sets the application ID used by this Dynamic Windows application instance.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3136 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3137 * appid: A string typically in the form: com.company.division.application
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3138 * appname: The application name used on Windows or NULL.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3139 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3140 * DW_ERROR_NONE after successfully setting the application ID.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3141 * DW_ERROR_UNKNOWN if unsupported on this system.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3142 * DW_ERROR_GENERAL if the application ID is not allowed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3143 * Remarks:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144 * This must be called before dw_init(). If dw_init() is called first
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145 * it will create a unique ID in the form: org.dbsoft.dwindows.application
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146 * or if the application name cannot be detected: org.dbsoft.dwindows.pid.#
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 * The appname is only required on Windows. If NULL is passed the detected
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148 * application name will be used, but a prettier name may be desired.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150 int dw_app_id_set(const char *appid, const char *appname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152 strncpy(_dw_app_id, appid, _DW_APP_ID_SIZE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3153 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157 * Displays a debug message on the console...
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3159 * format: printf style format string.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3160 * ...: Additional variables for use in the format.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162 void API dw_debug(const char *format, ...)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3163 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3164 va_list args;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3165 char outbuf[1025] = {0};
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3166
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3167 va_start(args, format);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3168 vsnprintf(outbuf, 1024, format, args);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3169 va_end(args);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3170
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3171 NSLog(@"%s", outbuf);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3172 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3173
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3174 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3175 * Displays a Message Box with given text and title..
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3176 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3177 * title: The title of the message box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3178 * flags: flags to indicate buttons and icon
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3179 * format: printf style format string.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3180 * ...: Additional variables for use in the format.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3181 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3182 int API dw_messagebox(const char *title, int flags, const char *format, ...)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3183 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3184 NSInteger iResponse;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3185 NSString *button1 = @"OK";
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3186 NSString *button2 = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3187 NSString *button3 = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3188 NSString *mtitle = [NSString stringWithUTF8String:title];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3189 NSString *mtext;
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3190 UIAlertControllerStyle mstyle = UIAlertControllerStyleAlert;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3191 NSArray *params;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3192 va_list args;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3193
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3194 if(flags & DW_MB_OKCANCEL)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3195 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3196 button2 = @"Cancel";
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3197 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3198 else if(flags & DW_MB_YESNO)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3199 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3200 button1 = @"Yes";
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3201 button2 = @"No";
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3202 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3203 else if(flags & DW_MB_YESNOCANCEL)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3204 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3205 button1 = @"Yes";
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3206 button2 = @"No";
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3207 button3 = @"Cancel";
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3208 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3209
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3210 va_start(args, format);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3211 mtext = [[[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3212 va_end(args);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3213
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
3214 #if 0 /* TODO: If we want to use this style it requires a rectangle...
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
3215 * However the alert style looks pretty good to me...
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
3216 */
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3217 if(flags & DW_MB_INFORMATION)
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3218 mstyle = UIAlertControllerStyleActionSheet;
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
3219 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3220
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3221 params = [NSMutableArray arrayWithObjects:mtitle, mtext, [NSNumber numberWithInteger:mstyle], button1, button2, button3, nil];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3222 [DWObj safeCall:@selector(messageBox:) withObject:params];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3223 iResponse = [[params lastObject] integerValue];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3224
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3225 switch(iResponse)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3226 {
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3227 case 1: /* user pressed OK */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3228 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3229 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3230 return DW_MB_RETURN_YES;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3231 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3232 return DW_MB_RETURN_OK;
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3233 case 2: /* user pressed Cancel */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3234 if(flags & DW_MB_OKCANCEL)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3235 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3236 return DW_MB_RETURN_CANCEL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3237 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3238 return DW_MB_RETURN_NO;
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3239 case 3: /* user pressed the third button */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3240 return DW_MB_RETURN_CANCEL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3241 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3242 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3243 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3244
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3245 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3246 * Opens a file dialog and queries user selection.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3247 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3248 * title: Title bar text for dialog.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3249 * defpath: The default path of the open dialog.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3250 * ext: Default file extention.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3251 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3252 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3253 * NULL on error. A malloced buffer containing
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3254 * the file path on success.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3255 *
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3256 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3257 char * API dw_file_browse(const char *title, const char *defpath, const char *ext, int flags)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3258 {
2415
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3259 NSPointerArray *params = [[NSPointerArray pointerArrayWithOptions:NSPointerFunctionsOpaqueMemory] retain];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3260 char *file = NULL;
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3261
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3262 [params addPointer:(void *)defpath];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3263 [params addPointer:(void *)ext];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3264 [params addPointer:DW_INT_TO_POINTER(flags)];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3265 [DWObj safeCall:@selector(filePicker:) withObject:params];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3266 if([params count] > 3)
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3267 file = [params pointerAtIndex:3];
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3268
f33a81fa29e9 iOS: Implment dw_file_browse() and fix issues in dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2414
diff changeset
3269 return file;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3270 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3271
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273 * Gets the contents of the default clipboard as text.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3275 * None.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3276 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3277 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3278 * be converted to text.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3279 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3280 char *dw_clipboard_get_text()
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3281 {
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3282 UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3283 NSString *str = [pasteboard string];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3284 if(str != nil)
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3285 return strdup([str UTF8String]);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3286 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3287 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3288
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3289 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3290 * Sets the contents of the default clipboard to the supplied text.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3291 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3292 * Text.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3293 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3294 void dw_clipboard_set_text(const char *str, int len)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3295 {
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3296 UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3297
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
3298 [pasteboard setString:[NSString stringWithUTF8String:str]];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3299 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3300
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3301
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3302 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3303 * Allocates and initializes a dialog struct.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3304 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3305 * data: User defined data to be passed to functions.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3306 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3307 DWDialog * API dw_dialog_new(void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3308 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3309 DWDialog *tmp = malloc(sizeof(DWDialog));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3310
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3311 if(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3312 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3313 tmp->eve = dw_event_new();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3314 dw_event_reset(tmp->eve);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3315 tmp->data = data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3316 tmp->done = FALSE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3317 tmp->result = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3318 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3319 return tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3320 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3321
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3322 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3323 * Accepts a dialog struct and returns the given data to the
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3324 * initial called of dw_dialog_wait().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3325 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3326 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3327 * result: Data to be returned by dw_dialog_wait().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3328 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3329 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3330 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 dialog->result = result;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3332 dw_event_post(dialog->eve);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333 dialog->done = TRUE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3335 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3336
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339 * called by a signal handler with the given dialog struct.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 void * API dw_dialog_wait(DWDialog *dialog)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3345 void *tmp = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3347 if(dialog)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3348 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3349 while(!dialog->done)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3350 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3351 _dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3352 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353 dw_event_close(&dialog->eve);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354 tmp = dialog->result;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3355 free(dialog);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 return tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3358 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3360 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3361 * Create a new Box to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3362 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3363 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3364 * pad: Number of pixels to pad around the box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3365 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3366 DW_FUNCTION_DEFINITION(dw_box_new, HWND, int type, int pad)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3367 DW_FUNCTION_ADD_PARAM2(type, pad)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3368 DW_FUNCTION_RETURN(dw_box_new, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3369 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3370 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3371 DW_FUNCTION_INIT;
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
3372 DWBox *view = [[[DWBox alloc] init] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3373 Box *newbox = [view box];
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
3374 [view setTranslatesAutoresizingMaskIntoConstraints:NO];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3375 memset(newbox, 0, sizeof(Box));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3376 newbox->pad = pad;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3377 newbox->type = type;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3378 DW_FUNCTION_RETURN_THIS(view);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3379 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3380
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3381 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3382 * Create a new Group Box to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3383 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3384 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3385 * pad: Number of pixels to pad around the box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3386 * title: Text to be displayined in the group outline.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3387 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3388 HWND API dw_groupbox_new(int type, int pad, const char *title)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3389 {
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
3390 return dw_box_new(type, pad);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3392
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3394 * Create a new scrollable Box to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 * pad: Number of pixels to pad around the box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 */
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
3399 DW_FUNCTION_DEFINITION(dw_scrollbox_new, HWND, int type, int pad)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
3400 DW_FUNCTION_ADD_PARAM2(type, pad)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
3401 DW_FUNCTION_RETURN(dw_scrollbox_new, HWND)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
3402 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 {
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
3404 DWScrollBox *scrollbox = [[[DWScrollBox alloc] init] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405 DWBox *box = dw_box_new(type, pad);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 DWBox *tmpbox = dw_box_new(DW_VERT, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407 dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3408 [scrollbox setBox:box];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3409 [scrollbox addSubview:tmpbox];
2449
6edaa9382046 iOS: Fix scrolling the scrollbox. Make sure scrolling is enabled and set the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2448
diff changeset
3410 [scrollbox setScrollEnabled:YES];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411 [tmpbox autorelease];
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
3412 DW_FUNCTION_RETURN_THIS(scrollbox);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3416 * Returns the position of the scrollbar in the scrollbox
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3417 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3418 * handle: Handle to the scrollbox to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3419 * orient: The vertical or horizontal scrollbar.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3421 int API dw_scrollbox_get_pos(HWND handle, int orient)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3422 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3423 DWScrollBox *scrollbox = handle;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3424 NSArray *subviews = [scrollbox subviews];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3425 UIView *view = [subviews firstObject];
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
3426 CGSize contentsize = [scrollbox contentSize];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3427 CGPoint contentoffset = [scrollbox contentOffset];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3428 int range = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3429 int val = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3430 if(orient == DW_VERT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3431 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3432 range = [view bounds].size.height - contentsize.height;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3433 val = contentoffset.y;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3434 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3435 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3436 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3437 range = [view bounds].size.width - contentsize.width;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3438 val = contentoffset.x;
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3439 }
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3440 if(val > range)
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3441 {
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3442 val = range;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3443 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3444 return val;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3445 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3446
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3447 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3448 * Gets the range for the scrollbar in the scrollbox.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3449 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3450 * handle: Handle to the scrollbox to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3451 * orient: The vertical or horizontal scrollbar.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3452 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3453 int API dw_scrollbox_get_range(HWND handle, int orient)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3454 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3455 DWScrollBox *scrollbox = handle;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3456 NSArray *subviews = [scrollbox subviews];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3457 UIView *view = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3458 int range = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3459 if(orient == DW_VERT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3460 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3461 range = [view bounds].size.height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3462 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3463 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3464 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3465 range = [view bounds].size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3466 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3467 return range;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3468 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3469
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3470 /* Return the handle to the text object */
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
3471 id _dw_text_handle(id object)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3472 {
2427
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
3473 if([object isMemberOfClass:[DWButton class]])
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
3474 {
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
3475 DWButton *button = object;
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
3476 object = [button titleLabel];
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
3477 }
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
3478 else if([object isMemberOfClass:[DWSpinButton class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3479 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3480 DWSpinButton *spinbutton = object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3481 object = [spinbutton textfield];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3482 }
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3483 #if 0 /* TODO: Fix this when we have a groupbox implemented */
2427
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
3484 if([object isMemberOfClass:[NSBox class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3485 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3486 NSBox *box = object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3487 id content = [box contentView];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3488
2427
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
3489 if([content isMemberOfClass:[DWText class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3490 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3491 object = content;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3492 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3493 }
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3494 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3495 return object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3496 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3497
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3498 /* Internal function to calculate the widget's required size..
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3499 * These are the general rules for widget sizes:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3500 *
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3501 * Render/Unspecified: 1x1
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 * Scrolled(Container,Tree,MLE): Guessed size clamped to min and max in dw.h
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503 * Entryfield/Combobox/Spinbutton: 150x(maxfontheight)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3504 * Spinbutton: 50x(maxfontheight)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505 * Text/Status: (textwidth)x(textheight)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506 * Ranged: 100x14 or 14x100 for vertical.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507 * Buttons/Bitmaps: Size of text or image and border.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 void _dw_control_size(id handle, int *width, int *height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3511 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512 NSString *nsstr = nil;
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
3513 id object = _dw_text_handle(handle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3514
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3515 /* Handle all the different button types */
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3516 if([handle isMemberOfClass:[DWButton class]])
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3517 {
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3518 UIImage *image = [handle imageForState:UIControlStateNormal];
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3519
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3520 if(image)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3521 {
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3522 /* Image button */
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3523 CGSize size = [image size];
2423
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3524 extrawidth = (int)size.width + 1;
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3525 /* Height isn't additive */
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3526 thisheight = (int)size.height + 1;
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3527 }
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3528 /* Text button */
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3529 nsstr = [[handle titleLabel] text];
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3530
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3531 if(nsstr && [nsstr length] > 0)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3532 {
2423
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3533 /* With combined text/image we seem to
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3534 * need a lot of additional width space.
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3535 */
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3536 if(image)
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3537 extrawidth += 30;
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3538 else
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3539 extrawidth += 8;
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
3540 extraheight += 4;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3541 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3542 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3543 /* If the control is an entryfield set width to 150 */
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3544 else if([object isKindOfClass:[UITextField class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3545 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3546 UIFont *font = [object font];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3547
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3548 if([object isEditable])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3549 {
2430
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3550 /* Spinbutton text doesn't need to be as wide */
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3551 if([handle isMemberOfClass:[DWSpinButton class]])
2430
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3552 thiswidth = 50;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3553 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3554 thiswidth = 150;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3555 }
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3556 nsstr = [object text];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3557
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558 if(font)
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3559 thisheight = (int)[font lineHeight];
2430
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3560
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3561 /* Spinbuttons need some extra */
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3562 if([handle isMemberOfClass:[DWSpinButton class]])
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3563 {
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3564 DWSpinButton *spinbutton = handle;
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3565 CGSize size = [[spinbutton stepper] intrinsicContentSize];
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3566
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3567 /* Add the stepper width as extra... */
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3568 extrawidth = size.width;
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3569 /* The height should be the bigger of the two */
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3570 if(size.height > thisheight)
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3571 thisheight = size.height;
e08968d21d45 iOS: Additional code to calculate spinbutton size.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2429
diff changeset
3572 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574 /* Handle the ranged widgets */
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3575 else if([object isMemberOfClass:[DWPercent class]] ||
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3576 [object isMemberOfClass:[DWSlider class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 thiswidth = 100;
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3579 thisheight = 25;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3581 /* Handle bitmap size */
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3582 else if([object isMemberOfClass:[UIImageView class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3583 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3584 UIImage *image = (UIImage *)[object image];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 if(image)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 {
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
3588 CGSize size = [image size];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589 thiswidth = (int)size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3590 thisheight = (int)size.height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3591 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3592 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3593 /* Handle calendar */
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3594 else if([object isMemberOfClass:[DWCalendar class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3595 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3596 CGSize size = [object intrinsicContentSize];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3597
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3598 thiswidth = size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3599 thisheight = size.height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3600 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3601 /* MLE and Container */
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3602 else if([object isMemberOfClass:[DWMLE class]] ||
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3603 [object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3604 {
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
3605 CGSize size;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3606
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3607 if([object isMemberOfClass:[DWMLE class]])
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
3608 size = [object contentSize];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3609 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3610 size = [object getsize];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3611
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3612 thiswidth = size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3613 thisheight = size.height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3614
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3615 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3616 thiswidth = _DW_SCROLLED_MIN_WIDTH;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3617 if(thiswidth > _DW_SCROLLED_MAX_WIDTH)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3618 thiswidth = _DW_SCROLLED_MAX_WIDTH;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3619 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3620 thisheight = _DW_SCROLLED_MIN_HEIGHT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3621 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3622 thisheight = _DW_SCROLLED_MAX_HEIGHT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3623 }
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3624 else if([object isKindOfClass:[UILabel class]])
2423
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3625 {
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
3626 nsstr = [object text];
2423
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3627 extrawidth = extraheight = 2;
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3628 }
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3629 #ifdef DW_INCLUDE_DEPRECATED
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3630 /* Any other control type */
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3631 else if([object isKindOfClass:[UIControl class]])
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
3632 nsstr = [object text];
2428
9c5b95d66fc8 iOS: Make spin buttons actually function. Fix layout and autosizing issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2427
diff changeset
3633 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3634
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3635 /* If we have a string...
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3636 * calculate the size with the current font.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3637 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3638 if(nsstr && [nsstr length])
2423
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3639 {
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3640 int textwidth, textheight;
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3641
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3642 dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &textwidth, &textheight);
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3643
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3644 if(textheight > thisheight)
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3645 thisheight = textheight;
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3646 if(textwidth > thiswidth)
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3647 thiswidth = textwidth;
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
3648 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 /* Set the requested sizes */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 if(width)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3652 *width = thiswidth + extrawidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3653 if(height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654 *height = thisheight + extraheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3655 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3656
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3657 /* Internal box packing function called by the other 3 functions */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3658 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3659 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3660 id object = box;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3661 DWBox *view = box;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3662 DWBox *this = item;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3663 Box *thisbox;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3664 int z, x = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3665 Item *tmpitem, *thisitem;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3666
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3667 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3668 * If you try and pack an item into itself VERY bad things can happen; like at least an
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3669 * infinite loop on GTK! Lets be safe!
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3670 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3671 if(box == item)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3672 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3673 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3674 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3675 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3676
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3677 /* Query the objects */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3678 if([ object isKindOfClass:[ UIWindow class ] ])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3679 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3680 UIWindow *window = box;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3681 NSArray *subviews = [window subviews];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3682 view = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3683 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3684 else if([ object isMemberOfClass:[ DWScrollBox class ] ])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3685 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3686 DWScrollBox *scrollbox = box;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3687 view = [scrollbox box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3688 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3689
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3690 thisbox = [view box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3691 thisitem = thisbox->items;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3692 object = item;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3693
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3694 /* Do some sanity bounds checking */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3695 if(!thisitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3696 thisbox->count = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3697 if(index < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698 index = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3699 if(index > thisbox->count)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3700 index = thisbox->count;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3701
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3702 /* Duplicate the existing data */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3703 tmpitem = calloc(sizeof(Item), (thisbox->count+1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3704
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3705 for(z=0;z<thisbox->count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3706 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3707 if(z == index)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3708 x++;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3709 tmpitem[x] = thisitem[z];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3710 x++;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3711 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3712
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3713 /* Sanity checks */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3714 if(vsize && !height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3715 height = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3716 if(hsize && !width)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3717 width = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3718
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3719 /* Fill in the item data appropriately */
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
3720 if([object isKindOfClass:[DWBox class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3721 tmpitem[index].type = TYPEBOX;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3722 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3723 {
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
3724 if(width == 0 && hsize == FALSE)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3725 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
3726 if(height == 0 && vsize == FALSE)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3727 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3728
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3729 tmpitem[index].type = TYPEITEM;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3730 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3731
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3732 tmpitem[index].hwnd = item;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3733 tmpitem[index].origwidth = tmpitem[index].width = width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3734 tmpitem[index].origheight = tmpitem[index].height = height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3735 tmpitem[index].pad = pad;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3736 tmpitem[index].hsize = hsize ? SIZEEXPAND : SIZESTATIC;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3737 tmpitem[index].vsize = vsize ? SIZEEXPAND : SIZESTATIC;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3738
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3739 /* If either of the parameters are -1 ... calculate the size */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3740 if(width == -1 || height == -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3741 _dw_control_size(object, width == -1 ? &tmpitem[index].width : NULL, height == -1 ? &tmpitem[index].height : NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3742
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3743 thisbox->items = tmpitem;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3744
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3745 /* Update the item count */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3746 thisbox->count++;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3747
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3748 /* Add the item to the box */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3749 [view addSubview:this];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3750 /* Enable autorelease on the item...
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3751 * so it will get destroyed when the parent is.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3752 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3753 [this autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3754 /* If we are packing a button... */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3755 if([this isMemberOfClass:[DWButton class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3756 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3757 DWButton *button = (DWButton *)this;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3758
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3759 /* Save the parent box so radio
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760 * buttons can use it later.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762 [button setParent:view];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 /* Queue a redraw on the top-level window */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765 _dw_redraw([view window], TRUE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3767 /* Free the old data */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 if(thisitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769 free(thisitem);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3770 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3771
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3772 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3773 * Remove windows (widgets) from the box they are packed into.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3774 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3775 * handle: Window handle of the packed item to be removed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3776 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3777 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3778 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3779 DW_FUNCTION_DEFINITION(dw_box_unpack, int, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3780 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3781 DW_FUNCTION_RETURN(dw_box_unpack, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3782 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3783 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3784 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3785 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3786 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3787 int retval = DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3788
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3789 if([object isKindOfClass:[UIView class]] || [object isKindOfClass:[UIControl class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3790 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3791 DWBox *parent = (DWBox *)[object superview];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3792
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
3793 if([parent isKindOfClass:[DWBox class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3794 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3795 id window = [object window];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3796 Box *thisbox = [parent box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3797 int z, index = -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3798 Item *tmpitem = NULL, *thisitem = thisbox->items;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3799
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3800 if(!thisitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3801 thisbox->count = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3802
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3803 for(z=0;z<thisbox->count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3804 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3805 if(thisitem[z].hwnd == object)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3806 index = z;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3807 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3808
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3809 if(index == -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3810 retval = DW_ERROR_GENERAL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3811 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3812 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3813 [object retain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3814 [object removeFromSuperview];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3815
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3816 if(thisbox->count > 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3817 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3818 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3819
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3820 /* Copy all but the current entry to the new list */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3821 for(z=0;z<index;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3822 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3823 tmpitem[z] = thisitem[z];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3824 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825 for(z=index+1;z<thisbox->count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3826 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3827 tmpitem[z-1] = thisitem[z];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3828 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3829 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3830
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3831 thisbox->items = tmpitem;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3832 if(thisitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3833 free(thisitem);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3834 if(tmpitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3835 thisbox->count--;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3836 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3837 thisbox->count = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838 /* Queue a redraw on the top-level window */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3839 _dw_redraw(window, TRUE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3840 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3841 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3843 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3844 DW_FUNCTION_RETURN_THIS(retval);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3845 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3846
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3848 * Remove windows (widgets) from a box at an arbitrary location.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3849 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3850 * box: Window handle of the box to be removed from.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3851 * index: 0 based index of packed items.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3852 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3853 * Handle to the removed item on success, 0 on failure or padding.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3854 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3855 DW_FUNCTION_DEFINITION(dw_box_unpack_at_index, HWND, HWND box, int index)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3856 DW_FUNCTION_ADD_PARAM2(box, index)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3857 DW_FUNCTION_RETURN(dw_box_unpack_at_index, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3858 DW_FUNCTION_RESTORE_PARAM2(box, HWND, index, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3859 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3860 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3861 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3862 DWBox *parent = (DWBox *)box;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3863 id object = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3864
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
3865 if([parent isKindOfClass:[DWBox class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3866 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3867 id window = [parent window];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3868 Box *thisbox = [parent box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3869
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3870 if(thisbox && index > -1 && index < thisbox->count)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3871 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3872 int z;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3873 Item *tmpitem = NULL, *thisitem = thisbox->items;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3874
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3875 object = thisitem[index].hwnd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3876
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3877 if(object)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3878 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3879 [object retain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3880 [object removeFromSuperview];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3881 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3882
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3883 if(thisbox->count > 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3884 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3885 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3886
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3887 /* Copy all but the current entry to the new list */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3888 for(z=0;thisitem && z<index;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3889 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3890 tmpitem[z] = thisitem[z];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3891 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3892 for(z=index+1;z<thisbox->count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3893 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3894 tmpitem[z-1] = thisitem[z];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3895 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3896 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3897
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3898 thisbox->items = tmpitem;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899 if(thisitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900 free(thisitem);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901 if(tmpitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902 thisbox->count--;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3903 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3904 thisbox->count = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3905
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3906 /* Queue a redraw on the top-level window */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3907 _dw_redraw(window, TRUE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3908 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3909 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3910 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3911 DW_FUNCTION_RETURN_THIS(object);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3912 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3913
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3914 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3915 * Pack windows (widgets) into a box at an arbitrary location.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3916 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3917 * box: Window handle of the box to be packed into.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3918 * item: Window handle of the item to pack.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3919 * index: 0 based index of packed items.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3920 * width: Width in pixels of the item or -1 to be self determined.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3921 * height: Height in pixels of the item or -1 to be self determined.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3922 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3923 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3924 * pad: Number of pixels of padding around the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3925 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
3926 DW_FUNCTION_DEFINITION(dw_box_pack_at_index, void, HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
3927 DW_FUNCTION_ADD_PARAM8(box, item, index, width, height, hsize, vsize, pad)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
3928 DW_FUNCTION_NO_RETURN(dw_box_pack_at_index)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
3929 DW_FUNCTION_RESTORE_PARAM8(box, HWND, item, HWND, index, int, width, int, height, int, hsize, int, vsize, int, pad, int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3930 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3931 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()");
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
3932 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3933 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3934
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3935 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3936 * Pack windows (widgets) into a box from the start (or top).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3937 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3938 * box: Window handle of the box to be packed into.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3939 * item: Window handle of the item to pack.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3940 * width: Width in pixels of the item or -1 to be self determined.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3941 * height: Height in pixels of the item or -1 to be self determined.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3942 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3943 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3944 * pad: Number of pixels of padding around the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3945 */
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3946 DW_FUNCTION_DEFINITION(dw_box_pack_start, void, HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3947 DW_FUNCTION_ADD_PARAM7(box, item, width, height, hsize, vsize, pad)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3948 DW_FUNCTION_NO_RETURN(dw_box_pack_start)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3949 DW_FUNCTION_RESTORE_PARAM7(box, HWND, item, HWND, width, int, height, int, hsize, int, vsize, int, pad, int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3950 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3951 /* 65536 is the table limit on GTK...
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3952 * seems like a high enough value we will never hit it here either.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3953 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3954 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()");
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3955 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3956 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3957
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3958 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3959 * Pack windows (widgets) into a box from the end (or bottom).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3960 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3961 * box: Window handle of the box to be packed into.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3962 * item: Window handle of the item to pack.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3963 * width: Width in pixels of the item or -1 to be self determined.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3964 * height: Height in pixels of the item or -1 to be self determined.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3965 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3966 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3967 * pad: Number of pixels of padding around the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3968 */
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3969 DW_FUNCTION_DEFINITION(dw_box_pack_end, void, HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3970 DW_FUNCTION_ADD_PARAM7(box, item, width, height, hsize, vsize, pad)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3971 DW_FUNCTION_NO_RETURN(dw_box_pack_end)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3972 DW_FUNCTION_RESTORE_PARAM7(box, HWND, item, HWND, width, int, height, int, hsize, int, vsize, int, pad, int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3973 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3974 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()");
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
3975 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3976 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3977
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3978 /* Internal function to create a basic button, used by all button types */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
3979 HWND _dw_internal_button_new(const char *text, ULONG cid)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3980 {
2401
010ae32a5067 iOS: Hide the UITransitionView that is attached to the UIWindow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2400
diff changeset
3981 DWButton *button = [[DWButton buttonWithType:UIButtonTypeRoundedRect] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3982 if(text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3983 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3984 [button setTitle:[NSString stringWithUTF8String:text] forState:UIControlStateNormal];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3985 }
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3986 [button addTarget:button
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3987 action:@selector(buttonClicked:)
2401
010ae32a5067 iOS: Hide the UITransitionView that is attached to the UIWindow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2400
diff changeset
3988 forControlEvents:UIControlEventTouchUpInside];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3989 [button setTag:cid];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3990 if(DWDefaultFont)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3991 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
3992 [[button titleLabel] setFont:DWDefaultFont];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3994 return button;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3995 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3996
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3998 * Create a new button window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3999 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4000 * text: The text to be display by the static text widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4001 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4002 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4003 DW_FUNCTION_DEFINITION(dw_button_new, HWND, const char *text, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4004 DW_FUNCTION_ADD_PARAM2(text, cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4005 DW_FUNCTION_RETURN(dw_button_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4006 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4007 {
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4008 DWButton *button = _dw_internal_button_new(text, cid);
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4009 [button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4010 DW_FUNCTION_RETURN_THIS(button);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4011 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4012
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4013 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4014 * Create a new Entryfield window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4015 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4016 * text: The default text to be in the entryfield widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4017 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4018 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4019 DW_FUNCTION_DEFINITION(dw_entryfield_new, HWND, const char *text, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4020 DW_FUNCTION_ADD_PARAM2(text, cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4021 DW_FUNCTION_RETURN(dw_entryfield_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4022 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4023 {
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
4024 DWEntryField *entry = [[[DWEntryField alloc] init] retain];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4025 [entry setText:[ NSString stringWithUTF8String:text ]];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4026 [entry setTag:cid];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4027 DW_FUNCTION_RETURN_THIS(entry);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4028 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4029
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4030 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4031 * Create a new Entryfield (password) window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4032 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4033 * text: The default text to be in the entryfield widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4034 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4035 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4036 DW_FUNCTION_DEFINITION(dw_entryfield_password_new, HWND, const char *text, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4037 DW_FUNCTION_ADD_PARAM2(text, cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4038 DW_FUNCTION_RETURN(dw_entryfield_password_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4039 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4040 {
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
4041 DWEntryField *entry = dw_entryfield_new(text, cid);
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
4042 [entry setSecureTextEntry:YES];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4043 DW_FUNCTION_RETURN_THIS(entry);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4045
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4046 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4047 * Sets the entryfield character limit.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4048 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4049 * handle: Handle to the spinbutton to be set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4050 * limit: Number of characters the entryfield will take.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4051 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4052 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4053 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
4054 #if 0 /* TODO: Implment this via textField:shouldChangeCharactersInRange:replacementString: */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4055 DWEntryField *entry = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4056 DWEntryFieldFormatter *formatter = [[[DWEntryFieldFormatter alloc] init] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4057
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4058 [formatter setMaximumLength:(int)limit];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4059 [entry setFormatter:formatter];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
4060 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4061 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4062
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4063 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4064 * Create a new bitmap button window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4065 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4066 * text: Bubble help text to be displayed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4067 * id: An ID of a bitmap in the resource file.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4068 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4069 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new, HWND, DW_UNUSED(const char *text), ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4070 DW_FUNCTION_ADD_PARAM2(text, cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4071 DW_FUNCTION_RETURN(dw_bitmapbutton_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4072 DW_FUNCTION_RESTORE_PARAM2(DW_UNUSED(text), const char *, cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4073 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4074 NSBundle *bundle = [NSBundle mainBundle];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4075 NSString *respath = [bundle resourcePath];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4076 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", cid];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077 UIImage *image = [[UIImage alloc] initWithContentsOfFile:filepath];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4078 DWButton *button = _dw_internal_button_new("", cid);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4079 if(image)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4080 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4081 [button setImage:image forState:UIControlStateNormal];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4082 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4083 [image release];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4084 DW_FUNCTION_RETURN_THIS(button);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4085 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4086
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4088 * Create a new bitmap button window (widget) to be packed from a file.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4089 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090 * text: Bubble help text to be displayed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4091 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4092 * filename: Name of the file, omit extention to have
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4093 * DW pick the appropriate file extension.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4094 * (BMP on OS/2 or Windows, XPM on Unix)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4095 */
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
4096 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new_from_file, HWND, DW_UNUSED(const char *text), ULONG cid, const char *filename)
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4097 DW_FUNCTION_ADD_PARAM3(text, cid, filename)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4098 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_file, HWND)
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
4099 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(text), const char *, cid, ULONG, filename, const char *)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4100 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4101 char *ext = _dw_get_image_extension(filename);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4102
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103 NSString *nstr = [ NSString stringWithUTF8String:filename ];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104 UIImage *image = [[UIImage alloc] initWithContentsOfFile:nstr];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 if(!image && ext)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 image = [[UIImage alloc] initWithContentsOfFile:nstr];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 }
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4111 DWButton *button = _dw_internal_button_new("", cid);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112 if(image)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4114 [button setImage:image forState:UIControlStateNormal];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4115 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4116 [image release];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4117 DW_FUNCTION_RETURN_THIS(button);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4118 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 * Create a new bitmap button window (widget) to be packed from data.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123 * text: Bubble help text to be displayed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 * data: The contents of the image
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 * (BMP or ICO on OS/2 or Windows, XPM on Unix)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4127 * len: length of str
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4129 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new_from_data, HWND, DW_UNUSED(const char *text), ULONG cid, const char *data, int len)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4130 DW_FUNCTION_ADD_PARAM4(text, cid, data, len)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4131 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_data, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4132 DW_FUNCTION_RESTORE_PARAM4(DW_UNUSED(text), const char *, cid, ULONG, data, const char *, len, int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4133 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4134 NSData *thisdata = [NSData dataWithBytes:data length:len];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4135 UIImage *image = [[UIImage alloc] initWithData:thisdata];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4136 DWButton *button = _dw_internal_button_new("", cid);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4137 if(image)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4138 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4139 [button setImage:image forState:UIControlStateNormal];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4140 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4141 [image release];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4142 DW_FUNCTION_RETURN_THIS(button);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4143 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 * Create a new spinbutton window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 * text: The text to be display by the static text widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4149 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4150 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4151 DW_FUNCTION_DEFINITION(dw_spinbutton_new, HWND, const char *text, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4152 DW_FUNCTION_ADD_PARAM2(text, cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4153 DW_FUNCTION_RETURN(dw_spinbutton_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4154 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4155 {
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
4156 DWSpinButton *spinbutton = [[[DWSpinButton alloc] init] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4157 UIStepper *stepper = [spinbutton stepper];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4158 UITextField *textfield = [spinbutton textfield];
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
4159 long val = atol(text);
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
4160
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4161 [stepper setStepValue:1];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4162 [stepper setTag:cid];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4163 [stepper setMinimumValue:-65536];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4164 [stepper setMaximumValue:65536];
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
4165 [stepper setValue:(float)val];
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
4166 [textfield setText:[NSString stringWithFormat:@"%ld",val]];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4167 DW_FUNCTION_RETURN_THIS(spinbutton);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4170 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4171 * Sets the spinbutton value.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173 * handle: Handle to the spinbutton to be set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 * position: Current value of the spinbutton.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4175 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4176 DW_FUNCTION_DEFINITION(dw_spinbutton_set_pos, void, HWND handle, long position)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4177 DW_FUNCTION_ADD_PARAM2(handle, position)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4178 DW_FUNCTION_NO_RETURN(dw_spinbutton_set_pos)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4179 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, long)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4181 DWSpinButton *spinbutton = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 UIStepper *stepper = [spinbutton stepper];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183 UITextField *textfield = [spinbutton textfield];
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
4184 [stepper setValue:(float)position];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4185 [textfield setText:[NSString stringWithFormat:@"%ld",position]];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4186 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4187 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4188
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4189 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4190 * Sets the spinbutton limits.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4191 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4192 * handle: Handle to the spinbutton to be set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 * upper: Upper limit.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194 * lower: Lower limit.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4196 DW_FUNCTION_DEFINITION(dw_spinbutton_set_limits, void, HWND handle, long upper, long lower)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4197 DW_FUNCTION_ADD_PARAM3(handle, upper, lower)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4198 DW_FUNCTION_NO_RETURN(dw_spinbutton_set_limits)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4199 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, upper, long, lower, long)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4200 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4201 DWSpinButton *spinbutton = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4202 UIStepper *stepper = [spinbutton stepper];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4203 [stepper setMinimumValue:(double)lower];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4204 [stepper setMaximumValue:(double)upper];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4205 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4206 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4207
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4208 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 * Returns the current value of the spinbutton.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211 * handle: Handle to the spinbutton to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4212 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4213 DW_FUNCTION_DEFINITION(dw_spinbutton_get_pos, long, HWND handle)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4214 DW_FUNCTION_ADD_PARAM1(handle)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4215 DW_FUNCTION_RETURN(dw_spinbutton_get_pos, long)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4216 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218 DWSpinButton *spinbutton = handle;
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4219 long retval;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 UIStepper *stepper = [spinbutton stepper];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4221 retval = (long)[stepper value];
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4222 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4223 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4224
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4225 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226 * Create a new radiobutton window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 * text: The text to be display by the static text widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4231 DW_FUNCTION_DEFINITION(dw_radiobutton_new, HWND, const char *text, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4232 DW_FUNCTION_ADD_PARAM2(text, cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4233 DW_FUNCTION_RETURN(dw_radiobutton_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4234 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4235 {
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4236 DWButton *button = _dw_internal_button_new(text, cid);
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4237 [button setType:_DW_BUTTON_TYPE_RADIO];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4238 DW_FUNCTION_RETURN_THIS(button);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4239 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4240
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4241 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4242 * Create a new slider window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4243 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4244 * vertical: TRUE or FALSE if slider is vertical.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4245 * increments: Number of increments available.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4246 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4247 */
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
4248 DW_FUNCTION_DEFINITION(dw_slider_new, HWND, int DW_UNUSED(vertical), int increments, ULONG cid)
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4249 DW_FUNCTION_ADD_PARAM3(vertical, increments, cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4250 DW_FUNCTION_RETURN(dw_slider_new, HWND)
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
4251 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(vertical), int, increments, int, cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4252 {
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
4253 DWSlider *slider = [[[DWSlider alloc] init] retain];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4254 [slider setMaximumValue:(double)increments];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4255 [slider setMinimumValue:0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4256 [slider setContinuous:YES];
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
4257 [slider addTarget:slider
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
4258 action:@selector(sliderChanged:)
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
4259 forControlEvents:UIControlEventValueChanged];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4260 [slider setTag:cid];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4261 DW_FUNCTION_RETURN_THIS(slider);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4262 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4263
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4264 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265 * Returns the position of the slider.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4266 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4267 * handle: Handle to the slider to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4269 unsigned int API dw_slider_get_pos(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4270 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4271 DWSlider *slider = handle;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4272 double val = [slider value];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4273 return (int)val;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4274 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4275
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4276 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4277 * Sets the slider position.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4278 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4279 * handle: Handle to the slider to be set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4280 * position: Position of the slider withing the range.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4281 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4282 void API dw_slider_set_pos(HWND handle, unsigned int position)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4283 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4284 DWSlider *slider = handle;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4285 [slider setValue:(double)position];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4286 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4287
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4288 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4289 * Create a new scrollbar window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4290 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4291 * vertical: TRUE or FALSE if scrollbar is vertical.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4292 * increments: Number of increments available.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4293 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4294 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4295 HWND API dw_scrollbar_new(int vertical, ULONG cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296 {
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
4297 /*TODO: Implement scrollbars if possible */
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
4298 return 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4299 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302 * Returns the position of the scrollbar.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4304 * handle: Handle to the scrollbar to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4306 unsigned int API dw_scrollbar_get_pos(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4307 {
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
4308 /*TODO: Implement scrollbars if possible */
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
4309 return 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4310 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4312 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4313 * Sets the scrollbar position.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4314 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4315 * handle: Handle to the scrollbar to be set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4316 * position: Position of the scrollbar withing the range.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4317 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4318 void API dw_scrollbar_set_pos(HWND handle, unsigned int position)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4319 {
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
4320 /*TODO: Implement scrollbars if possible */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4321 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4322
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4324 * Sets the scrollbar range.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4326 * handle: Handle to the scrollbar to be set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327 * range: Maximum range value.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 * visible: Visible area relative to the range.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4329 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4330 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4331 {
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
4332 /*TODO: Implement scrollbars if possible */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 * Create a new percent bar window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4340 DW_FUNCTION_DEFINITION(dw_percent_new, HWND, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4341 DW_FUNCTION_ADD_PARAM1(cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4342 DW_FUNCTION_RETURN(dw_percent_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4343 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344 {
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
4345 DWPercent *percent = [[[DWPercent alloc] init] retain];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4346 [percent setTag:cid];
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4347 DW_FUNCTION_RETURN_THIS(percent);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4350 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4351 * Sets the percent bar position.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4352 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4353 * handle: Handle to the percent bar to be set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354 * position: Position of the percent bar withing the range.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4356 DW_FUNCTION_DEFINITION(dw_percent_set_pos, void, HWND handle, unsigned int position)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4357 DW_FUNCTION_ADD_PARAM2(handle, position)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358 DW_FUNCTION_NO_RETURN(dw_percent_set_pos)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, unsigned int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4360 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4362 DWPercent *percent = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4364 /* Handle indeterminate */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4365 if(position == DW_PERCENT_INDETERMINATE)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4367 [percent setProgress:0 animated:NO];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4370 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371 /* Handle normal */
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4372 [percent setProgress:(float)position/100.0 animated:YES];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4375 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 * Create a new checkbox window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4380 * text: The text to be display by the static text widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4382 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4383 DW_FUNCTION_DEFINITION(dw_checkbox_new, HWND, const char *text, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4384 DW_FUNCTION_ADD_PARAM2(text, cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4385 DW_FUNCTION_RETURN(dw_checkbox_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4386 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4387 {
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4388 DWButton *button = _dw_internal_button_new(text, cid);
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4389 [button setType:_DW_BUTTON_TYPE_CHECK];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4390 DW_FUNCTION_RETURN_THIS(button);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4391 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4392
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394 * Returns the state of the checkbox.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4395 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396 * handle: Handle to the checkbox to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4397 */
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4398 DW_FUNCTION_DEFINITION(dw_checkbox_get, int, HWND handle)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4399 DW_FUNCTION_ADD_PARAM1(handle)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4400 DW_FUNCTION_RETURN(dw_checkbox_get, int)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4401 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4402 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4403 DWButton *button = handle;
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4404 int retval = FALSE;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4405
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4406 if([button state])
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4407 retval = TRUE;
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4408 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4410
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4411 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4412 * Sets the state of the checkbox.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4414 * handle: Handle to the checkbox to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4415 * value: TRUE for checked, FALSE for unchecked.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4416 */
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4417 DW_FUNCTION_DEFINITION(dw_checkbox_set, void, HWND handle, int value)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4418 DW_FUNCTION_ADD_PARAM2(handle, value)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4419 DW_FUNCTION_NO_RETURN(dw_checkbox_set)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4420 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, value, int)
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4421 {
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4422 DWButton *button = handle;
2422
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4423 [button setState:value];
4a353a83b2e4 iOS: Initial attempt at implementing check and radio boxes using SF Symbols.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2421
diff changeset
4424 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4425 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4426
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4427 /* Internal common function to create containers and listboxes */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4428 HWND _dw_cont_new(ULONG cid, int multi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4429 {
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
4430 DWContainer *cont = [[[DWContainer alloc] init] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432 [cont setAllowsMultipleSelection:(multi ? YES : NO)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 [cont setDataSource:cont];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434 [cont setDelegate:cont];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 [cont setTag:cid];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436 [cont autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437 [cont setRowBgOdd:DW_RGB_TRANSPARENT andEven:DW_RGB_TRANSPARENT];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4438 return cont;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4439 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4440
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4441 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4442 * Create a new listbox window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4443 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4444 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4445 * multi: Multiple select TRUE or FALSE.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4446 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4447 DW_FUNCTION_DEFINITION(dw_listbox_new, HWND, ULONG cid, int multi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4448 DW_FUNCTION_ADD_PARAM2(cid, multi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4449 DW_FUNCTION_RETURN(dw_listbox_new, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4450 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4451 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4452 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4453 DWContainer *cont = _dw_cont_new(cid, multi);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4454 [cont setup];
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
4455 [cont addColumn:@"" andType:DW_CFA_STRING];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456 DW_FUNCTION_RETURN_THIS(cont);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4457 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4460 * Appends the specified text to the listbox's (or combobox) entry list.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4461 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462 * handle: Handle to the listbox to be appended to.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463 * text: Text to append into listbox.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4464 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4465 DW_FUNCTION_DEFINITION(dw_listbox_append, void, HWND handle, const char *text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4466 DW_FUNCTION_ADD_PARAM2(handle, text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4467 DW_FUNCTION_NO_RETURN(dw_listbox_append)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4468 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4469 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4470 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4471 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4472
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4473 if([object isMemberOfClass:[DWComboBox class]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4474 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4475 DWComboBox *combo = handle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4476
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4477 [combo append:[NSString stringWithUTF8String:text]];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4478 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4479 else if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4480 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4481 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4482 NSString *nstr = [NSString stringWithUTF8String:text];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4483 NSArray *newrow = [NSArray arrayWithObject:_dw_table_cell_view_new(nil, nstr)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4484
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4485 [cont addRow:newrow];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486 [cont reloadData];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
4487 [cont setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4488 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4489 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4490 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4491
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4492 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4493 * Inserts the specified text into the listbox's (or combobox) entry list.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4494 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4495 * handle: Handle to the listbox to be inserted into.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4496 * text: Text to insert into listbox.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4497 * pos: 0-based position to insert text
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4498 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 DW_FUNCTION_DEFINITION(dw_listbox_insert, void, HWND handle, const char *text, int pos)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 DW_FUNCTION_ADD_PARAM3(handle, text, pos)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501 DW_FUNCTION_NO_RETURN(dw_listbox_insert)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, const char *, pos, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4504 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4505 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4507 if([object isMemberOfClass:[DWComboBox class]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4508 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4509 DWComboBox *combo = handle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4510
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4511 [combo insert:[NSString stringWithUTF8String:text] atIndex:pos];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4512 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4513 else if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4514 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4515 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4516 NSString *nstr = [NSString stringWithUTF8String:text];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4517 NSArray *newrow = [NSArray arrayWithObject:_dw_table_cell_view_new(nil, nstr)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4518
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4519 [cont insertRow:newrow at:pos];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4520 [cont reloadData];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
4521 [cont setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4522 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4523 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4524 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4526 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4527 * Appends the specified text items to the listbox's (or combobox) entry list.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4528 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4529 * handle: Handle to the listbox to be appended to.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4530 * text: Text strings to append into listbox.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4531 * count: Number of text strings to append
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4532 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4533 DW_FUNCTION_DEFINITION(dw_listbox_list_append, void, HWND handle, char **text, int count)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4534 DW_FUNCTION_ADD_PARAM3(handle, text, count)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535 DW_FUNCTION_NO_RETURN(dw_listbox_list_append)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4536 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, char **, count, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4537 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4538 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4539 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4540
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4541 if([object isMemberOfClass:[DWComboBox class]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4542 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4543 DWComboBox *combo = handle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4544 int z;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4545
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4546 for(z=0;z<count;z++)
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4547 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4548 NSString *nstr = [NSString stringWithUTF8String:text[z]];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4549
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4550 [combo append:nstr];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4551 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4552 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4553 else if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4554 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556 int z;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 for(z=0;z<count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4559 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4560 NSString *nstr = [NSString stringWithUTF8String:text[z]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561 NSArray *newrow = [NSArray arrayWithObjects:_dw_table_cell_view_new(nil, nstr),nil];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4562
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4563 [cont addRow:newrow];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565 [cont reloadData];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
4566 [cont setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4568 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4572 * Clears the listbox's (or combobox) list of all entries.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4574 * handle: Handle to the listbox to be cleared.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4575 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4576 DW_FUNCTION_DEFINITION(dw_listbox_clear, void, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4577 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4578 DW_FUNCTION_NO_RETURN(dw_listbox_clear)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4579 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4580 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4581 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4582 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4583
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4584 if([object isMemberOfClass:[DWComboBox class]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4585 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4586 DWComboBox *combo = handle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4587
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4588 [combo clear];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4589 }
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
4590 if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4591 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4592 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4593
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4594 [cont clear];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4595 [cont reloadData];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
4596 [cont setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4597 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4599 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 * Returns the listbox's item count.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4603 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4604 * handle: Handle to the listbox to be cleared.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4605 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4606 DW_FUNCTION_DEFINITION(dw_listbox_count, int, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4607 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4608 DW_FUNCTION_RETURN(dw_listbox_count, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4609 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4610 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4611 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4612 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4613 int result = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4614
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4615 if([object isMemberOfClass:[DWComboBox class]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4616 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4617 DWComboBox *combo = handle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4618
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4619 result = [combo count];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4620 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4621 else if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4622 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623 DWContainer *cont = handle;
2388
d84cd4227b21 iOS: Switch to UITableViewDataSource method numberOfRowsInSection:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2387
diff changeset
4624 result = (int)[cont numberOfRowsInSection:0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4625 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4626 DW_FUNCTION_RETURN_THIS(result);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4627 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4628
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4629 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4630 * Sets the topmost item in the viewport.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4631 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4632 * handle: Handle to the listbox to be cleared.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4633 * top: Index to the top item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4634 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4635 DW_FUNCTION_DEFINITION(dw_listbox_set_top, void, HWND handle, int top)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4636 DW_FUNCTION_ADD_PARAM2(handle, top)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4637 DW_FUNCTION_NO_RETURN(dw_listbox_set_top)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, top, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
4643 if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 DWContainer *cont = handle;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4646 NSIndexPath *myIP = [NSIndexPath indexPathForRow:top inSection:0];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4647
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4648 [cont scrollToRowAtIndexPath:myIP atScrollPosition:UITableViewScrollPositionNone animated:NO];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4649 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4650 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4651 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4652
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4653 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4654 * Copies the given index item's text into buffer.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4655 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4656 * handle: Handle to the listbox to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4657 * index: Index into the list to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4658 * buffer: Buffer where text will be copied.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659 * length: Length of the buffer (including NULL).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4660 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4661 DW_FUNCTION_DEFINITION(dw_listbox_get_text, void, HWND handle, unsigned int index, char *buffer, unsigned int length)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4662 DW_FUNCTION_ADD_PARAM4(handle, index, buffer, length)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663 DW_FUNCTION_NO_RETURN(dw_listbox_get_text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, index, unsigned int, buffer, char *, length, unsigned int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4665 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4666 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4667 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4668
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4669 if([object isMemberOfClass:[DWComboBox class]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4670 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4671 DWComboBox *combo = handle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4672 NSString *nstr = [combo getTextAtIndex:index];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4673
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4674 if(nstr)
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4675 strncpy(buffer, [nstr UTF8String], length - 1);
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4676 else
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4677 *buffer = '\0';
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4678 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4679 else if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4681 DWContainer *cont = handle;
2388
d84cd4227b21 iOS: Switch to UITableViewDataSource method numberOfRowsInSection:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2387
diff changeset
4682 int count = (int)[cont numberOfRowsInSection:0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4683
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4684 if(index > count)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686 *buffer = '\0';
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4688 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4689 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4690 UITableViewCell *cell = [cont getRow:index and:0];
2417
ccfc4ee9c4a7 iOS: Missed a few other DWContainer fixes in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2416
diff changeset
4691 NSString *nstr = [[cell textLabel] text];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4692
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4693 strncpy(buffer, [nstr UTF8String], length - 1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4694 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4695 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4698
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4699 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700 * Sets the text of a given listbox entry.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4701 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4702 * handle: Handle to the listbox to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4703 * index: Index into the list to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4704 * buffer: Buffer where text will be copied.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4705 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4706 DW_FUNCTION_DEFINITION(dw_listbox_set_text, void, HWND handle, unsigned int index, const char *buffer)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4707 DW_FUNCTION_ADD_PARAM3(handle, index, buffer)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4708 DW_FUNCTION_NO_RETURN(dw_listbox_set_text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4709 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, unsigned int, buffer, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4710 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4711 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4712 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4713
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4714 if([object isMemberOfClass:[DWComboBox class]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4715 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4716 DWComboBox *combo = handle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4717
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4718 [combo setText:[NSString stringWithUTF8String:buffer] atIndex:index];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4719 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4720 else if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 DWContainer *cont = handle;
2388
d84cd4227b21 iOS: Switch to UITableViewDataSource method numberOfRowsInSection:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2387
diff changeset
4723 int count = (int)[cont numberOfRowsInSection:0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4724
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 if(index <= count)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4727 NSString *nstr = [NSString stringWithUTF8String:buffer];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4728 UITableViewCell *cell = [cont getRow:index and:0];
2417
ccfc4ee9c4a7 iOS: Missed a few other DWContainer fixes in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2416
diff changeset
4729
ccfc4ee9c4a7 iOS: Missed a few other DWContainer fixes in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2416
diff changeset
4730 [[cell textLabel] setText:nstr];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4731 [cont reloadData];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
4732 [cont setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4733 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4734 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4735 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4736 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4737
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4739 * Returns the index to the item in the list currently selected.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4740 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4741 * handle: Handle to the listbox to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4742 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743 DW_FUNCTION_DEFINITION(dw_listbox_selected, int, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 DW_FUNCTION_RETURN(dw_listbox_selected, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 int result = -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4752 if([object isMemberOfClass:[DWComboBox class]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4753 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4754 DWComboBox *combo = handle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4755
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4756 result = [combo selectedIndex];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4757 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4758 else if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760 DWContainer *cont = handle;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4761 NSIndexPath *ip = [cont indexPathForSelectedRow];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4762
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4763 if(ip)
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4764 result = (int)ip.row;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 DW_FUNCTION_RETURN_THIS(result);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 * Returns the index to the current selected item or -1 when done.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 * handle: Handle to the listbox to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773 * where: Either the previous return or -1 to restart.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775 DW_FUNCTION_DEFINITION(dw_listbox_selected_multi, int, HWND handle, int where)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 DW_FUNCTION_ADD_PARAM2(handle, where)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777 DW_FUNCTION_RETURN(dw_listbox_selected_multi, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, where, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4780 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4781 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4782 int retval = -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4783
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4784 if([object isMemberOfClass:[DWContainer class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4786 DWContainer *cont = handle;
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
4787 NSArray *selected = [cont indexPathsForSelectedRows];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4788 NSIndexPath *ip = [selected objectAtIndex:(where == -1 ? 0 :where)];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4789
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4790 if(ip)
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4791 retval = (int)ip.row;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793 DW_FUNCTION_RETURN_THIS(retval)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4796 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797 * Sets the selection state of a given index.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4798 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4799 * handle: Handle to the listbox to be set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4800 * index: Item index.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4801 * state: TRUE if selected FALSE if unselected.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 */
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4803 DW_FUNCTION_DEFINITION(dw_listbox_select, void, HWND handle, int index, DW_UNUSED(int state))
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4804 DW_FUNCTION_ADD_PARAM3(handle, index, state)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4805 DW_FUNCTION_NO_RETURN(dw_listbox_select)
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4806 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, int, DW_UNUSED(state), int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4807 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4808 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4809 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4810
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
4811 if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4812 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4813 DWContainer *cont = handle;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4814 NSIndexPath *ip = [NSIndexPath indexPathForRow:index inSection:0];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4815
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4816 [cont selectRowAtIndexPath:ip
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4817 animated:NO
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4818 scrollPosition:UITableViewScrollPositionNone];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4820 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4822
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 * Deletes the item with given index from the list.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826 * handle: Handle to the listbox to be set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827 * index: Item index.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4829 DW_FUNCTION_DEFINITION(dw_listbox_delete, void, HWND handle, int index)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830 DW_FUNCTION_ADD_PARAM2(handle, index)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4831 DW_FUNCTION_NO_RETURN(dw_listbox_delete)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, index, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4833 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4836
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4837 if([object isMemberOfClass:[DWComboBox class]])
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4838 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4839 DWComboBox *combo = handle;
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4840
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4841 [combo deleteAtIndex:index];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4842 }
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4843 else if([object isMemberOfClass:[DWContainer class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4844 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4845 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4846
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4847 [cont removeRow:index];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4848 [cont reloadData];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
4849 [cont setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4851 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4852 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4853
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4854 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4855 * Create a new Combobox window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4856 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4857 * text: The default text to be in the combpbox widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4858 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4859 */
2432
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4860 DW_FUNCTION_DEFINITION(dw_combobox_new, HWND, const char *text, ULONG cid)
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4861 DW_FUNCTION_ADD_PARAM2(text, cid)
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4862 DW_FUNCTION_RETURN(dw_combobox_new, HWND)
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4863 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4864 {
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4865 DWComboBox *combo = [[DWComboBox alloc] init];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4866 if(text)
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4867 [combo setText:[NSString stringWithUTF8String:text]];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4868 [combo setTag:cid];
5e0507e67c5d iOS: Initial implementation of DWComboBox, not fully functional yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2430
diff changeset
4869 DW_FUNCTION_RETURN_THIS(combo);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4870 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4871
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4872 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4873 * Create a new Multiline Editbox window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4874 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4877 DW_FUNCTION_DEFINITION(dw_mle_new, HWND, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4878 DW_FUNCTION_ADD_PARAM1(cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4879 DW_FUNCTION_RETURN(dw_mle_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4880 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881 {
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
4882 CGRect frame = CGRectMake(0, 0, 100, 50);
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
4883 NSTextContainer *tc = [[NSTextContainer alloc] initWithSize:frame.size];
2421
d88928a85436 iOS: Fix DWMLE, have to created it like this to have valid textStorage.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2420
diff changeset
4884 NSLayoutManager *lm = [[NSLayoutManager alloc] init];
d88928a85436 iOS: Fix DWMLE, have to created it like this to have valid textStorage.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2420
diff changeset
4885 NSTextStorage *ts = [[NSTextStorage alloc] init];
d88928a85436 iOS: Fix DWMLE, have to created it like this to have valid textStorage.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2420
diff changeset
4886 [lm addTextContainer:tc];
d88928a85436 iOS: Fix DWMLE, have to created it like this to have valid textStorage.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2420
diff changeset
4887 [ts addLayoutManager:lm];
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
4888 DWMLE *mle = [[[DWMLE alloc] initWithFrame:frame textContainer:tc] retain];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4889 CGSize size = [mle intrinsicContentSize];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4890
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4891 size.width = size.height;
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
4892 [mle setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4893 [mle setTag:cid];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 [mle autorelease];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
4895 DW_FUNCTION_RETURN_THIS(mle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4896 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4897
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4898 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4899 * Adds text to an MLE box and returns the current point.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4900 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4901 * handle: Handle to the MLE to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4902 * buffer: Text buffer to be imported.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4903 * startpoint: Point to start entering text.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4904 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4905 DW_FUNCTION_DEFINITION(dw_mle_import, unsigned int, HWND handle, const char *buffer, int startpoint)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4906 DW_FUNCTION_ADD_PARAM3(handle, buffer, startpoint)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4907 DW_FUNCTION_RETURN(dw_mle_import, unsigned int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4908 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, buffer, const char *, startpoint, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4909 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4910 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4911 DWMLE *mle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4912 unsigned int retval;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4913 NSTextStorage *ts = [mle textStorage];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4914 NSString *nstr = [NSString stringWithUTF8String:buffer];
2444
ba24ddb19a43 iOS: Fix font and colors on MLE imported text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2443
diff changeset
4915 UIColor *fgcolor = [mle textColor];
ba24ddb19a43 iOS: Fix font and colors on MLE imported text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2443
diff changeset
4916 UIFont *font = [mle font];
ba24ddb19a43 iOS: Fix font and colors on MLE imported text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2443
diff changeset
4917 NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
ba24ddb19a43 iOS: Fix font and colors on MLE imported text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2443
diff changeset
4918 [attributes setObject:(fgcolor ? fgcolor : [UIColor labelColor]) forKey:NSForegroundColorAttributeName];
ba24ddb19a43 iOS: Fix font and colors on MLE imported text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2443
diff changeset
4919 if(font)
ba24ddb19a43 iOS: Fix font and colors on MLE imported text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2443
diff changeset
4920 [attributes setObject:font forKey:NSFontAttributeName];
ba24ddb19a43 iOS: Fix font and colors on MLE imported text.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2443
diff changeset
4921 NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr attributes:attributes];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4922 NSUInteger length = [ts length];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4923 if(startpoint < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4924 startpoint = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4925 if(startpoint > length)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 startpoint = (int)length;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4927 [ts insertAttributedString:nastr atIndex:startpoint];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4928 retval = (unsigned int)strlen(buffer) + startpoint;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4929 DW_FUNCTION_RETURN_THIS(retval);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4931
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4932 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4933 * Grabs text from an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4934 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4935 * handle: Handle to the MLE to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4936 * buffer: Text buffer to be exported.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4937 * startpoint: Point to start grabbing text.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4938 * length: Amount of text to be grabbed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4939 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4940 DW_FUNCTION_DEFINITION(dw_mle_export, void, HWND handle, char *buffer, int startpoint, int length)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4941 DW_FUNCTION_ADD_PARAM4(handle, buffer, startpoint, length)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4942 DW_FUNCTION_NO_RETURN(dw_mle_export)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, buffer, char *, startpoint, int, length, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4946 DWMLE *mle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947 NSTextStorage *ts = [mle textStorage];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4948 NSMutableString *ms = [ts mutableString];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4949 const char *tmp = [ms UTF8String];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4950 strncpy(buffer, tmp+startpoint, length);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4951 buffer[length] = '\0';
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4953 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4954
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4955 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4956 * Obtains information about an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4957 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4958 * handle: Handle to the MLE to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4959 * bytes: A pointer to a variable to return the total bytes.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4960 * lines: A pointer to a variable to return the number of lines.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4961 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4962 DW_FUNCTION_DEFINITION(dw_mle_get_size, void, HWND handle, unsigned long *bytes, unsigned long *lines)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4963 DW_FUNCTION_ADD_PARAM3(handle, bytes, lines)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4964 DW_FUNCTION_NO_RETURN(dw_mle_get_size)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4965 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, bytes, unsigned long *, lines, unsigned long *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4966 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4967 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4968 DWMLE *mle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4969 NSTextStorage *ts = [mle textStorage];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4970 NSMutableString *ms = [ts mutableString];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4971 NSUInteger numberOfLines, index, stringLength = [ms length];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4972
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 if(bytes)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4974 *bytes = stringLength;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4975 if(lines)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4976 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4977 for(index=0, numberOfLines=0; index < stringLength; numberOfLines++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4979
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 *lines = numberOfLines;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986 * Deletes text from an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988 * handle: Handle to the MLE to be deleted from.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 * startpoint: Point to start deleting text.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990 * length: Amount of text to be deleted.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4992 DW_FUNCTION_DEFINITION(dw_mle_delete, void, HWND handle, int startpoint, int length)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 DW_FUNCTION_ADD_PARAM3(handle, startpoint, length)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994 DW_FUNCTION_NO_RETURN(dw_mle_delete)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, startpoint, int, length, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4998 DWMLE *mle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4999 NSTextStorage *ts = [mle textStorage];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5000 NSMutableString *ms = [ts mutableString];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5001 NSUInteger mslength = [ms length];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5002 if(startpoint < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5003 startpoint = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5004 if(startpoint > mslength)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5005 startpoint = (int)mslength;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5006 if(startpoint + length > mslength)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5007 length = (int)mslength - startpoint;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5008 [ms deleteCharactersInRange:NSMakeRange(startpoint, length)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5009 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5010 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5011
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5012 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5013 * Clears all text from an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5014 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5015 * handle: Handle to the MLE to be cleared.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5016 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017 DW_FUNCTION_DEFINITION(dw_mle_clear, void, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 DW_FUNCTION_NO_RETURN(dw_mle_clear)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 DWMLE *mle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 NSTextStorage *ts = [mle textStorage];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 NSMutableString *ms = [ts mutableString];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5026 NSUInteger length = [ms length];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5027 [ms deleteCharactersInRange:NSMakeRange(0, length)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5028 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5029 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5030
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5031 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5032 * Sets the visible line of an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5033 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5034 * handle: Handle to the MLE to be positioned.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5035 * line: Line to be visible.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5036 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5037 DW_FUNCTION_DEFINITION(dw_mle_set_visible, void, HWND handle, int line)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5038 DW_FUNCTION_ADD_PARAM2(handle, line)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5039 DW_FUNCTION_NO_RETURN(dw_mle_set_visible)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5040 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, line, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5041 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5042 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5043 DWMLE *mle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5044 NSTextStorage *ts = [mle textStorage];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5045 NSMutableString *ms = [ts mutableString];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5046 NSUInteger numberOfLines, index, stringLength = [ms length];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5047
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5048 for(index=0, numberOfLines=0; index < stringLength && numberOfLines < line; numberOfLines++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5049 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5050
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051 if(line == numberOfLines)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 [mle scrollRangeToVisible:[ms lineRangeForRange:NSMakeRange(index, 0)]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059 * Sets the editablity of an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5060 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5061 * handle: Handle to the MLE.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5062 * state: TRUE if it can be edited, FALSE for readonly.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5063 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5064 void API dw_mle_set_editable(HWND handle, int state)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5065 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5066 DWMLE *mle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5067 if(state)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5069 [mle setEditable:YES];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5073 [mle setEditable:NO];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5077 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5078 * Sets the word wrap state of an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5080 * handle: Handle to the MLE.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5081 * state: TRUE if it wraps, FALSE if it doesn't.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5082 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5083 void API dw_mle_set_word_wrap(HWND handle, int state)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
5085 /* TODO: Figure out how to do this in iOS */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089 * Sets the word auto complete state of an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 * handle: Handle to the MLE.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5094 void API dw_mle_set_auto_complete(HWND handle, int state)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
5096 /* TODO: Figure out how to do this in iOS */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5097 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5098
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5099 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5100 * Sets the current cursor position of an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102 * handle: Handle to the MLE to be positioned.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103 * point: Point to position cursor.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105 DW_FUNCTION_DEFINITION(dw_mle_set_cursor, void, HWND handle, int point)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 DW_FUNCTION_ADD_PARAM2(handle, point)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 DW_FUNCTION_NO_RETURN(dw_mle_set_cursor)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, point, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 DWMLE *mle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 NSTextStorage *ts = [mle textStorage];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 NSMutableString *ms = [ts mutableString];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 NSUInteger length = [ms length];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 if(point < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 point = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 if(point > length)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 point = (int)length;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 [mle setSelectedRange: NSMakeRange(point,point)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 [mle scrollRangeToVisible:NSMakeRange(point,point)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5122 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5124 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125 * Finds text in an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5126 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5127 * handle: Handle to the MLE to be cleared.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5128 * text: Text to search for.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5129 * point: Start point of search.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130 * flags: Search specific flags.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5132 DW_FUNCTION_DEFINITION(dw_mle_search, int, HWND handle, const char *text, int point, unsigned long flags)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5133 DW_FUNCTION_ADD_PARAM4(handle, text, point, flags)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134 DW_FUNCTION_RETURN(dw_mle_search, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, text, const char *, point, int, flags, unsigned long)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 DWMLE *mle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5139 NSTextStorage *ts = [mle textStorage];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140 NSMutableString *ms = [ts mutableString];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5141 NSString *searchForMe = [NSString stringWithUTF8String:text];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142 NSRange searchRange = NSMakeRange(point, [ms length] - point);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5143 NSRange range = NSMakeRange(NSNotFound, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5144 NSUInteger options = flags ? flags : NSCaseInsensitiveSearch;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145 int retval = -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 if(ms)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5148 range = [ms rangeOfString:searchForMe options:options range:searchRange];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5149 if(range.location == NSNotFound)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5150 retval = (int)range.location;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5151 DW_FUNCTION_RETURN_THIS(retval);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5152 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5153
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5154 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5155 * Stops redrawing of an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5156 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 * handle: Handle to the MLE to freeze.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5158 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 void API dw_mle_freeze(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161 /* Don't think this is necessary */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165 * Resumes redrawing of an MLE box.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5167 * handle: Handle to the MLE to thaw.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5169 void API dw_mle_thaw(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5170 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5171 /* Don't think this is necessary */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5172 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5173
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5174 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5175 * Create a new status text window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5176 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5177 * text: The text to be display by the static text widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5178 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5179 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5180 HWND API dw_status_text_new(const char *text, ULONG cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5181 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
5182 return dw_text_new(text, cid);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5183 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5184
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5185 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5186 * Create a new static text window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5187 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 * text: The text to be display by the static text widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5189 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5190 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5191 DW_FUNCTION_DEFINITION(dw_text_new, HWND, const char *text, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5192 DW_FUNCTION_ADD_PARAM2(text, cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5193 DW_FUNCTION_RETURN(dw_text_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5194 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 {
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
5196 DWText *textfield = [[[DWText alloc] init] retain];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
5197 [textfield setText:[NSString stringWithUTF8String:text]];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5198 [textfield setTag:cid];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5199 if(DWDefaultFont)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5200 {
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
5201 [textfield setFont:DWDefaultFont];
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
5202 }
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5203 DW_FUNCTION_RETURN_THIS(textfield);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5204 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5205
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5206 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5207 * Creates a rendering context widget (window) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5208 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5209 * id: An id to be used with dw_window_from_id.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5210 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5211 * A handle to the widget or NULL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5212 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5213 DW_FUNCTION_DEFINITION(dw_render_new, HWND, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5214 DW_FUNCTION_ADD_PARAM1(cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5215 DW_FUNCTION_RETURN(dw_render_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5216 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217 {
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
5218 DWRender *render = [[[DWRender alloc] init] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5219 [render setTag:cid];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
5220 DW_FUNCTION_RETURN_THIS(render);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5221 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5222
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5223 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 * Invalidate the render widget triggering an expose event.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 * handle: A handle to a render widget to be redrawn.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 DW_FUNCTION_DEFINITION(dw_render_redraw, void, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 DW_FUNCTION_NO_RETURN(dw_render_redraw)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5231 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 DWRender *render = (DWRender *)handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
5236 [render setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5238 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240 /* Sets the current foreground drawing color.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5241 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5242 * red: red value.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5243 * green: green value.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5244 * blue: blue value.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5245 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5246 void API dw_color_foreground_set(unsigned long value)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5247 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5248 UIColor *oldcolor = pthread_getspecific(_dw_fg_color_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5249 UIColor *newcolor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5250 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5251
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5252 _dw_foreground = _dw_get_color(value);
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5253
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5254 newcolor = [[UIColor colorWithRed: DW_RED_VALUE(_dw_foreground)/255.0 green:
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5255 DW_GREEN_VALUE(_dw_foreground)/255.0 blue:
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5256 DW_BLUE_VALUE(_dw_foreground)/255.0 alpha: 1] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5257 pthread_setspecific(_dw_fg_color_key, newcolor);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5258 [oldcolor release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5259 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5260 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5261
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5262 /* Sets the current background drawing color.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5263 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5264 * red: red value.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5265 * green: green value.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5266 * blue: blue value.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5267 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5268 void API dw_color_background_set(unsigned long value)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5269 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5270 UIColor *oldcolor = pthread_getspecific(_dw_bg_color_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5271 UIColor *newcolor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5273
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5274 if(value == DW_CLR_DEFAULT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5275 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5276 pthread_setspecific(_dw_bg_color_key, NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5277 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5278 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5279 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5280 _dw_background = _dw_get_color(value);
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5281
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5282 newcolor = [[UIColor colorWithRed: DW_RED_VALUE(_dw_background)/255.0 green:
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5283 DW_GREEN_VALUE(_dw_background)/255.0 blue:
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
5284 DW_BLUE_VALUE(_dw_background)/255.0 alpha: 1] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5285 pthread_setspecific(_dw_bg_color_key, newcolor);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5286 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5287 [oldcolor release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5288 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5289 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5290
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5291 /* Allows the user to choose a color using the system's color chooser dialog.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5292 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5293 * value: current color
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5294 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5295 * The selected color or the current color if cancelled.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5297 unsigned long API dw_color_choose(unsigned long value)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 {
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
5299 NSMutableArray *params = [NSMutableArray arrayWithObject:[NSNumber numberWithUnsignedLong:value]];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
5300 unsigned long newcolor = value;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
5301
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
5302 [DWObj safeCall:@selector(colorPicker:) withObject:params];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
5303 if([params count] > 1)
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
5304 newcolor = [[params lastObject] unsignedLongValue];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
5305
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
5306 return newcolor;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5307 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5309 CGContextRef _dw_draw_context(id source, bool antialiased)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5310 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5311 CGContextRef context = nil;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5312
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5313 if([source isMemberOfClass:[DWImage class]])
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5314 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5315 DWImage *image = source;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5316
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5317 context = [image cgcontext];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5318 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5319 if(context)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5320 CGContextSetAllowsAntialiasing(context, antialiased);
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5321 return context;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5322 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5323
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5324 DWImage *_dw_dest_image(HPIXMAP pixmap, id object)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5325 {
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5326 if(pixmap && pixmap->image)
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5327 return pixmap->image;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5328 if([object isMemberOfClass:[DWRender class]])
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5329 return [object cachedImage];
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5330 return nil;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5331 }
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5332
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 /* Draw a point on a window (preferably a render window).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5334 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336 * pixmap: Handle to the pixmap. (choose only one of these)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 * x: X coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 * y: Y coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 DW_FUNCTION_DEFINITION(dw_draw_point, void, HWND handle, HPIXMAP pixmap, int x, int y)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 DW_FUNCTION_ADD_PARAM4(handle, pixmap, x, y)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 DW_FUNCTION_NO_RETURN(dw_draw_point)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, pixmap, HPIXMAP, x, int, y, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 DW_FUNCTION_INIT;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5346 DWImage *bi = _dw_dest_image(pixmap, handle);
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5347 CGContextRef context = _dw_draw_context(bi, NO);
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5348
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5349 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5350 UIGraphicsPushContext(context);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5351
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 if(bi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 {
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5354 UIBezierPath* aPath = [UIBezierPath bezierPath];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 [aPath setLineWidth: 0.5];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 UIColor *color = pthread_getspecific(_dw_fg_color_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357 [color set];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5359 [aPath moveToPoint:CGPointMake(x, y)];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 [aPath stroke];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 }
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5362 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5363 UIGraphicsPopContext();
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5365 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5366
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367 /* Draw a line on a window (preferably a render window).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5369 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5370 * pixmap: Handle to the pixmap. (choose only one of these)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 * x1: First X coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5372 * y1: First Y coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 * x2: Second X coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374 * y2: Second Y coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 DW_FUNCTION_DEFINITION(dw_draw_line, void, HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 DW_FUNCTION_ADD_PARAM6(handle, pixmap, x1, y1, x2, y2)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 DW_FUNCTION_NO_RETURN(dw_draw_line)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 DW_FUNCTION_RESTORE_PARAM6(handle, HWND, pixmap, HPIXMAP, x1, int, y1, int, x2, int, y2, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 DW_FUNCTION_INIT;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5382 DWImage *bi = _dw_dest_image(pixmap, handle);
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5383 CGContextRef context = _dw_draw_context(bi, NO);
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5384
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5385 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5386 UIGraphicsPushContext(context);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5387
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 if(bi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 {
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5390 UIBezierPath* aPath = [UIBezierPath bezierPath];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 UIColor *color = pthread_getspecific(_dw_fg_color_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 [color set];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5394 [aPath moveToPoint:CGPointMake(x1 + 0.5, y1 + 0.5)];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
5395 [aPath addLineToPoint:CGPointMake(x2 + 0.5, y2 + 0.5)];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 [aPath stroke];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 }
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5398 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5399 UIGraphicsPopContext();
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403 /* Draw text on a window (preferably a render window).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5404 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5405 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5406 * pixmap: Handle to the pixmap. (choose only one of these)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 * x: X coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408 * y: Y coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 * text: Text to be displayed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411 DW_FUNCTION_DEFINITION(dw_draw_text, void, HWND handle, HPIXMAP pixmap, int x, int y, const char *text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412 DW_FUNCTION_ADD_PARAM5(handle, pixmap, x, y, text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413 DW_FUNCTION_NO_RETURN(dw_draw_text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pixmap, HPIXMAP, x, int, y, int, text, const char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 NSString *nstr = [ NSString stringWithUTF8String:text ];
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5418 DWImage *bi = nil;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 UIFont *font = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 DWRender *render;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5421 id image = handle;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5423 if(pixmap)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 {
2395
2618277de356 iOS: Code error cleanup reported by LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2393
diff changeset
5425 bi = (id)pixmap->image;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5426 font = pixmap->font;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5427 render = pixmap->handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5428 if(!font && [render isMemberOfClass:[DWRender class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5429 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 font = [render font];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433 else if(image && [image isMemberOfClass:[DWRender class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435 render = image;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5436 font = [render font];
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5437 bi = [render cachedImage];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5439 if(bi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5440 {
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5441 CGContextRef context = _dw_draw_context(bi, NO);
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5442
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5443 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5444 UIGraphicsPushContext(context);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5445
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446 UIColor *fgcolor = pthread_getspecific(_dw_fg_color_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5447 UIColor *bgcolor = pthread_getspecific(_dw_bg_color_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 if(bgcolor)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 [dict setValue:bgcolor forKey:NSBackgroundColorAttributeName];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 if(font)
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5452 [dict setValue:font forKey:NSFontAttributeName];
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5453 [nstr drawAtPoint:CGPointMake(x, y) withAttributes:dict];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 [dict release];
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5455 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5456 UIGraphicsPopContext();
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5461 /* Query the width and height of a text string.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5463 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5464 * pixmap: Handle to the pixmap. (choose only one of these)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5465 * text: Text to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5466 * width: Pointer to a variable to be filled in with the width.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5467 * height Pointer to a variable to be filled in with the height.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5468 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5469 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, const char *text, int *width, int *height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5470 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5471 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5472 NSString *nstr;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5473 UIFont *font = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5475
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5476 nstr = [NSString stringWithUTF8String:text];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5477
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5478 /* Check the pixmap for associated object or font */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479 if(pixmap)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481 object = pixmap->handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5482 font = pixmap->font;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5483 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5484 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5485 /* If we didn't get a font from the pixmap... try the associated object */
2423
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
5486 if(!font && ([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[UIControl class]]
b4cb136b5222 iOS: Special handling for combined text/image buttons like check and radio
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2422
diff changeset
5487 || [object isKindOfClass:[UILabel class]]))
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5488 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5489 font = [object font];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5490 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5491 /* If we got a font... add it to the dictionary */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5492 if(font)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5493 {
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5494 [dict setValue:font forKey:NSFontAttributeName];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5495 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5496 /* Calculate the size of the string */
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
5497 CGSize size = [nstr sizeWithAttributes:dict];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5498 [dict release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5499 /* Return whatever information we can */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5500 if(width)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5501 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5502 *width = size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5503 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504 if(height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5505 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506 *height = size.height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 /* Draw a polygon on a window (preferably a render window).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5514 * pixmap: Handle to the pixmap. (choose only one of these)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5515 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5516 * x: X coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5517 * y: Y coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5518 * width: Width of rectangle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5519 * height: Height of rectangle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5520 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5521 DW_FUNCTION_DEFINITION(dw_draw_polygon, void, HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5522 DW_FUNCTION_ADD_PARAM6(handle, pixmap, flags, npoints, x, y)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5523 DW_FUNCTION_NO_RETURN(dw_draw_polygon)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5524 DW_FUNCTION_RESTORE_PARAM6(handle, HWND, pixmap, HPIXMAP, flags, int, npoints, int, x, int *, y, int *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5525 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5526 DW_FUNCTION_INIT;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5527 DWImage *bi = _dw_dest_image(pixmap, handle);
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5528 CGContextRef context = _dw_draw_context(bi, flags & DW_DRAW_NOAA ? NO : YES);
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5529
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5530 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5531 UIGraphicsPushContext(context);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5532
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5533 if(bi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5534 {
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5535 UIBezierPath* aPath = [UIBezierPath bezierPath];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5536 UIColor *color = pthread_getspecific(_dw_fg_color_key);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5537 int z;
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5538
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5539 [color set];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5540
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5541 [aPath moveToPoint:CGPointMake(*x + 0.5, *y + 0.5)];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5542 for(z=1;z<npoints;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5543 {
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5544 [aPath addLineToPoint:CGPointMake(x[z] + 0.5, y[z] + 0.5)];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5545 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5546 [aPath closePath];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5547 if(flags & DW_DRAW_FILL)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5548 [aPath fill];
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5549 else
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5550 [aPath stroke];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5551 }
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5552 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5553 UIGraphicsPopContext();
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557 /* Draw a rectangle on a window (preferably a render window).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5558 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5559 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 * pixmap: Handle to the pixmap. (choose only one of these)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561 * flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562 * x: X coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5563 * y: Y coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564 * width: Width of rectangle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5565 * height: Height of rectangle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5566 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5567 DW_FUNCTION_DEFINITION(dw_draw_rect, void, HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5568 DW_FUNCTION_ADD_PARAM7(handle, pixmap, flags, x, y, width, height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5569 DW_FUNCTION_NO_RETURN(dw_draw_rect)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5570 DW_FUNCTION_RESTORE_PARAM7(handle, HWND, pixmap, HPIXMAP, flags, int, x, int, y, int, width, int, height, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5571 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5572 DW_FUNCTION_INIT;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5573 DWImage *bi = _dw_dest_image(pixmap, handle);
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5574 CGContextRef context = _dw_draw_context(bi, flags & DW_DRAW_NOAA ? NO : YES);
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5575
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5576 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5577 UIGraphicsPushContext(context);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5578
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 if(bi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 UIColor *color = pthread_getspecific(_dw_fg_color_key);
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5582 UIBezierPath *bp = [UIBezierPath bezierPathWithRect:CGRectMake(x, y, width, height)];;
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5583
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 [color set];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 if(flags & DW_DRAW_FILL)
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5587 [bp fill];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 else
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5589 [bp stroke];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 }
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5591 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5592 UIGraphicsPopContext();
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5596 /* Draw an arc on a window (preferably a render window).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5597 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5598 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5599 * pixmap: Handle to the pixmap. (choose only one of these)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5600 * flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5601 * DW_DRAW_FULL will draw a complete circle/elipse.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5602 * xorigin: X coordinate of center of arc.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5603 * yorigin: Y coordinate of center of arc.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5604 * x1: X coordinate of first segment of arc.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5605 * y1: Y coordinate of first segment of arc.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5606 * x2: X coordinate of second segment of arc.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5607 * y2: Y coordinate of second segment of arc.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5608 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5609 DW_FUNCTION_DEFINITION(dw_draw_arc, void, HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5610 DW_FUNCTION_ADD_PARAM9(handle, pixmap, flags, xorigin, yorigin, x1, y1, x2, y2)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5611 DW_FUNCTION_NO_RETURN(dw_draw_arc)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5612 DW_FUNCTION_RESTORE_PARAM9(handle, HWND, pixmap, HPIXMAP, flags, int, xorigin, int, yorigin, int, x1, int, y1, int, x2, int, y2, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5613 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5614 DW_FUNCTION_INIT;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5615 DWImage *bi = _dw_dest_image(pixmap, handle);
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5616 CGContextRef context = _dw_draw_context(bi, flags & DW_DRAW_NOAA ? NO : YES);
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5617
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5618 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5619 UIGraphicsPushContext(context);
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
5620
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5621 if(bi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5622 {
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5623 UIBezierPath* aPath;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5624 UIColor *color = pthread_getspecific(_dw_fg_color_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5625 [color set];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5626
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5627 /* Special case of a full circle/oval */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5628 if(flags & DW_DRAW_FULL)
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5629 aPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(x1, y1, x2 - x1, y2 - y1)];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5630 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5631 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5632 double a1 = atan2((y1-yorigin), (x1-xorigin));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633 double a2 = atan2((y2-yorigin), (x2-xorigin));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5634 double dx = xorigin - x1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5635 double dy = yorigin - y1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5636 double r = sqrt(dx*dx + dy*dy);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5638 /* Prepare to draw */
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5639 aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(xorigin, yorigin)
2440
070337dd4ef7 iOS: Fix dw_draw_arc()... iOS is in raidans not degrees. Thanks wiliz on freenode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2438
diff changeset
5640 radius:r startAngle:a1 endAngle:a2 clockwise:YES];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5642 /* If the fill flag is passed */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5643 if(flags & DW_DRAW_FILL)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5644 [aPath fill];
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5645 else
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
5646 [aPath stroke];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5647 }
2435
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5648 if(context)
7d6c8b7f41d9 iOS: Implement graphic context pushing and popping during draw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2434
diff changeset
5649 UIGraphicsPopContext();
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5650 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5651 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5652
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5653 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 * Create a tree object to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5656 * id: An ID to be used for getting the resource from the
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5657 * resource file.
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5658 * Returns:
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5659 * A handle to a tree window or NULL on failure.
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5660 */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5661 HWND API dw_tree_new(ULONG cid)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5662 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5663 /* TODO: Implement tree for iOS if possible */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5664 return 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5665 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5666
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5667 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668 * Inserts an item into a tree window (widget) after another item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5669 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5670 * handle: Handle to the tree to be inserted.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5671 * item: Handle to the item to be positioned after.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5672 * title: The text title of the entry.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5673 * icon: Handle to coresponding icon.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5674 * parent: Parent handle or 0 if root.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5675 * itemdata: Item specific data.
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5676 * Returns:
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5677 * A handle to a tree item or NULL on failure.
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5678 */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5679 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5680 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5681 /* TODO: Implement tree for iOS if possible */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5682 return 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5683 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5684
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5685 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5686 * Inserts an item into a tree window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5687 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5688 * handle: Handle to the tree to be inserted.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5689 * title: The text title of the entry.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5690 * icon: Handle to coresponding icon.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5691 * parent: Parent handle or 0 if root.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5692 * itemdata: Item specific data.
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5693 * Returns:
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5694 * A handle to a tree item or NULL on failure.
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5695 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696 HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 {
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5698 /* TODO: Implement tree for iOS if possible */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5699 return 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5700 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5701
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5702 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5703 * Gets the text an item in a tree window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5704 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5705 * handle: Handle to the tree containing the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5706 * item: Handle of the item to be modified.
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5707 * Returns:
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5708 * A malloc()ed buffer of item text to be dw_free()ed or NULL on error.
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5709 */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5710 char * API dw_tree_get_title(HWND handle, HTREEITEM item)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5711 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5712 /* TODO: Implement tree for iOS if possible */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5713 return NULL;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5714 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5715
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5717 * Gets the text an item in a tree window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5718 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5719 * handle: Handle to the tree containing the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5720 * item: Handle of the item to be modified.
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5721 * Returns:
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5722 * A handle to a tree item or NULL on failure.
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5723 */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5724 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5725 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5726 /* TODO: Implement tree for iOS if possible */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5727 return 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5728 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5730 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5731 * Sets the text and icon of an item in a tree window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5732 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 * handle: Handle to the tree containing the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 * item: Handle of the item to be modified.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735 * title: The text title of the entry.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 * icon: Handle to coresponding icon.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 */
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5738 void API dw_tree_item_change(HWND handle, HTREEITEM item, const char *title, HICN icon)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5739 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5740 /* TODO: Implement tree for iOS if possible */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5741
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5744 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 * Sets the item data of a tree item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5746 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5747 * handle: Handle to the tree containing the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 * item: Handle of the item to be modified.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749 * itemdata: User defined data to be associated with item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750 */
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5751 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5752 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5753 /* TODO: Implement tree for iOS if possible */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5754
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5755 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5756
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5757 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758 * Gets the item data of a tree item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 * handle: Handle to the tree containing the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 * item: Handle of the item to be modified.
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5762 * Returns:
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5763 * A pointer to tree item data or NULL on failure.
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5764 */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5765 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5766 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5767 /* TODO: Implement tree for iOS if possible */
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5768 return NULL;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5769 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5771 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5772 * Sets this item as the active selection.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5773 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5774 * handle: Handle to the tree window (widget) to be selected.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5775 * item: Handle to the item to be selected.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5776 */
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5777 void API dw_tree_item_select(HWND handle, HTREEITEM item)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5778 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5779 /* TODO: Implement tree for iOS if possible */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5780 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5781
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5782 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5783 * Removes all nodes from a tree.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5784 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5785 * handle: Handle to the window (widget) to be cleared.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5786 */
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5787 void API dw_tree_clear(HWND handle)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5788 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5789 /* TODO: Implement tree for iOS if possible */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5790 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5791
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5792 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5793 * Expands a node on a tree.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5794 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5795 * handle: Handle to the tree window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5796 * item: Handle to node to be expanded.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797 */
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5798 void API dw_tree_item_expand(HWND handle, HTREEITEM item)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5799 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5800 /* TODO: Implement tree for iOS if possible */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5802
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5804 * Collapses a node on a tree.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5805 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5806 * handle: Handle to the tree window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5807 * item: Handle to node to be collapsed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5808 */
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5809 void API dw_tree_item_collapse(HWND handle, HTREEITEM item)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5810 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5811 /* TODO: Implement tree for iOS if possible */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5812 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5813
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5814 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5815 * Removes a node from a tree.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5816 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5817 * handle: Handle to the window (widget) to be cleared.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5818 * item: Handle to node to be deleted.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5819 */
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5820 void API dw_tree_item_delete(HWND handle, HTREEITEM item)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5821 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
5822 /* TODO: Implement tree for iOS if possible */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5823 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5824
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5825 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5826 * Create a container object to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5827 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5828 * id: An ID to be used for getting the resource from the
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5829 * resource file.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5830 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5831 DW_FUNCTION_DEFINITION(dw_container_new, HWND, ULONG cid, int multi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5832 DW_FUNCTION_ADD_PARAM2(cid, multi)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5833 DW_FUNCTION_RETURN(dw_container_new, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5834 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5835 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5836 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837 DWContainer *cont = _dw_cont_new(cid, multi);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838 DW_FUNCTION_RETURN_THIS(cont);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 * Sets up the container columns.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844 * handle: Handle to the container to be configured.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5845 * flags: An array of unsigned longs with column flags.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5846 * titles: An array of strings with column text titles.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5847 * count: The number of columns (this should match the arrays).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5848 * separator: The column number that contains the main separator.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5849 * (this item may only be used in OS/2)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5850 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5851 DW_FUNCTION_DEFINITION(dw_container_setup, int, HWND handle, unsigned long *flags, char **titles, int count, int separator)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5852 DW_FUNCTION_ADD_PARAM5(handle, flags, titles, count, separator)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5853 DW_FUNCTION_RETURN(dw_container_setup, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5854 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, flags, unsigned long *, titles, char **, count, int, DW_UNUSED(separator), int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5855 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5856 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5857 int z, retval = DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5858 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5859
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5860 [cont setup];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5861
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5862 for(z=0;z<count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5863 {
2387
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
5864 /* Even though we don't have columns on iOS, we save the data...
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
5865 * So we can simulate columns when displaying the data in the list.
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
5866 */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5867 NSString *title = [NSString stringWithUTF8String:titles[z]];
2387
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
5868
deb2345f4518 iOS: Implement the UITableViewDataSource protocol so DWContainer doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2385
diff changeset
5869 [cont addColumn:title andType:(int)flags[z]];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5871 DW_FUNCTION_RETURN_THIS(retval);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5873
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5875 * Configures the main filesystem columnn title for localization.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5876 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5877 * handle: Handle to the container to be configured.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5878 * title: The title to be displayed in the main column.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5880 void API dw_filesystem_set_column_title(HWND handle, const char *title)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5881 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5882 char *newtitle = strdup(title ? title : "");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5883
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5884 dw_window_set_data(handle, "_dw_coltitle", newtitle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5885 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5886
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5887 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5888 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5889 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5890 * handle: Handle to the container to be configured.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5891 * flags: An array of unsigned longs with column flags.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5892 * titles: An array of strings with column text titles.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5893 * count: The number of columns (this should match the arrays).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5894 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5895 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5896 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5897 char **newtitles = malloc(sizeof(char *) * (count + 1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5898 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5899 char *coltitle = (char *)dw_window_get_data(handle, "_dw_coltitle");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5900 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5901
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5902 newtitles[0] = coltitle ? coltitle : "Filename";
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5903
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5904 newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5905
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5906 memcpy(&newtitles[1], titles, sizeof(char *) * count);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5907 memcpy(&newflags[1], flags, sizeof(unsigned long) * count);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5908
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5909 dw_container_setup(handle, newflags, newtitles, count + 1, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5910 [cont setFilesystem:YES];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5911
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5912 if(coltitle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 dw_window_set_data(handle, "_dw_coltitle", NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915 free(coltitle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5917 free(newtitles);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918 free(newflags);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5922 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 * Allocates memory used to populate a container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5926 * rowcount: The number of items to be populated.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5927 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928 DW_FUNCTION_DEFINITION(dw_container_alloc, void *, HWND handle, int rowcount)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5929 DW_FUNCTION_ADD_PARAM2(handle, rowcount)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5930 DW_FUNCTION_RETURN(dw_container_alloc, void *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5931 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, rowcount, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5932 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5933 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5934 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5935 [cont addRows:rowcount];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5936 DW_FUNCTION_RETURN_THIS(cont);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5937 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 * Sets an item in specified row and column to the given data.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 * pointer: Pointer to the allocated memory in dw_container_alloc().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944 * column: Zero based column of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5946 * data: Pointer to the data to be added.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 DW_FUNCTION_DEFINITION(dw_container_set_item, void, HWND handle, void *pointer, int column, int row, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5949 DW_FUNCTION_ADD_PARAM5(handle, pointer, column, row, data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5950 DW_FUNCTION_NO_RETURN(dw_container_set_item)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5951 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pointer, void *, column, int, row, int, data, void *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5952 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5953 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 id icon = nil, text = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956 int type = [cont cellType:column];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 int lastadd = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959 /* If pointer is NULL we are getting a change request instead of set */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5960 if(pointer)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 lastadd = [cont lastAddPoint];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5962
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5963 if(data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965 if(type & DW_CFA_BITMAPORICON)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 icon = *((UIImage **)data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969 else if(type & DW_CFA_STRING)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5970 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5971 char *str = *((char **)data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5972 text = [ NSString stringWithUTF8String:str ];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5975 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5976 char textbuffer[101] = {0};
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978 if(type & DW_CFA_ULONG)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980 ULONG tmp = *((ULONG *)data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 snprintf(textbuffer, 100, "%lu", tmp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 else if(type & DW_CFA_DATE)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5986 struct tm curtm;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5987 CDATE cdate = *((CDATE *)data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5989 memset( &curtm, 0, sizeof(curtm) );
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 curtm.tm_mday = cdate.day;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5991 curtm.tm_mon = cdate.month - 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5992 curtm.tm_year = cdate.year - 1900;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5993
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5994 strftime(textbuffer, 100, "%x", &curtm);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5995 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5996 else if(type & DW_CFA_TIME)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5997 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5998 struct tm curtm;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5999 CTIME ctime = *((CTIME *)data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6000
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6001 memset( &curtm, 0, sizeof(curtm) );
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6002 curtm.tm_hour = ctime.hours;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6003 curtm.tm_min = ctime.minutes;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6004 curtm.tm_sec = ctime.seconds;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6005
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6006 strftime(textbuffer, 100, "%X", &curtm);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6007 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6008 if(textbuffer[0])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6009 text = [ NSString stringWithUTF8String:textbuffer ];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6010 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6012
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6013 id object = [cont getRow:(row+lastadd) and:column];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6014
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015 /* If it is a cell, change the content of the cell */
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6016 if([object isMemberOfClass:[UITableViewCell class]])
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6017 {
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6018 UITableViewCell *cell = object;
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6019
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020 if(icon)
2417
ccfc4ee9c4a7 iOS: Missed a few other DWContainer fixes in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2416
diff changeset
6021 [[cell imageView] setImage:icon];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 else
2417
ccfc4ee9c4a7 iOS: Missed a few other DWContainer fixes in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2416
diff changeset
6023 [[cell textLabel] setText:text];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6024 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 else /* Otherwise replace it with a new cell */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6026 [cont editCell:_dw_table_cell_view_new(icon, text) at:(row+lastadd) and:column];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
6027 [cont setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6029 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6031 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 * Changes an existing item in specified row and column to the given data.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6033 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6034 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6035 * column: Zero based column of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6036 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6037 * data: Pointer to the data to be added.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6038 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6039 void API dw_container_change_item(HWND handle, int column, int row, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6040 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6041 dw_container_set_item(handle, NULL, column, row, data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6042 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045 * Changes an existing item in specified row and column to the given data.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6046 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 * column: Zero based column of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050 * data: Pointer to the data to be added.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054 dw_container_change_item(handle, column+1, row, data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6056
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6058 * Changes an item in specified row and column to the given data.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6059 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6060 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 * pointer: Pointer to the allocated memory in dw_container_alloc().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6062 * column: Zero based column of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064 * data: Pointer to the data to be added.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066 void API dw_filesystem_change_file(HWND handle, int row, const char *filename, HICN icon)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 dw_filesystem_set_file(handle, NULL, row, filename, icon);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 * Sets an item in specified row and column to the given data.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6073 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6075 * pointer: Pointer to the allocated memory in dw_container_alloc().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6076 * column: Zero based column of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6077 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6078 * data: Pointer to the data to be added.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6079 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6080 DW_FUNCTION_DEFINITION(dw_filesystem_set_file, void, HWND handle, void *pointer, int row, const char *filename, HICN icon)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081 DW_FUNCTION_ADD_PARAM5(handle, pointer, row, filename, icon)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 DW_FUNCTION_NO_RETURN(dw_filesystem_set_file)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pointer, void *, row, int, filename, char *, icon, HICN)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087 NSString *text = filename ? [NSString stringWithUTF8String:filename] : nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088 int lastadd = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 /* If pointer is NULL we are getting a change request instead of set */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 if(pointer)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 lastadd = [cont lastAddPoint];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 id object = [cont getRow:(row+lastadd) and:0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 /* If it is a cell, change the content of the cell */
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6097 if([object isMemberOfClass:[UITableViewCell class]])
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6098 {
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6099 UITableViewCell *cell = object;
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6100
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 if(icon)
2417
ccfc4ee9c4a7 iOS: Missed a few other DWContainer fixes in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2416
diff changeset
6102 [[cell imageView] setImage:icon];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 if(text)
2417
ccfc4ee9c4a7 iOS: Missed a few other DWContainer fixes in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2416
diff changeset
6104 [[cell textLabel] setText:text];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 else /* Otherwise replace it with a new cell */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107 [cont editCell:_dw_table_cell_view_new(icon, text) at:(row+lastadd) and:0];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
6108 [cont setNeedsDisplay];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6111
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6112 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6113 * Sets an item in specified row and column to the given data.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6114 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6115 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6116 * pointer: Pointer to the allocated memory in dw_container_alloc().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6117 * column: Zero based column of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6118 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 * data: Pointer to the data to be added.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6122 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6123 dw_container_set_item(handle, pointer, column+1, row, data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6125
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6126 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6127 * Gets column type for a container column
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6128 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6129 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6130 * column: Zero based column.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 DW_FUNCTION_DEFINITION(dw_container_get_column_type, int, HWND handle, int column)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133 DW_FUNCTION_ADD_PARAM2(handle, column)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6134 DW_FUNCTION_RETURN(dw_container_get_column_type, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, column, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6136 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6137 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6138 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6139 int rc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6140 int flag = [cont cellType:column];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6141 if(flag & DW_CFA_BITMAPORICON)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142 rc = DW_CFA_BITMAPORICON;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143 else if(flag & DW_CFA_STRING)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6144 rc = DW_CFA_STRING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6145 else if(flag & DW_CFA_ULONG)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146 rc = DW_CFA_ULONG;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6147 else if(flag & DW_CFA_DATE)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6148 rc = DW_CFA_DATE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6149 else if(flag & DW_CFA_TIME)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6150 rc = DW_CFA_TIME;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6152 rc = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153 DW_FUNCTION_RETURN_THIS(rc);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6154 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6155
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6156 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6157 * Gets column type for a filesystem container column
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6158 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6159 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6160 * column: Zero based column.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6161 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6162 int API dw_filesystem_get_column_type(HWND handle, int column)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6163 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6164 return dw_container_get_column_type(handle, column+1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6165 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6166
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6167 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6168 * Sets the alternating row colors for container window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6169 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6170 * handle: The window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6171 * oddcolor: Odd row background color in DW_RGB format or a default color index.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6172 * evencolor: Even row background color in DW_RGB format or a default color index.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6173 * DW_RGB_TRANSPARENT will disable coloring rows.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6174 * DW_CLR_DEFAULT will use the system default alternating row colors.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6175 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6176 DW_FUNCTION_DEFINITION(dw_container_set_stripe, void, HWND handle, unsigned long oddcolor, unsigned long evencolor)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6177 DW_FUNCTION_ADD_PARAM3(handle, oddcolor, evencolor)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6178 DW_FUNCTION_NO_RETURN(dw_container_set_stripe)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6179 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, oddcolor, unsigned long, evencolor, unsigned long)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 [cont setRowBgOdd:oddcolor
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6184 andEven:evencolor];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189 * Sets the width of a column in the container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6190 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6191 * handle: Handle to window (widget) of container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6192 * column: Zero based column of width being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6193 * width: Width of column in pixels.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6194 */
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6195 void API dw_container_set_column_width(HWND handle, int column, int width)
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6196 {
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6197 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6198
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6199 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6200 * Sets the title of a row in the container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6201 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6202 * pointer: Pointer to the allocated memory in dw_container_alloc().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6203 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6204 * title: String title of the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6205 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6206 DW_FUNCTION_DEFINITION(dw_container_set_row_title, void, void *pointer, int row, const char *title)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6207 DW_FUNCTION_ADD_PARAM3(pointer, row, title)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6208 DW_FUNCTION_NO_RETURN(dw_container_set_row_title)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6209 DW_FUNCTION_RESTORE_PARAM3(pointer, void *, row, int, title, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6210 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6211 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6212 DWContainer *cont = pointer;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6213 int lastadd = [cont lastAddPoint];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6214 [cont setRow:(row+lastadd) title:title];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6215 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6216 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6217
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6218
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6219 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6220 * Sets the data pointer of a row in the container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6221 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 * pointer: Pointer to the allocated memory in dw_container_alloc().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6223 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6224 * data: Data pointer.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6225 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6226 DW_FUNCTION_DEFINITION(dw_container_set_row_data, void, void *pointer, int row, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6227 DW_FUNCTION_ADD_PARAM3(pointer, row, data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6228 DW_FUNCTION_NO_RETURN(dw_container_set_row_data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 DW_FUNCTION_RESTORE_PARAM3(pointer, void *, row, int, data, void *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6230 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232 DWContainer *cont = pointer;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6233 int lastadd = [cont lastAddPoint];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6234 [cont setRowData:(row+lastadd) title:data];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6235 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6236 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6237
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6238
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6239 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6240 * Sets the title of a row in the container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6241 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6242 * handle: Handle to window (widget) of container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6243 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6244 * title: String title of the item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6245 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6246 DW_FUNCTION_DEFINITION(dw_container_change_row_title, void, HWND handle, int row, const char *title)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6247 DW_FUNCTION_ADD_PARAM3(handle, row, title)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6248 DW_FUNCTION_NO_RETURN(dw_container_change_row_title)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6249 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, row, int, title, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6250 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6251 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6252 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6253 [cont setRow:row title:title];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6254 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6255 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6256
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6257 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6258 * Sets the data pointer of a row in the container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6259 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6260 * handle: Handle to window (widget) of container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6261 * row: Zero based row of data being set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6262 * data: Data pointer.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6263 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6264 DW_FUNCTION_DEFINITION(dw_container_change_row_data, void, HWND handle, int row, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6265 DW_FUNCTION_ADD_PARAM3(handle, row, data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6266 DW_FUNCTION_NO_RETURN(dw_container_change_row_data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6267 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, row, int, data, void *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6268 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6269 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6270 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6271 [cont setRowData:row title:data];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6272 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6273 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6274
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6275 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6276 * Sets the title of a row in the container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6277 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6278 * handle: Handle to the container window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6279 * pointer: Pointer to the allocated memory in dw_container_alloc().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6280 * rowcount: The number of rows to be inserted.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6281 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6282 DW_FUNCTION_DEFINITION(dw_container_insert, void, HWND handle, void *pointer, int rowcount)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6283 DW_FUNCTION_ADD_PARAM3(handle, pointer, rowcount)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6284 DW_FUNCTION_NO_RETURN(dw_container_insert)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6285 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, DW_UNUSED(pointer), void *, DW_UNUSED(rowcount), int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6286 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6287 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6288 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6289 [cont reloadData];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6290 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6291 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6292
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6293 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6294 * Removes all rows from a container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6295 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6296 * handle: Handle to the window (widget) to be cleared.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6297 * redraw: TRUE to cause the container to redraw immediately.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6298 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6299 DW_FUNCTION_DEFINITION(dw_container_clear, void, HWND handle, int redraw)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6300 DW_FUNCTION_ADD_PARAM2(handle, redraw)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6301 DW_FUNCTION_NO_RETURN(dw_container_clear)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6302 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, redraw, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6303 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6304 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6305 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6306 [cont clear];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6307 if(redraw)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6308 [cont reloadData];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6309 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6310 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6311
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6312 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6313 * Removes the first x rows from a container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6314 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6315 * handle: Handle to the window (widget) to be deleted from.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6316 * rowcount: The number of rows to be deleted.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6317 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6318 DW_FUNCTION_DEFINITION(dw_container_delete, void, HWND handle, int rowcount)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6319 DW_FUNCTION_ADD_PARAM2(handle, rowcount)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6320 DW_FUNCTION_NO_RETURN(dw_container_delete)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6321 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, rowcount, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6322 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6323 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6324 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6325 int x;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6326
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6327 for(x=0;x<rowcount;x++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6328 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6329 [cont removeRow:0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6330 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6331 [cont reloadData];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6332 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6333 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6334
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6335 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6336 * Scrolls container up or down.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6337 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6338 * handle: Handle to the window (widget) to be scrolled.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6341 * rows: The number of rows to be scrolled.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342 */
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
6343 DW_FUNCTION_DEFINITION(dw_container_scroll, void, HWND handle, int direction, DW_UNUSED(long rows))
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344 DW_FUNCTION_ADD_PARAM3(handle, direction, rows)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6345 DW_FUNCTION_NO_RETURN(dw_container_scroll)
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
6346 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, direction, int, DW_UNUSED(rows), long)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6347 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6348 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6349 DWContainer *cont = handle;
2388
d84cd4227b21 iOS: Switch to UITableViewDataSource method numberOfRowsInSection:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2387
diff changeset
6350 int rowcount = (int)[cont numberOfRowsInSection:0];
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
6351 CGPoint offset = [cont contentOffset];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6352
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6353 /* Safety check */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6354 if(rowcount < 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6355 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6356 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6357 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6358
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6359 switch(direction)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6360 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6361 case DW_SCROLL_TOP:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6362 {
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6363 offset.y = 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6364 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6365 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6366 case DW_SCROLL_BOTTOM:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6367 {
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
6368 offset.y = [cont contentSize].height - [cont visibleSize].height;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6370 }
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
6371 /* TODO: Currently scrolling a full page, need to use row parameter instead */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6372 case DW_SCROLL_UP:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6373 {
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
6374 offset.y -= [cont visibleSize].height;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6375 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6376 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6377 case DW_SCROLL_DOWN:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6378 {
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
6379 offset.y += [cont visibleSize].height;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6380 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6381 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6382 }
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6383 if(offset.y < 0)
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6384 offset.y = 0;
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
6385 [cont setContentOffset:offset];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6386 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6387 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6388
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6389 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6390 * Starts a new query of a container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6391 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6392 * handle: Handle to the window (widget) to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6393 * flags: If this parameter is DW_CRA_SELECTED it will only
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6394 * return items that are currently selected. Otherwise
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395 * it will return all records in the container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6396 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6397 DW_FUNCTION_DEFINITION(dw_container_query_start, char *, HWND handle, unsigned long flags)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6398 DW_FUNCTION_ADD_PARAM2(handle, flags)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6399 DW_FUNCTION_RETURN(dw_container_query_start, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6400 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6401 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6402 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6403 DWContainer *cont = handle;
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6404 NSArray *selected = [cont indexPathsForSelectedRows];
2381
3777ea1cccdb iOS: Continuing conversion...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2380
diff changeset
6405 NSIndexPath *result = [selected firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6406 void *retval = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6407
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6408 if(result)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6409 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6410 if(flags & DW_CR_RETDATA)
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6411 retval = [cont getRowData:(int)result.row];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6412 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6413 {
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6414 char *temp = [cont getRowTitle:(int)result.row];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6415 if(temp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6416 retval = strdup(temp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6417 }
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6418 [cont setLastQueryPoint:1];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6419 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6420 DW_FUNCTION_RETURN_THIS(retval);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6421 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6422
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6423 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6424 * Continues an existing query of a container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6425 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6426 * handle: Handle to the window (widget) to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6427 * flags: If this parameter is DW_CRA_SELECTED it will only
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6428 * return items that are currently selected. Otherwise
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6429 * it will return all records in the container.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6430 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6431 DW_FUNCTION_DEFINITION(dw_container_query_next, char *, HWND handle, unsigned long flags)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6432 DW_FUNCTION_ADD_PARAM2(handle, flags)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6433 DW_FUNCTION_RETURN(dw_container_query_next, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6434 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6435 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6436 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6437 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6438 int lastQueryPoint = [cont lastQueryPoint];
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6439 NSArray *selected = [cont indexPathsForSelectedRows];
2429
89f4aba2e387 iOS: Put back missing tree selection code, since it is apparently also used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2428
diff changeset
6440 NSIndexPath *result = lastQueryPoint < [selected count] ? [selected objectAtIndex:lastQueryPoint] : nil;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6441 void *retval = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6442
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6443 if(result)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6444 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6445 if(flags & DW_CR_RETDATA)
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6446 retval = [cont getRowData:(int)result.row];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448 {
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6449 char *temp = [cont getRowTitle:(int)result.row];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 if(temp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6451 retval = strdup(temp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6452 }
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
6453 [cont setLastQueryPoint:(int)lastQueryPoint+1];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6454 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6455 DW_FUNCTION_RETURN_THIS(retval);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6456 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6457
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6458 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6459 * Cursors the item with the text speficied, and scrolls to that item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6460 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6461 * handle: Handle to the window (widget) to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6462 * text: Text usually returned by dw_container_query().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6463 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6464 DW_FUNCTION_DEFINITION(dw_container_cursor, void, HWND handle, const char *text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6465 DW_FUNCTION_ADD_PARAM2(handle, text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6466 DW_FUNCTION_NO_RETURN(dw_container_cursor)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6467 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6468 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6469 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6470 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6471 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6472 char *thistext;
2388
d84cd4227b21 iOS: Switch to UITableViewDataSource method numberOfRowsInSection:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2387
diff changeset
6473 int x, count = (int)[cont numberOfRowsInSection:0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6474
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6475 for(x=0;x<count;x++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6476 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6477 thistext = [cont getRowTitle:x];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6478
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6479 if(thistext && strcmp(thistext, text) == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6480 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6481 NSIndexPath *ip = [NSIndexPath indexPathForRow:(NSUInteger)x inSection:0];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6482
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6483 [cont selectRowAtIndexPath:ip
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6484 animated:NO
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6485 scrollPosition:UITableViewScrollPositionNone];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6486 x=count;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6487 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6488 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6489 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6490 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6491 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6492 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6493
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6494 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6495 * Cursors the item with the data speficied, and scrolls to that item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6496 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6497 * handle: Handle to the window (widget) to be queried.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6498 * data: Data associated with the row.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6499 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6500 DW_FUNCTION_DEFINITION(dw_container_cursor_by_data, void, HWND handle, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6501 DW_FUNCTION_ADD_PARAM2(handle, data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6502 DW_FUNCTION_NO_RETURN(dw_container_cursor_by_data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6503 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, data, void *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6507 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6508 void *thisdata;
2388
d84cd4227b21 iOS: Switch to UITableViewDataSource method numberOfRowsInSection:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2387
diff changeset
6509 int x, count = (int)[cont numberOfRowsInSection:0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6510
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6511 for(x=0;x<count;x++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6512 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6513 thisdata = [cont getRowData:x];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6514
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6515 if(thisdata == data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6516 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6517 NSIndexPath *ip = [NSIndexPath indexPathForRow:(NSUInteger)x inSection:0];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6518
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6519 [cont selectRowAtIndexPath:ip
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6520 animated:NO
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6521 scrollPosition:UITableViewScrollPositionNone];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6522 x=count;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6523 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6524 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6525 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6526 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6527 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6528 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6529
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6530 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6531 * Deletes the item with the text speficied.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6532 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6533 * handle: Handle to the window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6534 * text: Text usually returned by dw_container_query().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6535 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6536 DW_FUNCTION_DEFINITION(dw_container_delete_row, void, HWND handle, const char *text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6537 DW_FUNCTION_ADD_PARAM2(handle, text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6538 DW_FUNCTION_NO_RETURN(dw_container_delete_row)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6539 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6540 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6541 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6542 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6543 char *thistext;
2388
d84cd4227b21 iOS: Switch to UITableViewDataSource method numberOfRowsInSection:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2387
diff changeset
6544 int x, count = (int)[cont numberOfRowsInSection:0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6545
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6546 for(x=0;x<count;x++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6547 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6548 thistext = [cont getRowTitle:x];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6549
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550 if(thistext && strcmp(thistext, text) == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6551 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 [cont removeRow:x];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6553 [cont reloadData];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 x=count;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6555 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6556 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6557 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6558 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6559 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6560
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6561 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6562 * Deletes the item with the data speficied.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6563 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6564 * handle: Handle to the window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6565 * data: Data specified.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6566 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6567 DW_FUNCTION_DEFINITION(dw_container_delete_row_by_data, void, HWND handle, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6568 DW_FUNCTION_ADD_PARAM2(handle, data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6569 DW_FUNCTION_NO_RETURN(dw_container_delete_row_by_data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6570 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, data, void *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6571 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6572 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6573 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6574 void *thisdata;
2388
d84cd4227b21 iOS: Switch to UITableViewDataSource method numberOfRowsInSection:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2387
diff changeset
6575 int x, count = (int)[cont numberOfRowsInSection:0];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6576
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6577 for(x=0;x<count;x++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6578 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6579 thisdata = [cont getRowData:x];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6580
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6581 if(thisdata == data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6582 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 [cont removeRow:x];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6584 [cont reloadData];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585 x=count;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6586 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6587 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6588 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6589 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6590 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6591
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6592 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6593 * Optimizes the column widths so that all data is visible.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6594 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6595 * handle: Handle to the window (widget) to be optimized.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6596 */
2379
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
6597 void dw_container_optimize(HWND handle)
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
6598 {
e35887009bb5 iOS: Remove tree functionality, combobox and radio button... include links
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2378
diff changeset
6599 /* TODO: Not sure if we need to implement this on iOS */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6600 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6601
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6602 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6603 * Inserts an icon into the taskbar.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6604 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6605 * handle: Window handle that will handle taskbar icon messages.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6606 * icon: Icon handle to display in the taskbar.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6607 * bubbletext: Text to show when the mouse is above the icon.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6608 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6609 void API dw_taskbar_insert(HWND handle, HICN icon, const char *bubbletext)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6610 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6611 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6612
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6614 * Deletes an icon from the taskbar.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6615 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6616 * handle: Window handle that was used with dw_taskbar_insert().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6617 * icon: Icon handle that was used with dw_taskbar_insert().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6618 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6619 void API dw_taskbar_delete(HWND handle, HICN icon)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6620 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6621 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6622
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6623 /* Internal function to keep HICNs from getting too big */
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
6624 void _dw_icon_resize(UIImage *image)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6625 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6626 if(image)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6627 {
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
6628 CGSize size = [image size];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6629 if(size.width > 24 || size.height > 24)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6630 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6631 if(size.width > 24)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6632 size.width = 24;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6633 if(size.height > 24)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6634 size.height = 24;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6635 #if 0 /* TODO: UIImage is immutable, duplicate? */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6636 [image setSize:size];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6637 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6638 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6639 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6640 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6641
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6642 /* Internal version that does not resize the image */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6643 HICN _dw_icon_load(unsigned long resid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6644 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6645 NSBundle *bundle = [NSBundle mainBundle];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6646 NSString *respath = [bundle resourcePath];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6647 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6648 UIImage *image = [[UIImage alloc] initWithContentsOfFile:filepath];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6649 return image;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6650 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6651
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6652 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6653 * Obtains an icon from a module (or header in GTK).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6654 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6655 * module: Handle to module (DLL) in OS/2 and Windows.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6656 * id: A unsigned long id int the resources on OS/2 and
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6657 * Windows, on GTK this is converted to a pointer
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6658 * to an embedded XPM.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6659 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6660 HICN API dw_icon_load(unsigned long module, unsigned long resid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6661 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6662 UIImage *image = _dw_icon_load(resid);
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
6663 _dw_icon_resize(image);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6664 return image;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6665 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6666
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6667 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6668 * Obtains an icon from a file.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6669 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6670 * filename: Name of the file, omit extention to have
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6671 * DW pick the appropriate file extension.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6672 * (ICO on OS/2 or Windows, XPM on Unix)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6673 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6674 HICN API dw_icon_load_from_file(const char *filename)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6675 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6676 char *ext = _dw_get_image_extension( filename );
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6677
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6678 NSString *nstr = [ NSString stringWithUTF8String:filename ];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6679 UIImage *image = [[UIImage alloc] initWithContentsOfFile:nstr];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6680 if(!image && ext)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6681 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6682 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6683 image = [[UIImage alloc] initWithContentsOfFile:nstr];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6684 }
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
6685 _dw_icon_resize(image);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6686 return image;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6687 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6688
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6689 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6690 * Obtains an icon from data
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6691 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6692 * filename: Name of the file, omit extention to have
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6693 * DW pick the appropriate file extension.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6694 * (ICO on OS/2 or Windows, XPM on Unix)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6695 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6696 HICN API dw_icon_load_from_data(const char *data, int len)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6697 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6698 NSData *thisdata = [NSData dataWithBytes:data length:len];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6699 UIImage *image = [[UIImage alloc] initWithData:thisdata];
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
6700 _dw_icon_resize(image);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6701 return image;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6702 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6703
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6704 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6705 * Frees a loaded resource in OS/2 and Windows.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6706 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6707 * handle: Handle to icon returned by dw_icon_load().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6708 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6709 void API dw_icon_free(HICN handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6710 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6711 UIImage *image = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6712 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6713 [image release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6714 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6715 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6716
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6717 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6718 * Create a new MDI Frame to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6719 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6720 * id: An ID to be used with dw_window_from_id or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6721 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6722 HWND API dw_mdi_new(unsigned long cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6723 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6724 /* There isn't anything like quite like MDI on MacOS...
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6725 * However we will make floating windows that hide
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6726 * when the application is deactivated to simulate
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6727 * similar behavior.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6728 */
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
6729 DWMDI *mdi = [[[DWMDI alloc] init] retain];
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
6730 [mdi setTag:cid];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6731 return mdi;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6732 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6733
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6734 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6735 * Creates a splitbar window (widget) with given parameters.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6736 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6737 * type: Value can be DW_VERT or DW_HORZ.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6738 * topleft: Handle to the window to be top or left.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6739 * bottomright: Handle to the window to be bottom or right.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6740 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6741 * A handle to a splitbar window or NULL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6742 */
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6743 DW_FUNCTION_DEFINITION(dw_splitbar_new, HWND, DW_UNUSED(int type), HWND topleft, HWND bottomright, unsigned long cid)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6744 DW_FUNCTION_ADD_PARAM4(type, topleft, bottomright, cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6745 DW_FUNCTION_RETURN(dw_splitbar_new, HWND)
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6746 DW_FUNCTION_RESTORE_PARAM4(DW_UNUSED(type), int, topleft, HWND, bottomright, HWND, cid, unsigned long)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6747 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6748 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6749 id tmpbox = dw_box_new(DW_VERT, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6750 DWSplitBar *split = [[DWSplitBar alloc] init];
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
6751 UIViewController *vc = [[[UIViewController alloc] init] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6752 [split setDelegate:split];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6753 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0);
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6754 [vc setView:tmpbox];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6755 if (@available(iOS 14.0, *)) {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6756 [split setViewController:vc forColumn:UISplitViewControllerColumnPrimary];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6757 } else {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6758 [split addChildViewController:vc];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6759 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6760 [tmpbox autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6761 tmpbox = dw_box_new(DW_VERT, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6762 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0);
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6763 vc = [[UIViewController alloc] init];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6764 [vc setView:tmpbox];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6765 if (@available(iOS 14.0, *)) {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6766 [split setViewController:vc forColumn:UISplitViewControllerColumnSecondary];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6767 } else {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6768 [split addChildViewController:vc];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6769 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6770 [tmpbox autorelease];
2395
2618277de356 iOS: Code error cleanup reported by LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2393
diff changeset
6771 [vc autorelease];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6772 #if 0 /* TODO: All iOS splitbars are vertical */
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6773 [split setVertical:(type == DW_VERT ? YES : NO)];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6774 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6775 /* Set the default percent to 50% split */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6776 [split setPercent:50.0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6777 [split setTag:cid];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6778 DW_FUNCTION_RETURN_THIS(split);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6779 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6780
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6781 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6782 * Sets the position of a splitbar (pecentage).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6783 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6784 * handle: The handle to the splitbar returned by dw_splitbar_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6785 * percent: The position of the splitbar.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6786 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6787 DW_FUNCTION_DEFINITION(dw_splitbar_set, void, HWND handle, float percent)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6788 DW_FUNCTION_ADD_PARAM2(handle, percent)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6789 DW_FUNCTION_NO_RETURN(dw_splitbar_set)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6790 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, percent, float)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6791 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6792 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6793 DWSplitBar *split = handle;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6794 CGSize size = [split preferredContentSize];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6795 float pos;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6796 /* Calculate the position based on the size */
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6797 #if 0 /* TODO: iOS split views are always vertical */
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6798 if(![split isVertical])
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6799 pos = size.height * (percent / 100.0);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6800 else
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6801 #endif
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6802 pos = size.width * (percent / 100.0);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6803 if(pos > 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6804 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6805 if (@available(iOS 14.0, *)) {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6806 [split setPreferredPrimaryColumnWidth:pos];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6807 } else {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6808 /* TODO: Is this possible on earlier versions? */
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6809 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6810 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6811 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6812 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6813 /* If we have no size.. wait until the resize
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6814 * event when we get an actual size to try
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6815 * to set the splitbar again.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6816 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6817 [split setPercent:percent];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6818 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6819 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6820 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6821
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6822 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6823 * Gets the position of a splitbar (pecentage).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6824 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6825 * handle: The handle to the splitbar returned by dw_splitbar_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6826 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6827 float API dw_splitbar_get(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6828 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6829 DWSplitBar *split = handle;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6830 float retval = 50.0;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6831
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6832 if (@available(iOS 14.0, *)) {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6833 float primary = [split primaryColumnWidth];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6834 float supplementary = [split supplementaryColumnWidth];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6835 retval = (primary / (primary + supplementary)) * 100.0;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6836 } else {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
6837 /* TODO: If possible*/
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6838 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6839 return retval;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6840 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6841
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6842 /* Internal function to convert fontname to UIFont */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6843 UIFont *_dw_font_by_name(const char *fontname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6844 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6845 UIFont *font = DWDefaultFont;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6846
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6847 if(fontname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6848 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6849 char *name = strchr(fontname, '.');
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6850
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6851 if(name && (name++))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6852 {
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6853 UIFontDescriptorSymbolicTraits traits = 0;
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6854 UIFontDescriptor* fd;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6855 int size = atoi(fontname);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6856 char *Italic = strstr(name, " Italic");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6857 char *Bold = strstr(name, " Bold");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6858 size_t len = (Italic ? (Bold ? (Italic > Bold ? (Bold - name) : (Italic - name)) : (Italic - name)) : (Bold ? (Bold - name) : strlen(name)));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6859 char *newname = alloca(len+1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6860
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6861 memset(newname, 0, len+1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6862 strncpy(newname, name, len);
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6863
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6864 if(Bold)
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6865 traits |= UIFontDescriptorTraitBold;
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6866 if(Italic)
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6867 traits |= UIFontDescriptorTraitItalic;
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6868
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6869 fd = [UIFontDescriptor
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6870 fontDescriptorWithFontAttributes:@{UIFontDescriptorFamilyAttribute:[NSString stringWithUTF8String:newname],
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6871 UIFontDescriptorTraitsAttribute: @{UIFontSymbolicTrait:[NSNumber numberWithInteger:traits]}}];
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6872 NSArray* matches = [fd matchingFontDescriptorsWithMandatoryKeys:
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6873 [NSSet setWithObjects:UIFontDescriptorFamilyAttribute, UIFontDescriptorTraitsAttribute, nil]];
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6874 if(matches.count != 0)
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6875 font = [UIFont fontWithDescriptor:matches[0] size:size];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6876 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6878 return font;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6879 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6880
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6881 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6882 * Create a bitmap object to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6883 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6884 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6885 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6886 DW_FUNCTION_DEFINITION(dw_bitmap_new, HWND, ULONG cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6887 DW_FUNCTION_ADD_PARAM1(cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6888 DW_FUNCTION_RETURN(dw_bitmap_new, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6889 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6890 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6891 DW_FUNCTION_INIT;
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
6892 UIImageView *bitmap = [[[UIImageView alloc] init] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6893 [bitmap setTag:cid];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6894 DW_FUNCTION_RETURN_THIS(bitmap);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6895 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6896
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6897 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6898 * Creates a pixmap with given parameters.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6899 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6900 * handle: Window handle the pixmap is associated with.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6901 * width: Width of the pixmap in pixels.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6902 * height: Height of the pixmap in pixels.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6903 * depth: Color depth of the pixmap.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6904 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6905 * A handle to a pixmap or NULL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6906 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6907 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6908 {
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6909 HPIXMAP pixmap = NULL;
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6910
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6911 if((pixmap = calloc(1,sizeof(struct _hpixmap))))
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6912 {
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6913 pixmap->width = width;
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6914 pixmap->height = height;
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6915 pixmap->handle = handle;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
6916 pixmap->image = [[[DWImage alloc] initWithSize:CGSizeMake(width,height)] retain];
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6917 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6918 return pixmap;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6919 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6920
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6921 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6922 * Creates a pixmap from a file.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6923 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6924 * handle: Window handle the pixmap is associated with.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6925 * filename: Name of the file, omit extention to have
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6926 * DW pick the appropriate file extension.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6927 * (BMP on OS/2 or Windows, XPM on Unix)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6928 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6929 * A handle to a pixmap or NULL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6930 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931 HPIXMAP API dw_pixmap_new_from_file(HWND handle, const char *filename)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933 HPIXMAP pixmap;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 char *ext = _dw_get_image_extension( filename );
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6938 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6939 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6940 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6941 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6942 NSString *nstr = [ NSString stringWithUTF8String:filename ];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6943 UIImage *tmpimage = [[[UIImage alloc] initWithContentsOfFile:nstr] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6944 if(!tmpimage && ext)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6945 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6946 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6947 tmpimage = [[[UIImage alloc] initWithContentsOfFile:nstr] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6948 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6949 if(!tmpimage)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6950 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6951 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6952 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6953 }
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
6954 pixmap->width = [tmpimage size].width;
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
6955 pixmap->height = [tmpimage size].height;
2447
8723c01fb87e iOS: Fix bug in dw_pixmap_new_from_file(). Resources go into the app
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2445
diff changeset
6956 pixmap->image = [[DWImage alloc] initWithUIImage:tmpimage];
8723c01fb87e iOS: Fix bug in dw_pixmap_new_from_file(). Resources go into the app
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2445
diff changeset
6957 pixmap->handle = handle;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6958 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6959 return pixmap;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6960 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6961
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6962 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6963 * Creates a pixmap from memory.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6964 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6965 * handle: Window handle the pixmap is associated with.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6966 * data: Source of the image data
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6967 * (BMP on OS/2 or Windows, XPM on Unix)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6968 * le: length of data
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6969 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6970 * A handle to a pixmap or NULL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6971 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6972 HPIXMAP API dw_pixmap_new_from_data(HWND handle, const char *data, int len)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6973 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6974 HPIXMAP pixmap;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6975 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6976
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6977 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6978 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6979 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6980 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6981 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6982 NSData *thisdata = [NSData dataWithBytes:data length:len];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6983 UIImage *tmpimage = [[[UIImage alloc] initWithData:thisdata] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6984 if(!tmpimage)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6985 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6986 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6987 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6988 }
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
6989 pixmap->width = [tmpimage size].width;
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
6990 pixmap->height = [tmpimage size].height;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
6991 pixmap->image = [[DWImage alloc] initWithUIImage:tmpimage];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6992 pixmap->handle = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6993 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6994 return pixmap;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6995 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6996
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6997 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6998 * Sets the transparent color for a pixmap
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6999 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7000 * pixmap: Handle to a pixmap returned by
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7001 * dw_pixmap_new..
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7002 * color: transparent color
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7003 * Note: This does nothing on Mac as transparency
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7004 * is handled automatically
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7005 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7006 void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color )
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7007 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7008 /* Don't do anything */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7009 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7010
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7011 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7012 * Creates a pixmap from internal resource graphic specified by id.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7013 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7014 * handle: Window handle the pixmap is associated with.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7015 * id: Resource ID associated with requested pixmap.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7016 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7017 * A handle to a pixmap or NULL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7018 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7019 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7020 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7021 HPIXMAP pixmap;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7022 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7023
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7024 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7025 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7026 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7027 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7028 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7029
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7030 NSBundle *bundle = [NSBundle mainBundle];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7031 NSString *respath = [bundle resourcePath];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7032 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid];
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
7033 UIImage *tmpimage = [[UIImage alloc] initWithContentsOfFile:filepath];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7034
2382
41a04e6b3e8e iOS: More conversion... mostly drawing related changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2381
diff changeset
7035 if(tmpimage)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7036 {
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
7037 pixmap->width = [tmpimage size].width;
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
7038 pixmap->height = [tmpimage size].height;
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
7039 pixmap->image = [[DWImage alloc] initWithUIImage:tmpimage];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7040 pixmap->handle = handle;
2412
3b59cbd26fab iOS/Mac: Fix a minor memory leak in dw_pixmap_grab().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2411
diff changeset
7041 DW_LOCAL_POOL_OUT;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7042 return pixmap;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7043 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7044 free(pixmap);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7045 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7046 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7047 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7048
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7049 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7050 * Sets the font used by a specified pixmap.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7051 * Normally the pixmap font is obtained from the associated window handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7052 * However this can be used to override that, or for pixmaps with no window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7053 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7054 * pixmap: Handle to a pixmap returned by dw_pixmap_new() or
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7055 * passed to the application via a callback.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7056 * fontname: Name and size of the font in the form "size.fontname"
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7057 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7058 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7059 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7060 int API dw_pixmap_set_font(HPIXMAP pixmap, const char *fontname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7061 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7062 if(pixmap)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7063 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7064 UIFont *font = _dw_font_by_name(fontname);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7065
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7066 if(font)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7067 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7068 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7069 UIFont *oldfont = pixmap->font;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7070 [font retain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7071 pixmap->font = font;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7072 if(oldfont)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7073 [oldfont release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7074 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7075 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7076 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7077 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7078 return DW_ERROR_GENERAL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7079 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7080
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7081 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7082 * Destroys an allocated pixmap.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7083 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7084 * pixmap: Handle to a pixmap returned by
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7085 * dw_pixmap_new..
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7086 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7087 void API dw_pixmap_destroy(HPIXMAP pixmap)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7088 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7089 if(pixmap)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7090 {
2434
404d9e9f1f08 iOS: Second attempt at a DWImage class that will actually work....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2433
diff changeset
7091 DWImage *image = (DWImage *)pixmap->image;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7092 UIFont *font = pixmap->font;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7093 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7094 [image release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7095 [font release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7096 free(pixmap);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7097 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7098 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7099 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7100
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7101 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7102 * Copies from one item to another.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7103 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7104 * dest: Destination window handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7105 * destp: Destination pixmap. (choose only one).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7106 * xdest: X coordinate of destination.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7107 * ydest: Y coordinate of destination.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7108 * width: Width of area to copy.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7109 * height: Height of area to copy.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7110 * src: Source window handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7111 * srcp: Source pixmap. (choose only one).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7112 * xsrc: X coordinate of source.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7113 * ysrc: Y coordinate of source.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7114 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7115 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7116 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7117 dw_pixmap_stretch_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, -1, -1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7118 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7119
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7120 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7121 * Copies from one surface to another allowing for stretching.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7122 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7123 * dest: Destination window handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7124 * destp: Destination pixmap. (choose only one).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7125 * xdest: X coordinate of destination.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7126 * ydest: Y coordinate of destination.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7127 * width: Width of the target area.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7128 * height: Height of the target area.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7129 * src: Source window handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7130 * srcp: Source pixmap. (choose only one).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7131 * xsrc: X coordinate of source.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7132 * ysrc: Y coordinate of source.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7133 * srcwidth: Width of area to copy.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7134 * srcheight: Height of area to copy.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7135 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7136 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7137 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7138 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7139 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7140 DWBitBlt *bltinfo;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7141 NSValue* bi;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7142 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7143
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7144 /* Sanity checks */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7145 if((!dest && !destp) || (!src && !srcp) ||
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7146 ((srcwidth == -1 || srcheight == -1) && srcwidth != srcheight))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7147 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7148 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7149 return DW_ERROR_GENERAL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7150 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7151
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7152 bltinfo = calloc(1, sizeof(DWBitBlt));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7153 bi = [NSValue valueWithPointer:bltinfo];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7154
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7155 /* Fill in the information */
2436
ab36fbb50fe5 iOS: Fixes to get cachedImage functionality working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2435
diff changeset
7156 bltinfo->dest = _dw_dest_image(destp, dest);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7157 bltinfo->src = src;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7158 bltinfo->xdest = xdest;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7159 bltinfo->ydest = ydest;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7160 bltinfo->width = width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7161 bltinfo->height = height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7162 bltinfo->xsrc = xsrc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7163 bltinfo->ysrc = ysrc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7164 bltinfo->srcwidth = srcwidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7165 bltinfo->srcheight = srcheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7166
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7167 if(srcp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7168 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7169 id object = bltinfo->src = (id)srcp->image;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7170 [object retain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7171 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7172 [DWObj safeCall:@selector(doBitBlt:) withObject:bi];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7173 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7174 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7175 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7176
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7177 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7178 * Create a new static text window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7179 * Not available under OS/2, eCS
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7180 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7181 * text: The text to be display by the static text widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7182 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7183 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7184 DW_FUNCTION_DEFINITION(dw_calendar_new, HWND, ULONG cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7185 DW_FUNCTION_ADD_PARAM1(cid)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7186 DW_FUNCTION_RETURN(dw_calendar_new, HWND)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7187 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7188 {
2419
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
7189 DWCalendar *calendar = nil;
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
7190 #if 0 /* TODO: Figure out why this hangs the UI */
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
7191 DWCalendar *calendar = [[[DWCalendar alloc] init] retain];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7192 [calendar setDatePickerMode:UIDatePickerModeDate];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7193 [calendar setTag:cid];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7194 [calendar setDate:[NSDate date]];
2419
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
7195 #endif
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7196 DW_FUNCTION_RETURN_THIS(calendar);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7197 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7198
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7199 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7200 * Sets the current date of a calendar.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7201 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7202 * handle: The handle to the calendar returned by dw_calendar_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7203 * year...
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7204 */
2400
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7205 DW_FUNCTION_DEFINITION(dw_calendar_set_date, void, HWND handle, unsigned int year, unsigned int month, unsigned int day)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7206 DW_FUNCTION_ADD_PARAM4(handle, year, month, day)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7207 DW_FUNCTION_NO_RETURN(dw_calendar_set_date)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7208 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, year, unsigned int, month, unsigned int, day, unsigned int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7209 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7210 DWCalendar *calendar = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7211 NSDate *date;
2419
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
7212 char buffer[101] = {0};
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7213
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7214 snprintf(buffer, 100, "%04d-%02d-%02d", year, month, day);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7215
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7216 NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7217 dateFormatter.dateFormat = @"yyyy-MM-dd";
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7218
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7219 date = [dateFormatter dateFromString:[NSString stringWithUTF8String:buffer]];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7220 [calendar setDate:date];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7221 [date release];
2400
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7222 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7223 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7224
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7225 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7226 * Gets the current date of a calendar.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7227 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7228 * handle: The handle to the calendar returned by dw_calendar_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7229 */
2400
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7230 DW_FUNCTION_DEFINITION(dw_calendar_get_date, void, HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7231 DW_FUNCTION_ADD_PARAM4(handle, year, month, day)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7232 DW_FUNCTION_NO_RETURN(dw_calendar_get_date)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7233 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, year, unsigned int *, month, unsigned int *, day, unsigned int *)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7234 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7235 DWCalendar *calendar = handle;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7236 NSCalendar *mycalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7237 NSDate *date = [calendar date];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7238 NSDateComponents* components = [mycalendar components:NSCalendarUnitDay|NSCalendarUnitMonth|NSCalendarUnitYear fromDate:date];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7239 *day = (unsigned int)[components day];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7240 *month = (unsigned int)[components month];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7241 *year = (unsigned int)[components year];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7242 [mycalendar release];
2400
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
7243 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7244 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7245
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7246 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7247 * Causes the embedded HTML widget to take action.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7248 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7249 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7250 * action: One of the DW_HTML_* constants.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 */
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7252 DW_FUNCTION_DEFINITION(dw_html_action, void, HWND handle, int action)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7253 DW_FUNCTION_ADD_PARAM2(handle, action)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7254 DW_FUNCTION_NO_RETURN(dw_html_action)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7255 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, action, int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7256 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7257 DWWebView *html = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7258 switch(action)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7259 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7260 case DW_HTML_GOBACK:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7261 [html goBack];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7262 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7263 case DW_HTML_GOFORWARD:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7264 [html goForward];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7265 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7266 case DW_HTML_GOHOME:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7267 dw_html_url(handle, DW_HOME_URL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7268 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7269 case DW_HTML_SEARCH:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7270 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7271 case DW_HTML_RELOAD:
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7272 [html reload];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7273 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7274 case DW_HTML_STOP:
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7275 [html stopLoading];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7276 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7277 case DW_HTML_PRINT:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7278 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7279 }
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7280 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7281 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7282
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7283 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7284 * Render raw HTML code in the embedded HTML widget..
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7285 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7286 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7287 * string: String buffer containt HTML code to
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7288 * be rendered.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7289 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7290 * 0 on success.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7291 */
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7292 DW_FUNCTION_DEFINITION(dw_html_raw, int, HWND handle, const char *string)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7293 DW_FUNCTION_ADD_PARAM2(handle, string)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7294 DW_FUNCTION_RETURN(dw_html_raw, int)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7295 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, string, const char *)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7296 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7297 DWWebView *html = handle;
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7298 int retval = DW_ERROR_NONE;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7299 [html loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil];
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7300 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7301 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7302
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7303 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7304 * Render file or web page in the embedded HTML widget..
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7305 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7306 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7307 * url: Universal Resource Locator of the web or
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7308 * file object to be rendered.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7309 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7310 * 0 on success.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7311 */
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7312 DW_FUNCTION_DEFINITION(dw_html_url, int, HWND handle, const char *url)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7313 DW_FUNCTION_ADD_PARAM2(handle, url)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7314 DW_FUNCTION_RETURN(dw_html_url, int)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7315 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, url, const char *)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7316 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7317 DWWebView *html = handle;
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7318 int retval = DW_ERROR_NONE;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7319 [html loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[ NSString stringWithUTF8String:url ]]]];
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7320 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7321 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7322
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7323 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7324 * Executes the javascript contained in "script" in the HTML window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7325 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7326 * handle: Handle to the HTML window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7327 * script: Javascript code to execute.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7328 * scriptdata: Data passed to the signal handler.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7329 * Notes: A DW_SIGNAL_HTML_RESULT event will be raised with scriptdata.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7330 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7331 * DW_ERROR_NONE (0) on success.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7332 */
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7333 DW_FUNCTION_DEFINITION(dw_html_javascript_run, int, HWND handle, const char *script, void *scriptdata)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7334 DW_FUNCTION_ADD_PARAM3(handle, script, scriptdata)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7335 DW_FUNCTION_RETURN(dw_html_javascript_run, int)
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7336 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, script, const char *, scriptdata, void *)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7337 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7338 DWWebView *html = handle;
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7339 int retval = DW_ERROR_NONE;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7340 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7341
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7342 [html evaluateJavaScript:[NSString stringWithUTF8String:script] completionHandler:^(NSString *result, NSError *error)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7343 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7344 void *params[2] = { result, scriptdata };
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
7345 _dw_event_handler(html, (UIEvent *)params, 18);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7346 }];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7347 DW_LOCAL_POOL_OUT;
2404
d4a044d24529 iOS: Fix crashes with full dwtest run. More thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2402
diff changeset
7348 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7349 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7350
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7351 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7352 * Create a new HTML window (widget) to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7353 * Not available under OS/2, eCS
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7354 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7355 * text: The default text to be in the entryfield widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7356 * id: An ID to be used with dw_window_from_id() or 0L.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7357 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7358 DW_FUNCTION_DEFINITION(dw_html_new, HWND, ULONG cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7359 DW_FUNCTION_ADD_PARAM1(cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7360 DW_FUNCTION_RETURN(dw_html_new, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7361 DW_FUNCTION_RESTORE_PARAM1(DW_UNUSED(cid), ULONG)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7362 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7363 DW_FUNCTION_INIT;
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
7364 DWWebView *web = [[[DWWebView alloc] init] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7365 web.navigationDelegate = web;
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
7366 [web setTag:cid];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7367 DW_FUNCTION_RETURN_THIS(web);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7368 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7369
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7370 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7371 * Returns the current X and Y coordinates of the mouse pointer.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7372 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7373 * x: Pointer to variable to store X coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7374 * y: Pointer to variable to store Y coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7375 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7376 void API dw_pointer_query_pos(long *x, long *y)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7377 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7378 if(x)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7379 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7380 *x = 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7381 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7382 if(y)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7383 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7384 *y = 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7385 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7386 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7387
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7388 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7389 * Sets the X and Y coordinates of the mouse pointer.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7390 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7391 * x: X coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7392 * y: Y coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7393 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7394 void API dw_pointer_set_pos(long x, long y)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7395 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7396 /* From what I have read this isn't possible, agaist human interface rules */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7397 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7398
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7399 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7400 * Create a menu object to be popped up.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7401 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7402 * id: An ID to be used for getting the resource from the
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7403 * resource file.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7404 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7405 HMENUI API dw_menu_new(ULONG cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7406 {
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
7407 DWMenu *menu = [[[DWMenu alloc] init] retain];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7408 /* [menu setTag:cid]; Why doesn't this work? */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7409 return menu;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7410 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7411
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7412 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7413 * Create a menubar on a window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7414 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7415 * location: Handle of a window frame to be attached to.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7416 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7417 HMENUI API dw_menubar_new(HWND location)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7418 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7419 /* TODO: Implement this with UIMenuSystem */
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7420 return NULL;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7421 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7422
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7423 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7424 * Destroys a menu created with dw_menubar_new or dw_menu_new.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7425 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7426 * menu: Handle of a menu.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7427 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7428 void API dw_menu_destroy(HMENUI *menu)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7429 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7430 DWMenu *thismenu = *menu;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7431 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7432 [thismenu release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7433 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7434 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7435
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7436 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7437 * Pops up a context menu at given x and y coordinates.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7438 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7439 * menu: The handle the the existing menu.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7440 * parent: Handle to the window initiating the popup.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7441 * x: X coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7442 * y: Y coordinate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7443 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7444 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7445 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7446 #if 0 /* TODO: Figure out how to do this */
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7447 DWMenu *thismenu = (DWMenu *)*menu;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7448 id object = parent;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7449 UIView *view = [object isKindOfClass:[UIWindow class]] ? [object contentView] : parent;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7450 UIWindow *window = [view window];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7451 [thismenu autorelease];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7452 CGPoint p = CGPointMake(x, y);
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7453 [UIContextMenuInteraction a
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7454 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7455 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7456
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
7457 char _dw_removetilde(char *dest, const char *src)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7458 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7459 int z, cur=0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7460 char accel = '\0';
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7461
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7462 for(z=0;z<strlen(src);z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7463 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7464 if(src[z] != '~')
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7465 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7466 dest[cur] = src[z];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7467 cur++;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7468 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7469 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7470 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7471 accel = src[z+1];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7473 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7474 dest[cur] = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 return accel;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7478 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7479 * Adds a menuitem or submenu to an existing menu.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7480 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7481 * menu: The handle the the existing menu.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7482 * title: The title text on the menu item to be added.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7483 * id: An ID to be used for message passing.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7484 * flags: Extended attributes to set on the menu.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7485 * end: If TRUE memu is positioned at the end of the menu.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7486 * check: If TRUE menu is "check"able.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7487 * flags: Extended attributes to set on the menu.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7488 * submenu: Handle to an existing menu to be a submenu or NULL.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7489 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7490 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7491 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7492 DWMenu *menu = menux;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7493 DWMenuItem *item = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7494 if(strlen(title) == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7495 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7496 #if 0 /* TODO: Not sure if separators exist in iOS */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7497 [menu addItem:[DWMenuItem separatorItem]];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7498 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7499 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7500 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7501 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7502 char accel[2];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7503 char *newtitle = malloc(strlen(title)+1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7504 NSString *nstr;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7505 UIMenu *newmenu, *oldmenu = [menu menu];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7506 NSArray *newchildren, *oldchildren = [oldmenu children];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7507
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
7508 accel[0] = _dw_removetilde(newtitle, title);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7509 accel[1] = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7510
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7511 nstr = [ NSString stringWithUTF8String:newtitle ];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7512 free(newtitle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7513
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7514 item = [[DWMenuItem commandWithTitle:nstr image:nil
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7515 action:@selector(menuHandler:)
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7516 propertyList:nil] autorelease];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7517 newchildren = [oldchildren arrayByAddingObjectsFromArray:@[item]];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7518 if(oldmenu)
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7519 {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7520 newmenu = [oldmenu menuByReplacingChildren:newchildren];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7521 [oldmenu release];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7522 }
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7523 else if(@available(iOS 14.0, *))
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7524 newmenu = [UIMenu menuWithChildren:newchildren];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7525 else
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7526 newmenu = [UIMenu menuWithTitle:@"" children:newchildren];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7527 [menu setMenu:newmenu];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7528
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7529 [item setTag:itemid];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7530 if(check)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7531 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7532 [item setCheck:YES];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7533 if(flags & DW_MIS_CHECKED)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7534 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7535 [item setState:UIMenuElementStateOn];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7536 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7537 }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7538 #if 0 /* TODO: Disabled items not supported on iOS */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7539 if(flags & DW_MIS_DISABLED)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7540 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7541 [item setEnabled:NO];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7542 }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7543 #endif
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7544
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7545 #if 0 /* TODO: iOS may not support submenus... but may be able to cascade... with defered menus */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7546 if(submenux)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7547 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7548 DWMenu *submenu = submenux;
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7549
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7550 [submenu setTitle:nstr];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7551 [menu setSubmenu:submenu forItem:item];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7552 }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7553 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7554 return item;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7555 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7556 return item;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7559 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560 * Sets the state of a menu item check.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7561 * Deprecated; use dw_menu_item_set_state()
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7562 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7563 * menu: The handle the the existing menu.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7564 * id: Menuitem id.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7565 * check: TRUE for checked FALSE for not checked.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7566 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7567 void API dw_menu_item_set_check(HMENUI menux, unsigned long itemid, int check)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7568 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7569 id menu = menux;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7570 DWMenuItem *menuitem = [menu itemWithTag:itemid];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7571
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7572 if(menuitem != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7573 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7574 if(check)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7575 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7576 [menuitem setState:UIMenuElementStateOn];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7577 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7578 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7579 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7580 [menuitem setState:UIMenuElementStateOff];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7581 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7582 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7583 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7584
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7585 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7586 * Deletes the menu item specified.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7587 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7588 * menu: The handle to the menu in which the item was appended.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7589 * id: Menuitem id.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7590 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7591 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7592 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7593 int API dw_menu_delete_item(HMENUI menux, unsigned long itemid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7594 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7595 #if 0 /* TODO: Remove item from the children array */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7596 id menu = menux;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7597 DWMenuItem *menuitem = [menu itemWithTag:itemid];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7598
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7599 if(menuitem != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7600 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7601 [menu removeItem:menuitem];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7602 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7603 }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7604 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7605 return DW_ERROR_UNKNOWN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7606 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7607
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7608 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7609 * Sets the state of a menu item.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7610 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7611 * menu: The handle to the existing menu.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7612 * id: Menuitem id.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7613 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7614 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7615 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7616 void API dw_menu_item_set_state(HMENUI menux, unsigned long itemid, unsigned long state)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7617 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7618 id menu = menux;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7619 DWMenuItem *menuitem = [menu itemWithTag:itemid];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7620
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7621 if(menuitem != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7622 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7623 if(state & DW_MIS_CHECKED)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7624 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7625 [menuitem setState:UIMenuElementStateOn];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7626 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7627 else if(state & DW_MIS_UNCHECKED)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7628 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7629 [menuitem setState:UIMenuElementStateOff];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7630 }
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7631 #if 0 /* TODO: Disabled items not supported on iOS */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7632 if(state & DW_MIS_ENABLED)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7633 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7634 [menuitem setEnabled:YES];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7635 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7636 else if(state & DW_MIS_DISABLED)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7637 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7638 [menuitem setEnabled:NO];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7639 }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7640 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7641 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7642 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7643
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7644 /* Gets the notebook page from associated ID */
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
7645 DWNotebookPage *_dw_notepage_from_id(DWNotebook *notebook, unsigned long pageid)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7646 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7647 NSArray *pages = [notebook views];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7648 for(DWNotebookPage *notepage in pages)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7649 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7650 if([notepage pageid] == pageid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7651 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7652 return notepage;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7653 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7654 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7655 return nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7656 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7657
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7658 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7659 * Create a notebook object to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7660 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7661 * id: An ID to be used for getting the resource from the
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7662 * resource file.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7663 */
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
7664 DW_FUNCTION_DEFINITION(dw_notebook_new, HWND, ULONG cid, DW_UNUSED(int top))
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7665 DW_FUNCTION_ADD_PARAM2(cid, top)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7666 DW_FUNCTION_RETURN(dw_notebook_new, HWND)
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
7667 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, DW_UNUSED(top), int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7668 {
2405
38c17a19e00d iOS: Add adjustment for the statusbar so it isn't covered up by our windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2404
diff changeset
7669 DWNotebook *notebook = [[[DWNotebook alloc] init] retain];
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7670 [[notebook tabs] addTarget:notebook
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7671 action:@selector(pageChanged:)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7672 forControlEvents:UIControlEventValueChanged];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7673 [notebook setTag:cid];
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7674 DW_FUNCTION_RETURN_THIS(notebook);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7675 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7676
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7677 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7678 * Adds a new page to specified notebook.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7679 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7680 * handle: Window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7681 * flags: Any additional page creation flags.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7682 * front: If TRUE page is added at the beginning.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7683 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7684 DW_FUNCTION_DEFINITION(dw_notebook_page_new, ULONG, HWND handle, DW_UNUSED(ULONG flags), int front)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7685 DW_FUNCTION_ADD_PARAM3(handle, flags, front)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7686 DW_FUNCTION_RETURN(dw_notebook_page_new, ULONG)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7687 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, DW_UNUSED(flags), ULONG, front, int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7688 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7689 DWNotebook *notebook = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7690 NSInteger page = [notebook pageid];
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7691 DWNotebookPage *notepage = [[[DWNotebookPage alloc] init] retain];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7692 NSMutableArray<DWNotebookPage *> *views = [notebook views];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7693 unsigned long retval;
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7694
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7695 [notepage setPageid:(int)page];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7696 if(front)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7697 {
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7698 [[notebook tabs] insertSegmentWithTitle:@"" atIndex:(NSInteger)0 animated:NO];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7699 [views addObject:notepage];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7700 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7701 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7702 {
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7703 [[notebook tabs] insertSegmentWithTitle:@"" atIndex:[[notebook tabs] numberOfSegments] animated:NO];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7704 [views addObject:notepage];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7705 }
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7706 [notebook addSubview:notepage];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7707 [notepage autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7708 [notebook setPageid:(int)(page+1)];
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7709
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7710 if([views count] != 1)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7711 {
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7712 /* Otherwise hide the page */
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7713 [notepage setHidden:YES];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7714 }
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7715
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7716 retval = (unsigned long)page;
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7717 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7718 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7719
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7720 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7721 * Remove a page from a notebook.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7722 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7723 * handle: Handle to the notebook widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7724 * pageid: ID of the page to be destroyed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7725 */
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7726 DW_FUNCTION_DEFINITION(dw_notebook_page_destroy, void, HWND handle, unsigned int pageid)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7727 DW_FUNCTION_ADD_PARAM2(handle, pageid)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7728 DW_FUNCTION_NO_RETURN(dw_notebook_page_destroy)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7729 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, pageid, unsigned int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7730 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7731 DWNotebook *notebook = handle;
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
7732 DWNotebookPage *notepage = _dw_notepage_from_id(notebook, pageid);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7733 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7734
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7735 if(notepage != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7736 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7737 NSMutableArray<DWNotebookPage *> *views = [notebook views];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7738 NSUInteger index = [views indexOfObject:notepage];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7739
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7740 if(index != NSNotFound)
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7741 {
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7742 [[notebook tabs] removeSegmentAtIndex:index animated:NO];
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7743 [notepage removeFromSuperview];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7744 [views removeObject:notepage];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7745 [notepage release];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7746 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7747 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7748 DW_LOCAL_POOL_OUT;
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7749 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7750 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7751
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7752 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7753 * Queries the currently visible page ID.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7754 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7755 * handle: Handle to the notebook widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7756 */
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7757 DW_FUNCTION_DEFINITION(dw_notebook_page_get, unsigned long, HWND handle)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7758 DW_FUNCTION_ADD_PARAM1(handle)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7759 DW_FUNCTION_RETURN(dw_notebook_page_get, unsigned long)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7760 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7761 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7762 DWNotebook *notebook = handle;
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7763 NSInteger index = [[notebook tabs] selectedSegmentIndex];
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
7764 unsigned long retval = 0;
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
7765
2419
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
7766 if(index != -1)
2413
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
7767 {
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
7768 NSMutableArray<DWNotebookPage *> *views = [notebook views];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
7769 DWNotebookPage *notepage = [views objectAtIndex:index];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
7770
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
7771 retval = [notepage pageid];
8727ad1a19c3 iOS: Fix notebook relayout on rotation. Also fix autosizing of controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2412
diff changeset
7772 }
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7773 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7774 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7775
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7776 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7777 * Sets the currently visibale page ID.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7778 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7779 * handle: Handle to the notebook widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7780 * pageid: ID of the page to be made visible.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7781 */
2409
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
7782 DW_FUNCTION_DEFINITION(dw_notebook_page_set, void, HWND handle, unsigned int pageid)
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
7783 DW_FUNCTION_ADD_PARAM2(handle, pageid)
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
7784 DW_FUNCTION_NO_RETURN(dw_notebook_page_set)
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
7785 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, pageid, unsigned int)
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
7786 {
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7787 DWNotebook *notebook = handle;
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
7788 DWNotebookPage *notepage = _dw_notepage_from_id(notebook, pageid);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7789
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7790 if(notepage != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7791 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7792 NSMutableArray<DWNotebookPage *> *views = [notebook views];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7793 NSUInteger index = [views indexOfObject:notepage];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7794
2419
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
7795 if(index != -1)
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
7796 {
65ff339e9cd2 iOS: A number of fixes, notebook layout select first page if none selected.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2417
diff changeset
7797 [[notebook tabs] setSelectedSegmentIndex:index];
2409
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
7798 }
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
7799 }
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
7800 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7801 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7802
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7803 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7804 * Sets the text on the specified notebook tab.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7805 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7806 * handle: Notebook handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7807 * pageid: Page ID of the tab to set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7808 * text: Pointer to the text to set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7809 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7810 DW_FUNCTION_DEFINITION(dw_notebook_page_set_text, void, HWND handle, ULONG pageid, const char *text)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7811 DW_FUNCTION_ADD_PARAM3(handle, pageid, text)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7812 DW_FUNCTION_NO_RETURN(dw_notebook_page_set_text)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7813 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, pageid, ULONG, text, const char *)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7814 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7815 DWNotebook *notebook = handle;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7816
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7817 [[notebook tabs] setTitle:[NSString stringWithUTF8String:text] forSegmentAtIndex:pageid];
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7818 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7819 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7820
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7821 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7822 * Sets the text on the specified notebook tab status area.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7823 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7824 * handle: Notebook handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7825 * pageid: Page ID of the tab to set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7826 * text: Pointer to the text to set.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7827 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7828 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, const char *text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7829 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7830 /* Note supported here... do nothing */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7831 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7832
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7833 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7834 * Packs the specified box into the notebook page.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7835 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7836 * handle: Handle to the notebook to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7837 * pageid: Page ID in the notebook which is being packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7838 * page: Box handle to be packed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7839 */
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7840 DW_FUNCTION_DEFINITION(dw_notebook_pack, void, HWND handle, ULONG pageid, HWND page)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7841 DW_FUNCTION_ADD_PARAM3(handle, pageid, page)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7842 DW_FUNCTION_NO_RETURN(dw_notebook_pack)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7843 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, pageid, ULONG, page, HWND)
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7844 {
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7845 DWNotebook *notebook = handle;
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
7846 DWNotebookPage *notepage = _dw_notepage_from_id(notebook, pageid);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7847
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7848 if(notepage != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7849 {
2408
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7850 dw_box_pack_start(notepage, page, 0, 0, TRUE, TRUE, 0);
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7851 }
795056df9efd iOS: Initial functional implmentation of the notebook/tabbed control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2407
diff changeset
7852 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7853 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7854
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7855 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7856 * Create a new Window Frame.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7857 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7858 * owner: The Owner's window handle or HWND_DESKTOP.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7859 * title: The Window title.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7860 * flStyle: Style flags, see the PM reference.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7861 */
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
7862 DW_FUNCTION_DEFINITION(dw_window_new, HWND, DW_UNUSED(HWND hwndOwner), const char *title, DW_UNUSED(ULONG flStyle))
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7863 DW_FUNCTION_ADD_PARAM3(hwndOwner, title, flStyle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7864 DW_FUNCTION_RETURN(dw_window_new, HWND)
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
7865 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(hwndOwner), HWND, title, char *, DW_UNUSED(flStyle), ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7866 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7867 DW_FUNCTION_INIT;
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
7868 DWWindow *window = [[DWWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
7869 DWView *view = [[DWView alloc] init];
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
7870 UIUserInterfaceStyle style = [[DWObj hiddenWindow] overrideUserInterfaceStyle];
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
7871
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
7872 [window setWindowLevel:UIWindowLevelNormal];
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
7873 [window setRootViewController:[[DWViewController alloc] init]];
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
7874 [window addSubview:view];
2409
2ab3e88e5d68 iOS: Implement dw_notebook_page_set(). Fix statusbar offset location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2408
diff changeset
7875 [window setBackgroundColor:[UIColor systemBackgroundColor]];
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7876
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
7877 /* TODO: Handle style flags... if we can? There is no visible frame */
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7878 if(@available(iOS 13.0, *)) {
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7879 [window setLargeContentTitle:[NSString stringWithUTF8String:title]];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7880 }
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
7881 /* Copy the overrideUserInterfaceStyle property from the hiddenWindow */
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
7882 if(style != UIUserInterfaceStyleUnspecified)
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
7883 [window setOverrideUserInterfaceStyle:style];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7884 DW_FUNCTION_RETURN_THIS(window);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7885 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7886
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7887 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7888 * Call a function from the window (widget)'s context.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7889 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7890 * handle: Window handle of the widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7891 * function: Function pointer to be called.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7892 * data: Pointer to the data to be passed to the function.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7893 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7894 void API dw_window_function(HWND handle, void *function, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7895 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7896 void **params = calloc(2, sizeof(void *));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7897 NSValue *v;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7898 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7899 v = [NSValue valueWithPointer:params];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7900 params[0] = function;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7901 params[1] = data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7902 [DWObj performSelectorOnMainThread:@selector(doWindowFunc:) withObject:v waitUntilDone:YES];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7903 free(params);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7904 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7905 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7906
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7907
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7908 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7909 * Changes the appearance of the mouse pointer.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7910 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7911 * handle: Handle to widget for which to change.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7912 * cursortype: ID of the pointer you want.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7913 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7914 void API dw_window_set_pointer(HWND handle, int pointertype)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7915 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7916 /* TODO: Only might be possible on Catalyst */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7917 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7918
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7919 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7920 * Makes the window visible.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7921 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7922 * handle: The window handle to make visible.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7923 */
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7924 DW_FUNCTION_DEFINITION(dw_window_show, int, HWND handle)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7925 DW_FUNCTION_ADD_PARAM1(handle)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7926 DW_FUNCTION_RETURN(dw_window_show, int)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7927 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7928 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7929 NSObject *object = handle;
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7930 int retval = DW_ERROR_NONE;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7931
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7932 if([ object isMemberOfClass:[ DWWindow class ] ])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7933 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7934 DWWindow *window = handle;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7935 CGRect rect = [window frame];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7936
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7937 /* If we haven't been sized by a call.. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7938 if(rect.size.width <= 1 || rect.size.height <= 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7939 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7940 /* Determine the contents size */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7941 dw_window_set_size(handle, 0, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7942 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7943 if(![window shown])
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
7944 {
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
7945 [window makeKeyAndVisible];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7946 [window setShown:YES];
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
7947 }
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
7948 else
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
7949 [window setHidden:NO];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7950 }
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7951 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7952 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7953
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7954 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7955 * Makes the window invisible.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7956 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7957 * handle: The window handle to make visible.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7958 */
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7959 DW_FUNCTION_DEFINITION(dw_window_hide, int, HWND handle)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7960 DW_FUNCTION_ADD_PARAM1(handle)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7961 DW_FUNCTION_RETURN(dw_window_hide, int)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7962 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7963 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7964 NSObject *object = handle;
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7965 int retval = DW_ERROR_NONE;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7966
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7967 if([ object isKindOfClass:[ UIWindow class ] ])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7968 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7969 UIWindow *window = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7970
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7971 [window setHidden:YES];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7972 }
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
7973 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7974 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7975
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7976 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7977 * Sets the colors used by a specified window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7978 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7979 * handle: The window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7980 * fore: Foreground color in DW_RGB format or a default color index.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7981 * back: Background color in DW_RGB format or a default color index.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7982 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7983 DW_FUNCTION_DEFINITION(dw_window_set_color, int, HWND handle, unsigned long fore, unsigned long back)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7984 DW_FUNCTION_ADD_PARAM3(handle, fore, back)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7985 DW_FUNCTION_RETURN(dw_window_set_color, int)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7986 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, fore, unsigned long, back, unsigned long)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7987 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7988 id object = handle;
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
7989 unsigned long _fore = _dw_get_color(fore);
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
7990 unsigned long _back = _dw_get_color(back);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7991 UIColor *fg = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7992 UIColor *bg = NULL;
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
7993 int retval = DW_ERROR_NONE;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7994
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7995 /* Get the UIColor for non-default colors */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7996 if(fore != DW_CLR_DEFAULT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7997 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
7998 fg = [UIColor colorWithRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7999 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8000 if(back != DW_CLR_DEFAULT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8001 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8002 bg = [UIColor colorWithRed: DW_RED_VALUE(_back)/255.0 green: DW_GREEN_VALUE(_back)/255.0 blue: DW_BLUE_VALUE(_back)/255.0 alpha: 1];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8003 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8004
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8005 /* Get the textfield from the spinbutton */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8006 if([object isMemberOfClass:[DWSpinButton class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8007 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8008 object = [object textfield];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8009 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8010 /* Get the cell on classes using NSCell */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8011 if([object isKindOfClass:[UITextField class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8012 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8013 [object setTextColor:(fg ? fg : [UIColor labelColor])];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8014 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8015 if([object isMemberOfClass:[DWButton class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8016 {
2385
a126b04b9996 iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2384
diff changeset
8017 [[object titleLabel] setTextColor:(fg ? fg : [UIColor labelColor])];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8018 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8019 if([object isKindOfClass:[UITextField class]] || [object isKindOfClass:[UIButton class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8020 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8021 [object setBackgroundColor:(bg ? bg : [UIColor systemBackgroundColor])];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8022 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8023 else if([object isMemberOfClass:[DWBox class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8024 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8025 DWBox *box = object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8026
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8027 [box setColor:_back];
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8028 [box setBackgroundColor:bg];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8029 }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8030 else if([object isKindOfClass:[UITableView class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8031 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8032 DWContainer *cont = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8033
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8034 [cont setBackgroundColor:(bg ? bg : [UIColor systemBackgroundColor])];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8035 [cont setForegroundColor:(fg ? fg : [UIColor labelColor])];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8036 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8037 else if([object isMemberOfClass:[DWMLE class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8038 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8039 DWMLE *mle = handle;
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8040 [mle setBackgroundColor:(bg ? bg : [UIColor systemBackgroundColor])];
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8041 [mle setTextColor:(fg ? fg : [UIColor labelColor])];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8042 }
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
8043 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8044 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8045
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8046 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8047 * Sets the font used by a specified window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8048 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8049 * handle: The window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8050 * border: Size of the window border in pixels.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8051 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8052 int API dw_window_set_border(HWND handle, int border)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8053 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8054 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8055 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8056
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8057 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8058 * Sets the style of a given window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8059 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8060 * handle: Window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8061 * width: New width in pixels.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8062 * height: New height in pixels.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8063 */
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
8064 DW_FUNCTION_DEFINITION(dw_window_set_style, void, HWND handle, ULONG style, ULONG mask)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
8065 DW_FUNCTION_ADD_PARAM3(handle, style, mask)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
8066 DW_FUNCTION_NO_RETURN(dw_window_set_style)
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
8067 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, style, ULONG, mask, ULONG)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8068 {
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
8069 id object = _dw_text_handle(handle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8070
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8071 if([object isKindOfClass:[UILabel class]])
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8072 {
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8073 UILabel *label = object;
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8074
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8075 [label setTextAlignment:(style & 0xF)];
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8076 #if 0 /* TODO: Implement vertical centering */
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8077 if(mask & DW_DT_VCENTER)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8078 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8079 [cell setVCenter:(style & DW_DT_VCENTER ? YES : NO)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8080 }
2378
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8081 #endif
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8082 if(mask & DW_DT_WORDBREAK)
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8083 {
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8084 if(style & DW_DT_WORDBREAK)
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8085 [label setLineBreakMode:NSLineBreakByWordWrapping];
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8086 else
cc858be0cb81 iOS: More work on conversion from Mac... going to be a few more of these
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2377
diff changeset
8087 [label setLineBreakMode:NSLineBreakByTruncatingTail];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8088 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8089 }
2425
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8090 else if([object isMemberOfClass:[DWMLE class]])
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8091 {
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8092 DWMLE *mle = handle;
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8093 [mle setTextAlignment:(style & mask)];
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8094 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8095 else if([object isMemberOfClass:[DWMenuItem class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8096 {
2425
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8097 DWMenuItem *menuitem = object;
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8098
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8099 if(mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8100 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8101 if(style & DW_MIS_CHECKED)
2425
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8102 [menuitem setState:UIMenuElementStateOn];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8103 else if(style & DW_MIS_UNCHECKED)
2425
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8104 [menuitem setState:UIMenuElementStateOff];
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8105 }
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8106 #if 0 /* Disabled menu items not available on iOS currently */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8107 if(mask & (DW_MIS_ENABLED | DW_MIS_DISABLED))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8108 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8109 if(style & DW_MIS_ENABLED)
2425
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8110 [menuitem setEnabled:YES];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8111 else if(style & DW_MIS_DISABLED)
2425
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8112 [menuitem setEnabled:NO];
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8113 }
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8114 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8115 }
2399
1cbc316292c1 iOS: Move more functions into thread safety, iOS is very adamant about the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2396
diff changeset
8116 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8117 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8118
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8119 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8120 * Sets the current focus item for a window/dialog.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8121 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8122 * handle: Handle to the dialog item to be focused.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8123 * Remarks:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8124 * This is for use after showing the window/dialog.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8125 */
2400
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8126 DW_FUNCTION_DEFINITION(dw_window_set_focus, void, HWND handle)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8127 DW_FUNCTION_ADD_PARAM1(handle)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8128 DW_FUNCTION_NO_RETURN(dw_window_set_focus)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8129 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8130 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8131 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8132
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8133 [object becomeFirstResponder];
2400
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8134 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8135 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8136
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8137 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8138 * Sets the default focus item for a window/dialog.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8139 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8140 * window: Toplevel window or dialog.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8141 * defaultitem: Handle to the dialog item to be default.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8142 * Remarks:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8143 * This is for use before showing the window/dialog.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8144 */
2400
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8145 DW_FUNCTION_DEFINITION(dw_window_default, void, HWND handle, HWND defaultitem)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8146 DW_FUNCTION_ADD_PARAM2(handle, defaultitem)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8147 DW_FUNCTION_NO_RETURN(dw_window_default)
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8148 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, defaultitem, HWND)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8149 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8150 DWWindow *window = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8151 id object = defaultitem;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8152
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8153 if([window isKindOfClass:[UIWindow class]] && [object isKindOfClass:[UIControl class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8154 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8155 [object becomeFirstResponder];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8156 }
2400
5e454dfab0db iOS: More thread safety, remove some debug code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2399
diff changeset
8157 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8158 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8159
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8160 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8161 * Sets window to click the default dialog item when an ENTER is pressed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8162 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8163 * window: Window (widget) to look for the ENTER press.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8164 * next: Window (widget) to move to next (or click)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8165 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8166 void API dw_window_click_default(HWND handle, HWND next)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8167 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8168 /* TODO: Figure out how to do this if we should */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8169 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8170
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8171 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8172 * Captures the mouse input to this window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8173 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8174 * handle: Handle to receive mouse input.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8175 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8176 void API dw_window_capture(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8177 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8178 /* Don't do anything for now */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8179 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8180
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8181 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8182 * Releases previous mouse capture.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8183 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8184 void API dw_window_release(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8185 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8186 /* Don't do anything for now */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8187 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8188
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8189 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8190 * Changes a window's parent to newparent.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8191 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8192 * handle: The window handle to destroy.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8193 * newparent: The window's new parent window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8194 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8195 void API dw_window_reparent(HWND handle, HWND newparent)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8196 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8197 /* TODO: Not sure if we should even bother with this */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8198 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8199
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8200 /* Allows the user to choose a font using the system's font chooser dialog.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8201 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8202 * currfont: current font
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8203 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8204 * A malloced buffer with the selected font or NULL on error.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8205 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8206 char * API dw_font_choose(const char *currfont)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8207 {
2414
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8208 NSPointerArray *params = [[NSPointerArray pointerArrayWithOptions:NSPointerFunctionsOpaqueMemory] retain];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8209 char *font = NULL;
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8210
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8211 [params addPointer:(void *)currfont];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8212 [DWObj safeCall:@selector(fontPicker:) withObject:params];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8213 if([params count] > 1)
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8214 font = [params pointerAtIndex:1];
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8215
5e5fab842901 iOS: Implement dw_font_choose() and dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2413
diff changeset
8216 return font;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8217 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8218
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8219 /* Internal function to return a pointer to an item struct
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8220 * with information about the packing information regarding object.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8221 */
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
8222 Item *_dw_box_item(id object)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8223 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8224 /* Find the item within the box it is packed into */
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
8225 if([object isKindOfClass:[DWBox class]] || [object isKindOfClass:[UIControl class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8226 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8227 DWBox *parent = (DWBox *)[object superview];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8228
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
8229 if([parent isKindOfClass:[DWBox class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8230 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8231 Box *thisbox = [parent box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8232 Item *thisitem = thisbox->items;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8233 int z;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8234
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8235 for(z=0;z<thisbox->count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8236 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8237 if(thisitem[z].hwnd == object)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8238 return &thisitem[z];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8239 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8240 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8241 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8242 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8243 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8244
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8245 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8246 * Sets the font used by a specified window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8247 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8248 * handle: The window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8249 * fontname: Name and size of the font in the form "size.fontname"
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8250 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8251 int API dw_window_set_font(HWND handle, const char *fontname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8252 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8253 UIFont *font = fontname ? _dw_font_by_name(fontname) :
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8254 (DWDefaultFont ? DWDefaultFont : [UIFont systemFontOfSize:[UIFont smallSystemFontSize]]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8255
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8256 if(font)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8257 {
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
8258 id object = _dw_text_handle(handle);
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8259 if([object isMemberOfClass:[DWMLE class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8260 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8261 DWMLE *mle = object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8262
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8263 [mle setFont:font];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8264 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8265 else if([object isKindOfClass:[UIControl class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8266 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8267 [object setFont:font];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8268 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8269 else if([object isMemberOfClass:[DWRender class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8270 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8271 DWRender *render = object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8272
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8273 [render setFont:font];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8274 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8275 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8276 return DW_ERROR_UNKNOWN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8277 /* If we changed the text... */
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
8278 Item *item = _dw_box_item(handle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8279
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8280 /* Check to see if any of the sizes need to be recalculated */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8281 if(item && (item->origwidth == -1 || item->origheight == -1))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8282 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8283 _dw_control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8284 /* Queue a redraw on the top-level window */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8285 _dw_redraw([object window], TRUE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8286 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8287 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8288 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8289 return DW_ERROR_UNKNOWN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8290 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8291
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8292 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8293 * Returns the current font for the specified window
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8294 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8295 * handle: The window handle from which to obtain the font.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8296 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8297 char * API dw_window_get_font(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8298 {
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
8299 id object = _dw_text_handle(handle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8300 UIFont *font = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8301
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
8302 if([object isKindOfClass:[UIControl class]] || [object isMemberOfClass:[DWRender class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8303 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8304 font = [object font];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8305 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8306 if(font)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8307 {
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8308 NSString *fontname = [font fontName];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8309 NSString *output = [NSString stringWithFormat:@"%d.%s", (int)[font pointSize], [fontname UTF8String]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8310 return strdup([output UTF8String]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8311 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8312 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8313 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8314
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8315 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8316 * Destroys a window and all of it's children.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8317 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8318 * handle: The window handle to destroy.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8319 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8320 DW_FUNCTION_DEFINITION(dw_window_destroy, int, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8321 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8322 DW_FUNCTION_RETURN(dw_window_destroy, int)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8323 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8324 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8325 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8326 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8327 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8328 int retval = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8329
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8330 /* Handle destroying a top-level window */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8331 if([ object isKindOfClass:[ UIWindow class ] ])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8332 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8333 DWWindow *window = handle;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8334 [window release];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8335 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8336 /* Handle removing menu items from menus */
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8337 #if 0 /* TODO: The menus are technically immutable, so we'd need to recreate it...*/
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
8338 else if([ object isKindOfClass:[UIMenuItem class]])
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
8339 {
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8340 DWMenu *menu = [object menu];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8341
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8342 [menu removeItem:object];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8343 }
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8344 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8345 /* Handle destroying a control or box */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8346 else if([object isKindOfClass:[UIView class]] || [object isKindOfClass:[UIControl class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8347 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8348 DWBox *parent = (DWBox *)[object superview];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8349
2377
6393d8c10569 iOS: More progress on converting Mac to iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2373
diff changeset
8350 if([parent isKindOfClass:[DWBox class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8351 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8352 id window = [object window];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8353 Box *thisbox = [parent box];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8354 int z, index = -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8355 Item *tmpitem = NULL, *thisitem = thisbox->items;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8356
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8357 if(!thisitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8358 thisbox->count = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8359
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8360 for(z=0;z<thisbox->count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8361 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8362 if(thisitem[z].hwnd == object)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8363 index = z;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8364 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8365
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8366 if(index != -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8367 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8368 [object removeFromSuperview];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8369
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8370 if(thisbox->count > 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8371 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8372 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8373
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8374 /* Copy all but the current entry to the new list */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8375 for(z=0;z<index;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8376 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8377 tmpitem[z] = thisitem[z];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8378 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8379 for(z=index+1;z<thisbox->count;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8380 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8381 tmpitem[z-1] = thisitem[z];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8382 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8383 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8384
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8385 thisbox->items = tmpitem;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8386 if(thisitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8387 free(thisitem);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8388 if(tmpitem)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8389 thisbox->count--;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8390 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8391 thisbox->count = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8392
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8393 /* Queue a redraw on the top-level window */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8394 _dw_redraw(window, TRUE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8395 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8396 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8397 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8398 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8399 DW_FUNCTION_RETURN_THIS(retval);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8400 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8401
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8402 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8403 * Gets the text used for a given window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8405 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8406 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 * text: The text associsated with a given window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8408 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8409 DW_FUNCTION_DEFINITION(dw_window_get_text, char *, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8410 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8411 DW_FUNCTION_RETURN(dw_window_get_text, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8412 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8413 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8414 DW_FUNCTION_INIT;
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
8415 id object = _dw_text_handle(handle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8416 char *retval = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8417
2427
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8418 if([object isKindOfClass:[UILabel class]] || [object isKindOfClass:[UITextField class]])
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8419 {
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8420 NSString *nsstr = [object text];
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8421
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8422 retval = strdup([nsstr UTF8String]);
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8423 }
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8424 #ifdef DW_INCLUDE_DEPRECATED
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8425 else if([object isKindOfClass:[UIControl class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8426 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8427 UIControl *control = object;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8428 NSString *nsstr = [control text];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8429
2425
60a459df758d iOS: Account for the special area at the bottom of certain devies.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2424
diff changeset
8430 if(nsstr && [nsstr length] > 0)
2427
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8431 retval = strdup([nsstr UTF8String]);
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8432 }
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8433 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8434 DW_FUNCTION_RETURN_THIS(retval);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8435 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8436
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8437 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8438 * Sets the text used for a given window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8439 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8440 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8441 * text: The text associsated with a given window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8442 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8443 DW_FUNCTION_DEFINITION(dw_window_set_text, void, HWND handle, const char *text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8444 DW_FUNCTION_ADD_PARAM2(handle, text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8445 DW_FUNCTION_NO_RETURN(dw_window_set_text)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8446 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8447 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8448 DW_FUNCTION_INIT;
2416
353581ebf4a5 iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2415
diff changeset
8449 id object = _dw_text_handle(handle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8450
2427
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8451 if([object isKindOfClass:[UILabel class]] || [object isKindOfClass:[UITextField class]])
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8452 [object setText:[NSString stringWithUTF8String:text]];
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8453 #ifdef DW_INCLUDE_DEPRECATED
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8454 else if([object isKindOfClass:[UIControl class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8455 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8456 UIControl *control = object;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8457 [control setText:[NSString stringWithUTF8String:text]];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8458 }
2427
4f078d24fe83 iOS: Correct _dw_text_handle() behavior. Add UILabel/UITextView to controls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2426
diff changeset
8459 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8460 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8461 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8462 /* If we changed the text... */
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
8463 Item *item = _dw_box_item(handle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8464
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8465 /* Check to see if any of the sizes need to be recalculated */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8466 if(item && (item->origwidth == -1 || item->origheight == -1))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8467 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8468 int newwidth, newheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8469
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8470 _dw_control_size(handle, &newwidth, &newheight);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8471
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8472 /* Only update the item and redraw the window if it changed */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8473 if((item->origwidth == -1 && item->width != newwidth) ||
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8474 (item->origheight == -1 && item->height != newheight))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8475 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8476 if(item->origwidth == -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8477 item->width = newwidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8478 if(item->origheight == -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8479 item->height = newheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8480 /* Queue a redraw on the top-level window */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8481 _dw_redraw([object window], TRUE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8482 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8483 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8484 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8485 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8486
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8487 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8488 * Sets the text used for a given window's floating bubble help.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8489 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8490 * handle: Handle to the window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8491 * bubbletext: The text in the floating bubble tooltip.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8492 */
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8493 void API dw_window_set_tooltip(HWND handle, const char *bubbletext)
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8494 {
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8495 /* Tooltips don't exist on iOS */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8496 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8497
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8498 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8499 * Disables given window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8500 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8501 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8502 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8503 DW_FUNCTION_DEFINITION(dw_window_disable, void, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8504 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8505 DW_FUNCTION_NO_RETURN(dw_window_disable)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8506 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8507 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8508 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8509 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8510
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8511 if([object isMemberOfClass:[UIScrollView class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8512 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8513 UIScrollView *sv = handle;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8514 NSArray *subviews = [sv subviews];
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8515 object = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8516 }
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
8517 if([object isKindOfClass:[UIControl class]] || [object isKindOfClass:[UIMenuItem class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8518 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8519 [object setEnabled:NO];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8520 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8521 if([object isKindOfClass:[UITextView class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8522 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8523 UITextView *mle = object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8524
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8525 [mle setEditable:NO];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8526 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8527 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8528 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8529
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8530 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8531 * Enables given window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8532 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8533 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8534 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8535 DW_FUNCTION_DEFINITION(dw_window_enable, void, HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8536 DW_FUNCTION_ADD_PARAM1(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8537 DW_FUNCTION_NO_RETURN(dw_window_enable)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8538 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8539 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8540 DW_FUNCTION_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8541 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8542
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8543 if([object isMemberOfClass:[UIScrollView class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8544 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8545 UIScrollView *sv = handle;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8546 NSArray *subviews = [sv subviews];
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8547 object = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8548 }
2383
a410d42d9e36 iOS: Implement classes for encapsulating immutable UIImage and UIMenu so the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2382
diff changeset
8549 if([object isKindOfClass:[UIControl class]] /* TODO: || [object isKindOfClass:[UIMenuItem class]] */)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8550 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8551 [object setEnabled:YES];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8552 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8553 if([object isKindOfClass:[UITextView class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8554 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8555 UITextView *mle = object;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8556
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8557 [mle setEditable:YES];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8558 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8559 DW_FUNCTION_RETURN_NOTHING;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8560 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8561
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8562 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8563 * Sets the bitmap used for a given static window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8564 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8565 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8566 * id: An ID to be used to specify the icon,
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8567 * (pass 0 if you use the filename param)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8568 * filename: a path to a file (Bitmap on OS/2 or
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8569 * Windows and a pixmap on Unix, pass
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8570 * NULL if you use the id param)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8571 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8572 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8573 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8574 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8575
2450
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8576 if([object isKindOfClass:[UIImageView class]] || [object isMemberOfClass:[DWButton class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8577 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8578 if(data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8579 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8580 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8581 NSData *thisdata = [NSData dataWithBytes:data length:len];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8582 UIImage *pixmap = [[[UIImage alloc] initWithData:thisdata] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8583
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8584 if(pixmap)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8585 {
2450
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8586 if([object isMemberOfClass:[DWButton class]])
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8587 {
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8588 DWButton *button = object;
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8589 [button setImage:pixmap forState:UIControlStateNormal];
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8590 }
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8591 else
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8592 {
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8593 UIImageView *iv = object;
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8594 [iv setImage:pixmap];
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8595 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8596 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8597 /* If we changed the bitmap... */
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
8598 Item *item = _dw_box_item(handle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8599
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8600 /* Check to see if any of the sizes need to be recalculated */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8601 if(item && (item->origwidth == -1 || item->origheight == -1))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8602 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8603 _dw_control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8604 /* Queue a redraw on the top-level window */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8605 _dw_redraw([object window], TRUE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8606 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8607 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8608 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8609 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8610 dw_window_set_bitmap(handle, cid, NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8611 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8612 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8613
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8614 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8615 * Sets the bitmap used for a given static window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8616 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8617 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8618 * id: An ID to be used to specify the icon,
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8619 * (pass 0 if you use the filename param)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8620 * filename: a path to a file (Bitmap on OS/2 or
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8621 * Windows and a pixmap on Unix, pass
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8622 * NULL if you use the id param)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8623 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8624 void API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8625 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8626 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8627 DW_LOCAL_POOL_IN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8628
2450
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8629 if([object isKindOfClass:[UIImageView class]] || [object isMemberOfClass:[DWButton class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8630 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8631 UIImage *bitmap = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8632
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8633 if(filename)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8634 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8635 char *ext = _dw_get_image_extension( filename );
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8636 NSString *nstr = [ NSString stringWithUTF8String:filename ];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8637
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8638 bitmap = [[[UIImage alloc] initWithContentsOfFile:nstr] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8639
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8640 if(!bitmap && ext)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8641 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8642 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8643 bitmap = [[[UIImage alloc] initWithContentsOfFile:nstr] autorelease];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8644 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8645 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8646 if(!bitmap && resid > 0 && resid < 65536)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8647 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8648 bitmap = _dw_icon_load(resid);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8649 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8650
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8651 if(bitmap)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8652 {
2450
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8653 if([object isMemberOfClass:[DWButton class]])
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8654 {
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8655 DWButton *button = object;
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8656 [button setImage:bitmap forState:UIControlStateNormal];
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8657 }
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8658 else
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8659 {
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8660 UIImageView *iv = object;
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8661 [iv setImage:bitmap];
2c03987c95bd iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2449
diff changeset
8662 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8663
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8664 /* If we changed the bitmap... */
2391
a7bfb97fd80e iOS: Switch to using UIApplicationMain() in dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2390
diff changeset
8665 Item *item = _dw_box_item(handle);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8666
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8667 /* Check to see if any of the sizes need to be recalculated */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8668 if(item && (item->origwidth == -1 || item->origheight == -1))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8669 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8670 _dw_control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8671 /* Queue a redraw on the top-level window */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8672 _dw_redraw([object window], TRUE);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8673 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8674 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8675 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8676 DW_LOCAL_POOL_OUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8677 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8678
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8679 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8680 * Sets the icon used for a given window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8681 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8682 * handle: Handle to the window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8683 * id: An ID to be used to specify the icon.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8684 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8685 void API dw_window_set_icon(HWND handle, HICN icon)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8686 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8687 /* This isn't needed, it is loaded from the bundle */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8688 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8689
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8690 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8691 * Gets the child window handle with specified ID.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8692 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8693 * handle: Handle to the parent window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8694 * id: Integer ID of the child.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8695 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8696 HWND API dw_window_from_id(HWND handle, int cid)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8697 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8698 NSObject *object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8699 UIView *view = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8700 if([ object isKindOfClass:[ UIWindow class ] ])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8701 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8702 UIWindow *window = handle;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8703 NSArray *subviews = [window subviews];
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8704 view = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8705 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8706 return [view viewWithTag:cid];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8707 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8708
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8709 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8710 * Minimizes or Iconifies a top-level window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8711 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8712 * handle: The window handle to minimize.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8713 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8714 int API dw_window_minimize(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8715 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8716 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8717 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8718
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8719 /* Causes entire window to be invalidated and redrawn.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8720 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8721 * handle: Toplevel window handle to be redrawn.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8722 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8723 void API dw_window_redraw(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8724 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8725 DWWindow *window = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8726 [window setRedraw:YES];
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8727 [window setShown:YES];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8728 [window setRedraw:NO];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8729 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8730
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8731 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8732 * Makes the window topmost.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8733 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8734 * handle: The window handle to make topmost.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8735 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8736 int API dw_window_raise(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8737 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8738 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8739 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8740
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8741 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8742 * Makes the window bottommost.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8743 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8744 * handle: The window handle to make bottommost.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8745 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8746 int API dw_window_lower(HWND handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8747 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8748 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8749 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8750
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8751 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8752 * Sets the size of a given window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8753 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8754 * handle: Window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8755 * width: New width in pixels.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8756 * height: New height in pixels.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8757 */
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8758 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8759 {
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8760 /* On iOS the window usually takes up the full screen */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8761 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8762
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8763 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8764 * Gets the size the system thinks the widget should be.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8765 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8766 * handle: Window handle of the item to be back.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8767 * width: Width in pixels of the item or NULL if not needed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8768 * height: Height in pixels of the item or NULL if not needed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8769 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8770 void API dw_window_get_preferred_size(HWND handle, int *width, int *height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8771 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8772 id object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8773
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8774 if([object isMemberOfClass:[DWBox class]])
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8775 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8776 Box *thisbox;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8777
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8778 if((thisbox = (Box *)[object box]))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8779 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8780 int depth = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8781
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8782 /* Calculate space requirements */
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
8783 _dw_resize_box(thisbox, &depth, 0, 0, 1);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8784
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8785 /* Return what was requested */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8786 if(width) *width = thisbox->minwidth;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8787 if(height) *height = thisbox->minheight;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8788 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8789 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8790 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8791 _dw_control_size(handle, width, height);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8792 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8793
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8794 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8795 * Sets the gravity of a given window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8796 * Gravity controls which corner of the screen and window the position is relative to.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8797 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8798 * handle: Window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8799 * horz: DW_GRAV_LEFT (default), DW_GRAV_RIGHT or DW_GRAV_CENTER.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8800 * vert: DW_GRAV_TOP (default), DW_GRAV_BOTTOM or DW_GRAV_CENTER.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8801 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8802 void API dw_window_set_gravity(HWND handle, int horz, int vert)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8803 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8804 dw_window_set_data(handle, "_dw_grav_horz", DW_INT_TO_POINTER(horz));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8805 dw_window_set_data(handle, "_dw_grav_vert", DW_INT_TO_POINTER(vert));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8806 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8807
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8808 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8809 * Sets the position of a given window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8810 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8811 * handle: Window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8812 * x: X location from the bottom left.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8813 * y: Y location from the bottom left.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8814 */
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8815 void API dw_window_set_pos(HWND handle, LONG x, LONG y)
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8816 {
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8817 /* iOS windows take up the whole screen */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8818 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8819
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8820 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8821 * Sets the position and size of a given window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8822 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8823 * handle: Window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8824 * x: X location from the bottom left.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8825 * y: Y location from the bottom left.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8826 * width: Width of the widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8827 * height: Height of the widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8828 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8829 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8830 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8831 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8832
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8833 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8834 * Gets the position and size of a given window (widget).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8835 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8836 * handle: Window (widget) handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8837 * x: X location from the bottom left.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8838 * y: Y location from the bottom left.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8839 * width: Width of the widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8840 * height: Height of the widget.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8841 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8842 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8843 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8844 NSObject *object = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8845
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8846 if([ object isKindOfClass:[ UIWindow class ] ])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8847 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8848 UIWindow *window = handle;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
8849 CGRect rect = [window frame];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8850 if(x)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8851 *x = rect.origin.x;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8852 if(y)
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8853 *y = rect.origin.y;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8854 if(width)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8855 *width = rect.size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8856 if(height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8857 *height = rect.size.height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8858 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8859 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8860 else if([ object isKindOfClass:[ UIControl class ] ])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8861 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8862 UIControl *control = handle;
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
8863 CGRect rect = [control frame];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8864 if(x)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8865 *x = rect.origin.x;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8866 if(y)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8867 *y = rect.origin.y;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8868 if(width)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8869 *width = rect.size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8870 if(height)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8871 *height = rect.size.height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8872 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8873 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8874 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8875
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8876 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8877 * Returns the width of the screen.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8878 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8879 int API dw_screen_width(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8880 {
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8881 CGRect screenRect = [[UIScreen mainScreen] bounds];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8882 return screenRect.size.width;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8883 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8884
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8885 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8886 * Returns the height of the screen.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8887 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8888 int API dw_screen_height(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8889 {
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8890 CGRect screenRect = [[UIScreen mainScreen] bounds];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8891 return screenRect.size.height;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8892 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8893
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8894 /* This should return the current color depth */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8895 unsigned long API dw_color_depth_get(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8896 {
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8897 /* iOS always runs in 32bit depth */
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
8898 return 32;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8899 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8900
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8901 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8902 * Creates a new system notification if possible.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8903 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8904 * title: The short title of the notification.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8905 * imagepath: Path to an image to display or NULL if none.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8906 * description: A longer description of the notification,
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8907 * or NULL if none is necessary.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8908 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8909 * A handle to the notification which can be used to attach a "clicked" event if desired,
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8910 * or NULL if it fails or notifications are not supported by the system.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8911 * Remarks:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8912 * This will create a system notification that will show in the notifaction panel
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8913 * on supported systems, which may be clicked to perform another task.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8914 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8915 HWND dw_notification_new(const char *title, const char *imagepath, const char *description, ...)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8916 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8917 char outbuf[1025] = {0};
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8918 HWND retval = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8919
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8920 if(description)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8921 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8922 va_list args;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8923
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8924 va_start(args, description);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8925 vsnprintf(outbuf, 1024, description, args);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8926 va_end(args);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8927 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8928
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8929 /* Configure the notification's payload. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8930 if (@available(iOS 10.0, *))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8931 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8932 if([[NSBundle mainBundle] bundleIdentifier] != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8933 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8934 UNMutableNotificationContent* notification = [[UNMutableNotificationContent alloc] init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8935
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8936 if(notification)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8937 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8938 notification.title = [NSString stringWithUTF8String:title];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8939 if(description)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8940 notification.body = [NSString stringWithUTF8String:outbuf];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8941 if(imagepath)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8942 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8943 NSURL *url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:imagepath]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8944 NSError *error;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8945 UNNotificationAttachment *attachment = [UNNotificationAttachment attachmentWithIdentifier:@"imageID"
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8946 URL:url
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8947 options:nil
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8948 error:&error];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8949 if(attachment)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8950 notification.attachments = @[attachment];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8951 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8952 retval = notification;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8953 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8954 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8955 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8956 return retval;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8957 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8958
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8959 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8960 * Sends a notification created by dw_notification_new() after attaching signal handler.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8961 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8962 * notification: The handle to the notification returned by dw_notification_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8963 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8964 * DW_ERROR_NONE on success, DW_ERROR_UNKNOWN on error or not supported.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8965 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8966 int dw_notification_send(HWND notification)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8967 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8968 if(notification)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8969 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8970 NSString *notid = [NSString stringWithFormat:@"dw-notification-%llu", DW_POINTER_TO_ULONGLONG(notification)];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8971
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8972 /* Schedule the notification. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8973 if (@available(iOS 10.0, *))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8974 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8975 if([[NSBundle mainBundle] bundleIdentifier] != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8976 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8977 UNMutableNotificationContent* content = (UNMutableNotificationContent *)notification;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8978 UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:notid content:content trigger:nil];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8979
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8980 UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8981 [center addNotificationRequest:request withCompletionHandler:nil];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8982 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8983 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8984 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8985 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8986 return DW_ERROR_UNKNOWN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8987 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8988
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8989
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8990 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8991 * Returns some information about the current operating environment.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8992 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8993 * env: Pointer to a DWEnv struct.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8994 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8995 void dw_environment_query(DWEnv *env)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8996 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8997 memset(env, '\0', sizeof(DWEnv));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8998 strcpy(env->osName, "iOS");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8999
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9000 strncpy(env->buildDate, __DATE__, sizeof(env->buildDate)-1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9001 strncpy(env->buildTime, __TIME__, sizeof(env->buildTime)-1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9002 strncpy(env->htmlEngine, "WEBKIT", sizeof(env->htmlEngine)-1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9003 env->DWMajorVersion = DW_MAJOR_VERSION;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9004 env->DWMinorVersion = DW_MINOR_VERSION;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9005 #ifdef VER_REV
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9006 env->DWSubVersion = VER_REV;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9007 #else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9008 env->DWSubVersion = DW_SUB_VERSION;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9009 #endif
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9010
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9011 env->MajorVersion = DWOSMajor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9012 env->MinorVersion = DWOSMinor;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9013 env->MajorBuild = DWOSBuild;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9014 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9015
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9016 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9017 * Emits a beep.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9018 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9019 * freq: Frequency.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9020 * dur: Duration.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9021 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9022 void API dw_beep(int freq, int dur)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9023 {
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9024 AudioServicesPlayAlertSound((SystemSoundID)1104);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9025 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9026
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9027 /* Call this after drawing to the screen to make sure
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9028 * anything you have drawn is visible.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9029 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9030 void API dw_flush(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9031 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9032 /* This may need to be thread specific */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9033 [DWObj performSelectorOnMainThread:@selector(doFlush:) withObject:nil waitUntilDone:NO];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9034 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9035
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9036 /* Functions for managing the user data lists that are associated with
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9037 * a given window handle. Used in dw_window_set_data() and
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9038 * dw_window_get_data().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9039 */
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9040 UserData *_dw_find_userdata(UserData **root, const char *varname)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9041 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9042 UserData *tmp = *root;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9043
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9044 while(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9045 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9046 if(strcasecmp(tmp->varname, varname) == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9047 return tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9048 tmp = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9049 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9050 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9051 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9052
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9053 int _dw_new_userdata(UserData **root, const char *varname, void *data)
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9054 {
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9055 UserData *new = _dw_find_userdata(root, varname);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9056
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9057 if(new)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9058 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9059 new->data = data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9060 return TRUE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9061 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9062 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9063 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9064 new = malloc(sizeof(UserData));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9065 if(new)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9066 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9067 new->varname = strdup(varname);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9068 new->data = data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9069
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9070 new->next = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9071
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9072 if (!*root)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9073 *root = new;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9074 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9075 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9076 UserData *prev = *root, *tmp = prev->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9077
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9078 while(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9079 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9080 prev = tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9081 tmp = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9082 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9083 prev->next = new;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9084 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9085 return TRUE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9086 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9087 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9088 return FALSE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9089 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9090
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
9091 int _dw_remove_userdata(UserData **root, const char *varname, int all)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9092 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9093 UserData *prev = NULL, *tmp = *root;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9094
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9095 while(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9096 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9097 if(all || strcasecmp(tmp->varname, varname) == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9098 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9099 if(!prev)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9100 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9101 *root = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9102 free(tmp->varname);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9103 free(tmp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9104 if(!all)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9105 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9106 tmp = *root;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9107 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9108 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9109 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9110 /* If all is true we should
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9111 * never get here.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9112 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9113 prev->next = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9114 free(tmp->varname);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9115 free(tmp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9116 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9117 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9118 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9119 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9120 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9121 prev = tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9122 tmp = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9123 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9124 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9125 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9126 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9127
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9128 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9129 * Add a named user data item to a window handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9130 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9131 * window: Window handle of signal to be called back.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9132 * dataname: A string pointer identifying which signal to be hooked.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9133 * data: User data to be passed to the handler function.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9134 */
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9135 DW_FUNCTION_DEFINITION(dw_window_set_data, void, HWND window, const char *dataname, void *data)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9136 DW_FUNCTION_ADD_PARAM3(window, dataname, data)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9137 DW_FUNCTION_NO_RETURN(dw_window_set_data)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9138 DW_FUNCTION_RESTORE_PARAM3(window, HWND, dataname, const char *, data, void *)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9139 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9140 id object = window;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9141 if([object isMemberOfClass:[DWWindow class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9142 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9143 UIWindow *win = window;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
9144 NSArray *subviews = [win subviews];
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
9145 object = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9146 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9147 else if([object isMemberOfClass:[UIScrollView class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9148 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9149 UIScrollView *sv = window;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
9150 NSArray *subviews = [sv subviews];
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
9151 object = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9152 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9153 WindowData *blah = (WindowData *)[object userdata];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9154
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9155 if(!blah)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9156 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9157 if(!dataname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9158 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9159
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9160 blah = calloc(1, sizeof(WindowData));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9161 [object setUserdata:blah];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9162 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9163
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9164 if(data)
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9165 _dw_new_userdata(&(blah->root), dataname, data);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9166 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9167 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9168 if(dataname)
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
9169 _dw_remove_userdata(&(blah->root), dataname, FALSE);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9170 else
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
9171 _dw_remove_userdata(&(blah->root), NULL, TRUE);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9172 }
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9173 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9174 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9175
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9176 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9177 * Gets a named user data item to a window handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9178 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9179 * window: Window handle of signal to be called back.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9180 * dataname: A string pointer identifying which signal to be hooked.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9181 * data: User data to be passed to the handler function.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9182 */
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9183 DW_FUNCTION_DEFINITION(dw_window_get_data, void *, HWND window, const char *dataname)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9184 DW_FUNCTION_ADD_PARAM2(window, dataname)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9185 DW_FUNCTION_RETURN(dw_window_get_data, void *)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9186 DW_FUNCTION_RESTORE_PARAM2(window, HWND, dataname, const char *)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9187 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9188 id object = window;
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9189 void *retval = NULL;
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9190
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9191 if([object isMemberOfClass:[DWWindow class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9192 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9193 UIWindow *win = window;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
9194 NSArray *subviews = [win subviews];
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
9195 object = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9196 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9197 else if([object isMemberOfClass:[UIScrollView class]])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9198 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9199 UIScrollView *sv = window;
2384
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
9200 NSArray *subviews = [sv subviews];
32ebd33be56b iOS: First building version. Yay! Still lots to do but progress.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2383
diff changeset
9201 object = [subviews firstObject];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9202 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9203 WindowData *blah = (WindowData *)[object userdata];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9204
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9205 if(blah && blah->root && dataname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9206 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9207 UserData *ud = _dw_find_userdata(&(blah->root), dataname);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9208 if(ud)
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9209 retval = ud->data;
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9210 }
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9211 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9212 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9213
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9214 #define DW_TIMER_MAX 64
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9215 static NSTimer *DWTimers[DW_TIMER_MAX];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9216
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9217 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9218 * Add a callback to a timer event.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9219 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9220 * interval: Milliseconds to delay between calls.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9221 * sigfunc: The pointer to the function to be used as the callback.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9222 * data: User data to be passed to the handler function.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9223 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9224 * Timer ID for use with dw_timer_disconnect(), 0 on error.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9225 */
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9226 DW_FUNCTION_DEFINITION(dw_timer_connect, int, int interval, void *sigfunc, void *data)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9227 DW_FUNCTION_ADD_PARAM3(interval, sigfunc, data)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9228 DW_FUNCTION_RETURN(dw_timer_connect, int)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9229 DW_FUNCTION_RESTORE_PARAM3(interval, int, sigfunc, void *, data, void *)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9230 {
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9231 int z, retval = 0;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9232
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9233 for(z=0;z<DW_TIMER_MAX;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9234 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9235 if(!DWTimers[z])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9236 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9237 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9238 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9239 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9240
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9241 if(sigfunc && !DWTimers[z])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9242 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9243 NSTimeInterval seconds = (double)interval / 1000.0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9244 NSTimer *thistimer = DWTimers[z] = [NSTimer scheduledTimerWithTimeInterval:seconds target:DWHandler selector:@selector(runTimer:) userInfo:nil repeats:YES];
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
9245 _dw_new_signal(0, thistimer, z+1, sigfunc, NULL, data);
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9246 retval = z+1;
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9247 }
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9248 DW_FUNCTION_RETURN_THIS(retval);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9249 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9250
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9251 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9252 * Removes timer callback.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9253 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9254 * id: Timer ID returned by dw_timer_connect().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9255 */
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9256 DW_FUNCTION_DEFINITION(dw_timer_disconnect, void, int timerid)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9257 DW_FUNCTION_ADD_PARAM1(timerid)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9258 DW_FUNCTION_NO_RETURN(dw_timer_disconnect)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9259 DW_FUNCTION_RESTORE_PARAM1(timerid, int)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9260 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9261 SignalHandler *prev = NULL, *tmp = DWRoot;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9262 NSTimer *thistimer;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9263
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9264 /* 0 is an invalid timer ID */
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9265 if(timerid > 0 && timerid < DW_TIMER_MAX && DWTimers[timerid-1])
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9266 {
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9267 thistimer = DWTimers[timerid-1];
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9268 DWTimers[timerid-1] = nil;
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9269
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9270 [thistimer invalidate];
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9271
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9272 while(tmp)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9273 {
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9274 if(tmp->id == timerid && tmp->window == thistimer)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9275 {
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9276 if(prev)
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9277 {
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9278 prev->next = tmp->next;
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9279 free(tmp);
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9280 tmp = prev->next;
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9281 }
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9282 else
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9283 {
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9284 DWRoot = tmp->next;
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9285 free(tmp);
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9286 tmp = DWRoot;
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9287 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9288 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9289 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9290 {
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9291 prev = tmp;
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9292 tmp = tmp->next;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9293 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9294 }
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9295 }
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
9296 DW_FUNCTION_RETURN_NOTHING;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9297 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9298
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9299 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9300 * Add a callback to a window event.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9301 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9302 * window: Window handle of signal to be called back.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9303 * signame: A string pointer identifying which signal to be hooked.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9304 * sigfunc: The pointer to the function to be used as the callback.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9305 * data: User data to be passed to the handler function.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9306 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9307 void API dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9308 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9309 dw_signal_connect_data(window, signame, sigfunc, NULL, data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9310 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9311
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9312 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9313 * Add a callback to a window event with a closure callback.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9314 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9315 * window: Window handle of signal to be called back.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9316 * signame: A string pointer identifying which signal to be hooked.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9317 * sigfunc: The pointer to the function to be used as the callback.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9318 * discfunc: The pointer to the function called when this handler is removed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9319 * data: User data to be passed to the handler function.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9320 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9321 void API dw_signal_connect_data(HWND window, const char *signame, void *sigfunc, void *discfunc, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9322 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9323 ULONG message = 0, msgid = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9324
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9325 /* Handle special case of application delete signal */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9326 if(!window && signame && strcmp(signame, DW_SIGNAL_DELETE) == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9327 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9328 window = DWApp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9329 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9330
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9331 if(window && signame && sigfunc)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9332 {
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
9333 if((message = _dw_findsigmessage(signame)) != 0)
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
9334 {
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
9335 _dw_new_signal(message, window, (int)msgid, sigfunc, discfunc, data);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9336 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9337 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9338 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9339
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9340 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9341 * Removes callbacks for a given window with given name.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9342 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9343 * window: Window handle of callback to be removed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9344 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9345 void API dw_signal_disconnect_by_name(HWND window, const char *signame)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9346 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9347 SignalHandler *prev = NULL, *tmp = DWRoot;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9348 ULONG message;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9349
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
9350 if(!window || !signame || (message = _dw_findsigmessage(signame)) == 0)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9351 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9352
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9353 while(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9354 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9355 if(tmp->window == window && tmp->message == message)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9356 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9357 void (*discfunc)(HWND, void *) = tmp->discfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9358
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9359 if(discfunc)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9360 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9361 discfunc(tmp->window, tmp->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9362 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9363
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9364 if(prev)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9365 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9366 prev->next = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9367 free(tmp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9368 tmp = prev->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9369 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9370 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9371 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9372 DWRoot = tmp->next;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9373 free(tmp);
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9374 tmp = DWRoot;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9375 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9376 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9377 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9378 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9379 prev = tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9380 tmp = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9381 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9382 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9383 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9384
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9385 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9386 * Removes all callbacks for a given window.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9387 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9388 * window: Window handle of callback to be removed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9389 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9390 void API dw_signal_disconnect_by_window(HWND window)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9391 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9392 SignalHandler *prev = NULL, *tmp = DWRoot;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9393
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9394 while(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9395 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9396 if(tmp->window == window)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9397 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9398 void (*discfunc)(HWND, void *) = tmp->discfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9399
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9400 if(discfunc)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9401 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9402 discfunc(tmp->window, tmp->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9403 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9404
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9405 if(prev)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9406 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9407 prev->next = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9408 free(tmp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9409 tmp = prev->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9410 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9411 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9412 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9413 DWRoot = tmp->next;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9414 free(tmp);
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9415 tmp = DWRoot;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9416 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9417 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9418 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9419 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9420 prev = tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9421 tmp = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9422 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9423 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9424 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9425
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9426 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9427 * Removes all callbacks for a given window with specified data.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9428 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9429 * window: Window handle of callback to be removed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9430 * data: Pointer to the data to be compared against.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9431 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9432 void API dw_signal_disconnect_by_data(HWND window, void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9433 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9434 SignalHandler *prev = NULL, *tmp = DWRoot;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9435
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9436 while(tmp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9437 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9438 if(tmp->window == window && tmp->data == data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9439 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9440 void (*discfunc)(HWND, void *) = tmp->discfunction;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9441
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9442 if(discfunc)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9443 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9444 discfunc(tmp->window, tmp->data);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9445 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9446
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9447 if(prev)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9448 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9449 prev->next = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9450 free(tmp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9451 tmp = prev->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9452 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9453 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9454 {
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9455 DWRoot = tmp->next;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9456 free(tmp);
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9457 tmp = DWRoot;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9458 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9459 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9460 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9461 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9462 prev = tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9463 tmp = tmp->next;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9464 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9465 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9466 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9467
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9468 void _dw_my_strlwr(char *buf)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9469 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9470 int z, len = (int)strlen(buf);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9471
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9472 for(z=0;z<len;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9473 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9474 if(buf[z] >= 'A' && buf[z] <= 'Z')
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9475 buf[z] -= 'A' - 'a';
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9476 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9477 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9478
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9479 /* Open a shared library and return a handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9480 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9481 * name: Base name of the shared library.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9482 * handle: Pointer to a module handle,
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9483 * will be filled in with the handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9484 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9485 int dw_module_load(const char *name, HMOD *handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9486 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9487 int len;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9488 char *newname;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9489 char errorbuf[1025];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9490
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9491
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9492 if(!handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9493 return -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9494
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9495 if((len = (int)strlen(name)) == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9496 return -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9497
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9498 /* Lenth + "lib" + ".dylib" + NULL */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9499 newname = malloc(len + 10);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9500
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9501 if(!newname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9502 return -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9503
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9504 sprintf(newname, "lib%s.dylib", name);
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9505 _dw_my_strlwr(newname);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9506
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9507 *handle = dlopen(newname, RTLD_NOW);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9508 if(*handle == NULL)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9509 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9510 strncpy(errorbuf, dlerror(), 1024);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9511 printf("%s\n", errorbuf);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9512 sprintf(newname, "lib%s.dylib", name);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9513 *handle = dlopen(newname, RTLD_NOW);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9514 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9515
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9516 free(newname);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9517
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9518 return (NULL == *handle) ? -1 : 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9519 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9520
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9521 /* Queries the address of a symbol within open handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9522 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9523 * handle: Module handle returned by dw_module_load()
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9524 * name: Name of the symbol you want the address of.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9525 * func: A pointer to a function pointer, to obtain
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9526 * the address.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9527 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9528 int dw_module_symbol(HMOD handle, const char *name, void**func)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9529 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9530 if(!func || !name)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9531 return -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9532
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9533 if(strlen(name) == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9534 return -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9535
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9536 *func = (void*)dlsym(handle, name);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9537 return (NULL == *func);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9538 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9539
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9540 /* Frees the shared library previously opened.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9541 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9542 * handle: Module handle returned by dw_module_load()
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9543 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9544 int dw_module_close(HMOD handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9545 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9546 if(handle)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9547 return dlclose(handle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9548 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9549 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9550
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9551 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9552 * Returns the handle to an unnamed mutex semaphore.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9553 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9554 HMTX dw_mutex_new(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9555 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9556 HMTX mutex = malloc(sizeof(pthread_mutex_t));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9557
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9558 pthread_mutex_init(mutex, NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9559 return mutex;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9560 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9561
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9562 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9563 * Closes a semaphore created by dw_mutex_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9564 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9565 * mutex: The handle to the mutex returned by dw_mutex_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9566 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9567 void dw_mutex_close(HMTX mutex)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9568 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9569 if(mutex)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9570 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9571 pthread_mutex_destroy(mutex);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9572 free(mutex);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9573 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9574 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9575
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9576 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9577 * Tries to gain access to the semaphore, if it can't it blocks.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9578 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9579 * mutex: The handle to the mutex returned by dw_mutex_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9580 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9581 void dw_mutex_lock(HMTX mutex)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9582 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9583 /* We need to handle locks from the main thread differently...
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9584 * since we can't stop message processing... otherwise we
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9585 * will deadlock... so try to acquire the lock and continue
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9586 * processing messages in between tries.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9587 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9588 if(DWThread == pthread_self())
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9589 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9590 while(pthread_mutex_trylock(mutex) != 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9591 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9592 /* Process any pending events */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9593 while(_dw_main_iteration([NSDate dateWithTimeIntervalSinceNow:0.01]))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9594 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9595 /* Just loop */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9596 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9597 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9598 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9599 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9600 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9601 pthread_mutex_lock(mutex);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9602 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9603 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9604
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9605 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9606 * Tries to gain access to the semaphore.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9607 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9608 * mutex: The handle to the mutex returned by dw_mutex_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9609 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9610 * DW_ERROR_NONE on success, DW_ERROR_TIMEOUT if it is already locked.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9611 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9612 int API dw_mutex_trylock(HMTX mutex)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9613 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9614 if(pthread_mutex_trylock(mutex) == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9615 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9616 return DW_ERROR_TIMEOUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9617 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9618
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9619 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9620 * Reliquishes the access to the semaphore.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9621 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9622 * mutex: The handle to the mutex returned by dw_mutex_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9623 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9624 void dw_mutex_unlock(HMTX mutex)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9625 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9626 pthread_mutex_unlock(mutex);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9627 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9628
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9629 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9630 * Returns the handle to an unnamed event semaphore.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9631 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9632 HEV dw_event_new(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9633 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9634 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9635
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9636 if(!eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9637 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9638
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9639 /* We need to be careful here, mutexes on Linux are
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9640 * FAST by default but are error checking on other
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9641 * systems such as FreeBSD and OS/2, perhaps others.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9642 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9643 pthread_mutex_init (&(eve->mutex), NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9644 pthread_mutex_lock (&(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9645 pthread_cond_init (&(eve->event), NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9646
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9647 pthread_mutex_unlock (&(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9648 eve->alive = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9649 eve->posted = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9650
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9651 return eve;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9652 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9653
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9654 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9655 * Resets a semaphore created by dw_event_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9656 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9657 * eve: The handle to the event returned by dw_event_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9658 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9659 int dw_event_reset (HEV eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9660 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9661 if(!eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9662 return DW_ERROR_NON_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9663
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9664 pthread_mutex_lock (&(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9665 pthread_cond_broadcast (&(eve->event));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9666 pthread_cond_init (&(eve->event), NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9667 eve->posted = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9668 pthread_mutex_unlock (&(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9669 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9670 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9671
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9672 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9673 * Posts a semaphore created by dw_event_new(). Causing all threads
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9674 * waiting on this event in dw_event_wait to continue.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9675 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9676 * eve: The handle to the event returned by dw_event_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9677 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9678 int dw_event_post (HEV eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9679 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9680 if(!eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9681 return FALSE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9682
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9683 pthread_mutex_lock (&(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9684 pthread_cond_broadcast (&(eve->event));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9685 eve->posted = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9686 pthread_mutex_unlock (&(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9687 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9688 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9689
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9690 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9691 * Waits on a semaphore created by dw_event_new(), until the
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9692 * event gets posted or until the timeout expires.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9693 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9694 * eve: The handle to the event returned by dw_event_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9695 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9696 int dw_event_wait(HEV eve, unsigned long timeout)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9697 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9698 int rc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9699
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9700 if(!eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9701 return DW_ERROR_NON_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9702
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9703 pthread_mutex_lock (&(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9704
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9705 if(eve->posted)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9706 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9707 pthread_mutex_unlock (&(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9708 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9709 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9710
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9711 if(timeout != -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9712 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9713 struct timeval now;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9714 struct timespec timeo;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9715
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9716 gettimeofday(&now, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9717 timeo.tv_sec = now.tv_sec + (timeout / 1000);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9718 timeo.tv_nsec = now.tv_usec * 1000;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9719 rc = pthread_cond_timedwait(&(eve->event), &(eve->mutex), &timeo);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9720 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9721 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9722 rc = pthread_cond_wait(&(eve->event), &(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9723 pthread_mutex_unlock (&(eve->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9724 if(!rc)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9725 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9726 if(rc == ETIMEDOUT)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9727 return DW_ERROR_TIMEOUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9728 return DW_ERROR_GENERAL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9729 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9730
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9731 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9732 * Closes a semaphore created by dw_event_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9733 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9734 * eve: The handle to the event returned by dw_event_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9735 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9736 int dw_event_close(HEV *eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9737 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9738 if(!eve || !(*eve))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9739 return DW_ERROR_NON_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9740
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9741 pthread_mutex_lock (&((*eve)->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9742 pthread_cond_destroy (&((*eve)->event));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9743 pthread_mutex_unlock (&((*eve)->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9744 pthread_mutex_destroy (&((*eve)->mutex));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9745 free(*eve);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9746 *eve = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9747
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9748 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9749 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9750
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9751 struct _seminfo {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9752 int fd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9753 int waiting;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9754 };
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9755
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9756 static void _dw_handle_sem(int *tmpsock)
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9757 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9758 fd_set rd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9759 struct _seminfo *array = (struct _seminfo *)malloc(sizeof(struct _seminfo));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9760 int listenfd = tmpsock[0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9761 int bytesread, connectcount = 1, maxfd, z, posted = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9762 char command;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9763 sigset_t mask;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9764
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9765 sigfillset(&mask); /* Mask all allowed signals */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9766 pthread_sigmask(SIG_BLOCK, &mask, NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9767
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9768 /* problems */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9769 if(tmpsock[1] == -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9770 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9771 free(array);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9772 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9773 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9774
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9775 array[0].fd = tmpsock[1];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9776 array[0].waiting = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9777
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9778 /* Free the memory allocated in dw_named_event_new. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9779 free(tmpsock);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9780
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9781 while(1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9782 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9783 FD_ZERO(&rd);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9784 FD_SET(listenfd, &rd);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9785
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9786 maxfd = listenfd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9787
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9788 /* Added any connections to the named event semaphore */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9789 for(z=0;z<connectcount;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9790 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9791 if(array[z].fd > maxfd)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9792 maxfd = array[z].fd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9793
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9794 FD_SET(array[z].fd, &rd);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9795 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9796
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9797 if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9798 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9799 free(array);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9800 return;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9801 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9802
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9803 if(FD_ISSET(listenfd, &rd))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9804 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9805 struct _seminfo *newarray;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9806 int newfd = accept(listenfd, 0, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9807
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9808 if(newfd > -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9809 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9810 /* Add new connections to the set */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9811 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount+1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9812 memcpy(newarray, array, sizeof(struct _seminfo)*(connectcount));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9813
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9814 newarray[connectcount].fd = newfd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9815 newarray[connectcount].waiting = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9816
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9817 connectcount++;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9818
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9819 /* Replace old array with new one */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9820 free(array);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9821 array = newarray;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9822 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9823 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9824
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9825 /* Handle any events posted to the semaphore */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9826 for(z=0;z<connectcount;z++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9827 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9828 if(FD_ISSET(array[z].fd, &rd))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9829 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9830 if((bytesread = (int)read(array[z].fd, &command, 1)) < 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9831 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9832 struct _seminfo *newarray = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9833
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9834 /* Remove this connection from the set */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9835 if(connectcount > 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9836 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9837 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount-1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9838 if(!z)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9839 memcpy(newarray, &array[1], sizeof(struct _seminfo)*(connectcount-1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9840 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9841 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9842 memcpy(newarray, array, sizeof(struct _seminfo)*z);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9843 if(z!=(connectcount-1))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9844 memcpy(&newarray[z], &array[z+1], sizeof(struct _seminfo)*(z-connectcount-1));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9845 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9846 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9847 connectcount--;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9848
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9849 /* Replace old array with new one */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9850 free(array);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9851 array = newarray;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9852 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9853 else if(bytesread == 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9854 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9855 switch(command)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9856 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9857 case 0:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9858 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9859 /* Reset */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9860 posted = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9861 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9862 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9863 case 1:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9864 /* Post */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9865 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9866 int s;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9867 char tmp = (char)0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9868
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9869 posted = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9870
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9871 for(s=0;s<connectcount;s++)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9872 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9873 /* The semaphore has been posted so
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9874 * we tell all the waiting threads to
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9875 * continue.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9876 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9877 if(array[s].waiting)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9878 write(array[s].fd, &tmp, 1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9879 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9880 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9881 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9882 case 2:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9883 /* Wait */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9884 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9885 char tmp = (char)0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9886
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9887 array[z].waiting = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9888
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9889 /* If we are posted exit immeditately */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9890 if(posted)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9891 write(array[z].fd, &tmp, 1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9892 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9893 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9894 case 3:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9895 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9896 /* Done Waiting */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9897 array[z].waiting = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9898 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9899 break;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9900 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9901 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9902 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9903 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9904 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9905 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9906
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9907 /* Using domain sockets on unix for IPC */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9908 /* Create a named event semaphore which can be
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9909 * opened from other processes.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9910 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9911 * eve: Pointer to an event handle to receive handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9912 * name: Name given to semaphore which can be opened
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9913 * by other processes.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9914 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9915 HEV dw_named_event_new(const char *name)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9916 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9917 struct sockaddr_un un;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9918 int ev, *tmpsock = (int *)malloc(sizeof(int)*2);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9919 HEV eve;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9920 DWTID dwthread;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9921
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9922 if(!tmpsock)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9923 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9924
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9925 eve = (HEV)malloc(sizeof(struct _dw_unix_event));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9926
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9927 if(!eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9928 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9929 free(tmpsock);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9930 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9931 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9932
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9933 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9934 ev = socket(AF_UNIX, SOCK_STREAM, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9935 memset(&un, 0, sizeof(un));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9936 un.sun_family=AF_UNIX;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9937 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9938 strcpy(un.sun_path, "/tmp/.dw/");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9939 strcat(un.sun_path, name);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9940
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9941 /* just to be safe, this should be changed
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9942 * to support multiple instances.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9943 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9944 remove(un.sun_path);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9945
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9946 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9947 listen(tmpsock[0], 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9948 connect(ev, (struct sockaddr *)&un, sizeof(un));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9949 tmpsock[1] = accept(tmpsock[0], 0, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9950
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9951 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9952 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9953 if(tmpsock[0] > -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9954 close(tmpsock[0]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9955 if(tmpsock[1] > -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9956 close(tmpsock[1]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9957 if(ev > -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9958 close(ev);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9959 free(tmpsock);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9960 free(eve);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9961 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9962 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9963
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9964 /* Create a thread to handle this event semaphore */
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
9965 pthread_create(&dwthread, NULL, (void *)_dw_handle_sem, (void *)tmpsock);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9966 eve->alive = ev;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9967 return eve;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9968 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9969
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9970 /* Open an already existing named event semaphore.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9971 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9972 * eve: Pointer to an event handle to receive handle.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9973 * name: Name given to semaphore which can be opened
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9974 * by other processes.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9975 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9976 HEV dw_named_event_get(const char *name)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9977 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9978 struct sockaddr_un un;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9979 HEV eve;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9980 int ev = socket(AF_UNIX, SOCK_STREAM, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9981 if(ev < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9982 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9983
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9984 eve = (HEV)malloc(sizeof(struct _dw_unix_event));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9985
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9986 if(!eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9987 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9988 close(ev);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9989 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9990 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9991
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9992 un.sun_family=AF_UNIX;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9993 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9994 strcpy(un.sun_path, "/tmp/.dw/");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9995 strcat(un.sun_path, name);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9996 connect(ev, (struct sockaddr *)&un, sizeof(un));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9997 eve->alive = ev;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9998 return eve;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9999 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10000
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10001 /* Resets the event semaphore so threads who call wait
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10002 * on this semaphore will block.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10003 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10004 * eve: Handle to the semaphore obtained by
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10005 * an open or create call.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10006 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10007 int dw_named_event_reset(HEV eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10008 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10009 /* signal reset */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10010 char tmp = (char)0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10011
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10012 if(!eve || eve->alive < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10013 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10014
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10015 if(write(eve->alive, &tmp, 1) == 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10016 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10017 return 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10018 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10019
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10020 /* Sets the posted state of an event semaphore, any threads
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10021 * waiting on the semaphore will no longer block.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10022 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10023 * eve: Handle to the semaphore obtained by
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10024 * an open or create call.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10025 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10026 int dw_named_event_post(HEV eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10027 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10028
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10029 /* signal post */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10030 char tmp = (char)1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10031
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10032 if(!eve || eve->alive < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10033 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10034
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10035 if(write(eve->alive, &tmp, 1) == 1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10036 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10037 return 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10038 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10039
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10040 /* Waits on the specified semaphore until it becomes
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10041 * posted, or returns immediately if it already is posted.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10042 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10043 * eve: Handle to the semaphore obtained by
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10044 * an open or create call.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10045 * timeout: Number of milliseconds before timing out
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10046 * or -1 if indefinite.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10047 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10048 int dw_named_event_wait(HEV eve, unsigned long timeout)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10049 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10050 fd_set rd;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10051 struct timeval tv, *useme = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10052 int retval = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10053 char tmp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10054
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10055 if(!eve || eve->alive < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10056 return DW_ERROR_NON_INIT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10057
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10058 /* Set the timout or infinite */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10059 if(timeout != -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10060 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10061 tv.tv_sec = timeout / 1000;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10062 tv.tv_usec = (int)timeout % 1000;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10063
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10064 useme = &tv;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10065 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10066
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10067 FD_ZERO(&rd);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10068 FD_SET(eve->alive, &rd);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10069
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10070 /* Signal wait */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10071 tmp = (char)2;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10072 write(eve->alive, &tmp, 1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10073
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10074 retval = select(eve->alive+1, &rd, NULL, NULL, useme);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10075
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10076 /* Signal done waiting. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10077 tmp = (char)3;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10078 write(eve->alive, &tmp, 1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10079
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10080 if(retval == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10081 return DW_ERROR_TIMEOUT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10082 else if(retval == -1)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10083 return DW_ERROR_INTERRUPT;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10084
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10085 /* Clear the entry from the pipe so
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10086 * we don't loop endlessly. :)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10087 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10088 read(eve->alive, &tmp, 1);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10089 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10090 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10091
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10092 /* Release this semaphore, if there are no more open
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10093 * handles on this semaphore the semaphore will be destroyed.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10094 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10095 * eve: Handle to the semaphore obtained by
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10096 * an open or create call.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10097 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10098 int dw_named_event_close(HEV eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10099 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10100 /* Finally close the domain socket,
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
10101 * cleanup will continue in _dw_handle_sem.
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10102 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10103 if(eve)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10104 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10105 close(eve->alive);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10106 free(eve);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10107 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10108 return 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10109 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10110
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10111 /* Mac specific function to cause garbage collection */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10112 void _dw_pool_drain(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10113 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10114 NSAutoreleasePool *pool = pthread_getspecific(_dw_pool_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10115 [pool drain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10116 pool = [[NSAutoreleasePool alloc] init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10117 pthread_setspecific(_dw_pool_key, pool);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10118 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10119
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10120 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10121 * Generally an internal function called from a newly created
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10122 * thread to setup the Dynamic Windows environment for the thread.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10123 * However it is exported so language bindings can call it when
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10124 * they create threads that require access to Dynamic Windows.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10125 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10126 void API _dw_init_thread(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10127 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10128 /* If we aren't using garbage collection we need autorelease pools */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10129 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10130 pthread_setspecific(_dw_pool_key, pool);
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
10131 _dw_init_colors();
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10132 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10133
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10134 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10135 * Generally an internal function called from a terminating
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10136 * thread to cleanup the Dynamic Windows environment for the thread.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10137 * However it is exported so language bindings can call it when
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10138 * they exit threads that require access to Dynamic Windows.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10139 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10140 void API _dw_deinit_thread(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10141 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10142 UIColor *color;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10143
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10144 /* Release the pool when we are done so we don't leak */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10145 color = pthread_getspecific(_dw_fg_color_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10146 [color release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10147 color = pthread_getspecific(_dw_bg_color_key);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10148 [color release];
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
10149 NSAutoreleasePool *pool = pthread_getspecific(_dw_pool_key);
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10150 [pool drain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10151 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10152
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10153 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10154 * Setup thread independent pools.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10155 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10156 void _dwthreadstart(void *data)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10157 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10158 void (*threadfunc)(void *) = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10159 void **tmp = (void **)data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10160
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10161 _dw_init_thread();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10162
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10163 threadfunc = (void (*)(void *))tmp[0];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10164
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10165 /* Start our thread function */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10166 threadfunc(tmp[1]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10167
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10168 free(tmp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10169
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10170 _dw_deinit_thread();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10171 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10172
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10173 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10174 * Sets the default font used on text based widgets.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10175 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10176 * fontname: Font name in Dynamic Windows format.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10177 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10178 void API dw_font_set_default(const char *fontname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10179 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10180 UIFont *oldfont = DWDefaultFont;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10181 DWDefaultFont = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10182 if(fontname)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10183 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10184 DWDefaultFont = _dw_font_by_name(fontname);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10185 [DWDefaultFont retain];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10186 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10187 [oldfont release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10188 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10189
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10190 /* Thread start stub to launch our main */
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10191 void _dw_main_launch(void **data)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10192 {
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10193 int (*_dwmain)(int argc, char **argv) = (int (*)(int, char **))data[0];
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10194 int argc = DW_POINTER_TO_INT(data[1]);
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10195 char **argv = (char **)data[2];
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10196
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10197 _dwmain(argc, argv);
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10198 free(data);
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10199 }
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10200
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10201 /* The iOS main thread... all this does is handle messages */
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10202 void _dw_main_thread(int argc, char *argv[])
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10203 {
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10204 DWMainEvent = dw_event_new();
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10205 dw_event_reset(DWMainEvent);
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10206 /* We wait for the dw_init() in the user's main function */
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10207 dw_event_wait(DWMainEvent, DW_TIMEOUT_INFINITE);
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10208 DWThread = dw_thread_id();
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10209 DWObj = [[DWObject alloc] init];
2407
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
10210 /* Create object for handling timers */
6336244aa895 iOS: Fix timers and implement dw_beep().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2405
diff changeset
10211 DWHandler = [[DWTimerHandler alloc] init];
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10212 UIApplicationMain(argc, argv, nil, NSStringFromClass([DWAppDel class]));
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10213 /* Shouldn't get here, but ... just in case */
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10214 DWThread = (DWTID)-1;
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10215 }
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10216
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10217 /* If DWApp is uninitialized, initialize it */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10218 void _dw_app_init(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10219 {
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10220 /* The UIApplication singleton won't be created until we call
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10221 * UIApplicationMain() which blocks indefinitely.. so we have
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10222 * a thread to just run UIApplicationMain() .. and wait until
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10223 * we get a non-nil sharedApplication result.
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10224 */
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10225 while(!DWApp)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10226 {
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10227 static int posted = FALSE;
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10228
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10229 if(DWMainEvent && !posted)
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10230 {
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10231 /* Post the DWMainEvent so the main thread
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10232 * will call UIApplicationMain() creating
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10233 * the UIApplication sharedApplication.
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10234 */
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10235 posted = TRUE;
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10236 dw_event_post(DWMainEvent);
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10237 }
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10238 pthread_yield_np();
2373
8d6ab1f46a29 iOS: Converting more types and classes to the iOS equivalents.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2372
diff changeset
10239 DWApp = [UIApplication sharedApplication];
2396
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10240 }
5bb3491ceba2 iOS: Get iOS basic funcionality working by creating dwmain() macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2395
diff changeset
10241 dw_event_reset(DWMainEvent);
2402
b28852b35452 iOS: Fix message boxes... the hiddenWindow they are attached to was being
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2401
diff changeset
10242 [DWObj performSelectorOnMainThread:@selector(delayedInit:) withObject:nil waitUntilDone:YES];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10243 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10244
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10245 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10246 * Initializes the Dynamic Windows engine.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10247 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10248 * newthread: True if this is the only thread.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10249 * False if there is already a message loop running.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10250 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10251 int API dw_init(int newthread, int argc, char *argv[])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10252 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10253 char *lang = getenv("LANG");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10254
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10255 /* Correct the startup path if run from a bundle */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10256 if(argc > 0 && argv[0])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10257 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10258 char *pathcopy = strdup(argv[0]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10259 char *app = strstr(pathcopy, ".app/");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10260 char *binname = strrchr(pathcopy, '/');
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10261
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10262 if(binname && (binname++) && !_dw_app_id[0])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10263 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10264 /* If we have a binary name, use that for the Application ID instead. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10265 snprintf(_dw_app_id, _DW_APP_ID_SIZE, "%s.%s", DW_APP_DOMAIN_DEFAULT, binname);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10266 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10267 if(app)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10268 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10269 char pathbuf[PATH_MAX+1] = { 0 };
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10270 size_t len = (size_t)(app - pathcopy);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10271
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10272 if(len > 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10273 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10274 strncpy(_dw_bundle_path, pathcopy, len + 4);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10275 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10276 *app = 0;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10277
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10278 getcwd(pathbuf, PATH_MAX);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10279
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10280 /* If run from a bundle the path seems to be / */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10281 if(strcmp(pathbuf, "/") == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10282 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10283 char *pos = strrchr(pathcopy, '/');
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10284
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10285 if(pos)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10286 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10287 strncpy(pathbuf, pathcopy, (size_t)(pos - pathcopy));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10288 chdir(pathbuf);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10289 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10290 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10291 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10292 if(pathcopy)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10293 free(pathcopy);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10294 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10295
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10296 /* Just in case we can't obtain a path */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10297 if(!_dw_bundle_path[0])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10298 getcwd(_dw_bundle_path, PATH_MAX);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10299
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10300 /* Get the operating system version */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10301 NSString *version = [[NSProcessInfo processInfo] operatingSystemVersionString];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10302 const char *versionstr = [version UTF8String];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10303 sscanf(versionstr, "Version %d.%d.%d", &DWOSMajor, &DWOSMinor, &DWOSBuild);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10304 /* Set the locale... if it is UTF-8 pass it
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10305 * directly, otherwise specify UTF-8 explicitly.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10306 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10307 setlocale(LC_ALL, lang && strstr(lang, ".UTF-8") ? lang : "UTF-8");
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10308 /* Create the application object */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10309 _dw_app_init();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10310 pthread_key_create(&_dw_pool_key, NULL);
2393
6669e152e30b iOS: More namespace cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2391
diff changeset
10311 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10312 pthread_setspecific(_dw_pool_key, pool);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10313 pthread_key_create(&_dw_fg_color_key, NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10314 pthread_key_create(&_dw_bg_color_key, NULL);
2390
2613d1533f1a iOS: Fix initial window display and handle resize/rotation events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2389
diff changeset
10315 _dw_init_colors();
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10316 DWDefaultFont = nil;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10317 if (@available(iOS 10.0, *))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10318 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10319 if([[NSBundle mainBundle] bundleIdentifier] != nil)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10320 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10321 UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10322 if(center)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10323 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10324 [center requestAuthorizationWithOptions:UNAuthorizationOptionAlert|UNAuthorizationOptionSound
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10325 completionHandler:^(BOOL granted, NSError * _Nullable error) {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10326 if (granted)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10327 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10328 center.delegate = [[DWUserNotificationCenterDelegate alloc] init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10329 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10330 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10331 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10332 NSLog(@"WARNING: Unable to get notification permission. %@", error.localizedDescription);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10333 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10334 }];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10335 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10336 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10337 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10338 _DWDirtyDrawables = [[NSMutableArray alloc] init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10339 /* Use NSThread to start a dummy thread to initialize the threading subsystem */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10340 NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10341 [thread start];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10342 [thread release];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10343 if(!_dw_app_id[0])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10344 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10345 /* Generate an Application ID based on the PID if all else fails. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10346 snprintf(_dw_app_id, _DW_APP_ID_SIZE, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid());
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10347 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10348 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10349 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10350
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10351 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10352 * Allocates a shared memory region with a name.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10353 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10354 * handle: A pointer to receive a SHM identifier.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10355 * dest: A pointer to a pointer to receive the memory address.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10356 * size: Size in bytes of the shared memory region to allocate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10357 * name: A string pointer to a unique memory name.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10358 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10359 HSHM dw_named_memory_new(void **dest, int size, const char *name)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10360 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10361 char namebuf[1025] = {0};
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10362 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10363
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10364 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10365 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10366
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10367 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10368 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10369 free(handle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10370 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10371 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10373 ftruncate(handle->fd, size);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10374
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10375 /* attach the shared memory segment to our process's address space. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10376 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10377
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10378 if(*dest == MAP_FAILED)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10379 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10380 close(handle->fd);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10381 *dest = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10382 free(handle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10383 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10384 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10385
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10386 handle->size = size;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10387 handle->sid = getsid(0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10388 handle->path = strdup(namebuf);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10389
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10390 return handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10391 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10392
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10393 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10394 * Aquires shared memory region with a name.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10395 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10396 * dest: A pointer to a pointer to receive the memory address.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10397 * size: Size in bytes of the shared memory region to requested.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10398 * name: A string pointer to a unique memory name.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10399 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10400 HSHM dw_named_memory_get(void **dest, int size, const char *name)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10401 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10402 char namebuf[1025];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10403 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10404
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10405 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10406 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10407
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10408 if((handle->fd = open(namebuf, O_RDWR)) < 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10409 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10410 free(handle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10411 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10412 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10413
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10414 /* attach the shared memory segment to our process's address space. */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10415 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10416
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10417 if(*dest == MAP_FAILED)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10418 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10419 close(handle->fd);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10420 *dest = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10421 free(handle);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10422 return NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10423 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10424
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10425 handle->size = size;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10426 handle->sid = -1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10427 handle->path = NULL;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10428
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10429 return handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10430 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10431
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10432 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10433 * Frees a shared memory region previously allocated.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10434 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10435 * handle: Handle obtained from DB_named_memory_allocate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10436 * ptr: The memory address aquired with DB_named_memory_allocate.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10437 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10438 int dw_named_memory_free(HSHM handle, void *ptr)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10439 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10440 struct _dw_unix_shm *h = handle;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10441 int rc = munmap(ptr, h->size);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10442
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10443 close(h->fd);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10444 if(h->path)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10445 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10446 /* Only remove the actual file if we are the
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10447 * creator of the file.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10448 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10449 if(h->sid != -1 && h->sid == getsid(0))
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10450 remove(h->path);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10451 free(h->path);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10452 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10453 return rc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10454 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10455
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10456 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10457 * Creates a new thread with a starting point of func.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10458 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10459 * func: Function which will be run in the new thread.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10460 * data: Parameter(s) passed to the function.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10461 * stack: Stack size of new thread (OS/2 and Windows only).
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10462 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10463 DWTID dw_thread_new(void *func, void *data, int stack)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10464 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10465 DWTID thread;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10466 void **tmp = malloc(sizeof(void *) * 2);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10467 int rc;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10468
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10469 tmp[0] = func;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10470 tmp[1] = data;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10471
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10472 rc = pthread_create(&thread, NULL, (void *)_dwthreadstart, (void *)tmp);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10473 if(rc == 0)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10474 return thread;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10475 return (DWTID)-1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10476 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10477
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10478 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10479 * Ends execution of current thread immediately.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10480 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10481 void dw_thread_end(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10482 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10483 pthread_exit(NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10484 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10485
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10486 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10487 * Returns the current thread's ID.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10488 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10489 DWTID dw_thread_id(void)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10490 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10491 return (DWTID)pthread_self();
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10492 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10493
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10494 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10495 * Execute and external program in a seperate session.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10496 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10497 * program: Program name with optional path.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10498 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10499 * params: An array of pointers to string arguements.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10500 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10501 * DW_ERROR_UNKNOWN (-1) on error.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10502 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10503 int dw_exec(const char *program, int type, char **params)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10504 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10505 int ret = DW_ERROR_UNKNOWN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10506
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
10507 #if 0 /* TODO: Figure out how to do this on iOS */
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10508 if(type == DW_EXEC_GUI)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10509 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10510 NSString *nsprogram = [NSString stringWithUTF8String:program];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10511 NSWorkspace *ws = [NSWorkspace sharedWorkspace];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10512
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10513 if(params && params[0] && params[1])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10514 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10515 NSURL *url = _dw_url_from_program(nsprogram, ws);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10516 NSMutableArray *array = [[NSMutableArray alloc] init];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10517 __block DWDialog *dialog = dw_dialog_new(NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10518 int z = 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10519
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10520 while(params[z])
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10521 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10522 NSString *thisfile = [NSString stringWithUTF8String:params[z]];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10523 NSURL *nsfile = [NSURL fileURLWithPath:thisfile];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10524
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10525 [array addObject:nsfile];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10526 z++;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10527 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10528
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10529 [ws openURLs:array withApplicationAtURL:url
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10530 configuration:[NSWorkspaceOpenConfiguration configuration]
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10531 completionHandler:^(NSRunningApplication *app, NSError *error) {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10532 int pid = DW_ERROR_UNKNOWN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10533
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10534 if(error)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10535 NSLog(@"openURLs: %@", [error localizedDescription]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10536 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10537 pid = [app processIdentifier];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10538 dw_dialog_dismiss(dialog, DW_INT_TO_POINTER(pid));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10539 }];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10540 ret = DW_POINTER_TO_INT(dw_dialog_wait(dialog));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10541 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10542 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10543 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10544 NSURL *url = _dw_url_from_program(nsprogram, ws);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10545 __block DWDialog *dialog = dw_dialog_new(NULL);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10546
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10547 [ws openApplicationAtURL:url
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10548 configuration:[NSWorkspaceOpenConfiguration configuration]
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10549 completionHandler:^(NSRunningApplication *app, NSError *error) {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10550 int pid = DW_ERROR_UNKNOWN;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10551
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10552 if(error)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10553 NSLog(@"openApplicationAtURL: %@", [error localizedDescription]);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10554 else
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10555 pid = [app processIdentifier];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10556 dw_dialog_dismiss(dialog, DW_INT_TO_POINTER(pid));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10557 }];
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10558 ret = DW_POINTER_TO_INT(dw_dialog_wait(dialog));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10559 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10560 }
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
10561 #endif
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10562 return ret;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10563 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10564
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10565 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10566 * Loads a web browser pointed at the given URL.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10567 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10568 * url: Uniform resource locator.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10569 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10570 int dw_browse(const char *url)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10571 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10572 NSURL *myurl = [NSURL URLWithString:[NSString stringWithUTF8String:url]];
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
10573 [DWApp openURL:myurl options:@{}
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
10574 completionHandler:^(BOOL success) {}];
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10575 return DW_ERROR_NONE;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10576 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10577
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10578 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10579 * Creates a new print object.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10580 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10581 * jobname: Name of the print job to show in the queue.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10582 * flags: Flags to initially configure the print object.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10583 * pages: Number of pages to print.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10584 * drawfunc: The pointer to the function to be used as the callback.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10585 * drawdata: User data to be passed to the handler function.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10586 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10587 * A handle to the print object or NULL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10588 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10589 HPRINT API dw_print_new(const char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10590 {
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
10591 return NULL;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10592 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10593
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10594 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10595 * Runs the print job, causing the draw page callbacks to fire.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10596 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10597 * print: Handle to the print object returned by dw_print_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10598 * flags: Flags to run the print job.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10599 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10600 * DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10601 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10602 int API dw_print_run(HPRINT print, unsigned long flags)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10603 {
2380
93424ad710de iOS: Remove printing and file browsing... more conversion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2379
diff changeset
10604 return DW_ERROR_UNKNOWN;
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10605 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10606
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10607 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10608 * Cancels the print job, typically called from a draw page callback.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10609 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10610 * print: Handle to the print object returned by dw_print_new().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10611 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10612 void API dw_print_cancel(HPRINT print)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10613 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10614 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10615
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10616 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10617 * Converts a UTF-8 encoded string into a wide string.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10618 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10619 * utf8string: UTF-8 encoded source string.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10620 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10621 * Wide string that needs to be freed with dw_free()
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10622 * or NULL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10623 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10624 wchar_t * API dw_utf8_to_wchar(const char *utf8string)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10625 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10626 size_t buflen = strlen(utf8string) + 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10627 wchar_t *temp = malloc(buflen * sizeof(wchar_t));
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10628 if(temp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10629 mbstowcs(temp, utf8string, buflen);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10630 return temp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10631 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10632
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10633 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10634 * Converts a wide string into a UTF-8 encoded string.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10635 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10636 * wstring: Wide source string.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10637 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10638 * UTF-8 encoded string that needs to be freed with dw_free()
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10639 * or NULL on failure.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10640 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10641 char * API dw_wchar_to_utf8(const wchar_t *wstring)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10642 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10643 size_t bufflen = 8 * wcslen(wstring) + 1;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10644 char *temp = malloc(bufflen);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10645 if(temp)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10646 wcstombs(temp, wstring, bufflen);
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10647 return temp;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10648 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10649
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10650 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10651 * Gets the state of the requested library feature.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10652 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10653 * feature: The requested feature for example DW_FEATURE_DARK_MODE
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10654 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10655 * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10656 * DW_FEATURE_DISABLED if the feature is supported but disabled.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10657 * DW_FEATURE_ENABLED if the feature is supported and enabled.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10658 * Other value greater than 1, same as enabled but with extra info.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10659 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10660 int API dw_feature_get(DWFEATURE feature)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10661 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10662 switch(feature)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10663 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10664 case DW_FEATURE_NOTIFICATION:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10665 case DW_FEATURE_MLE_AUTO_COMPLETE:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10666 case DW_FEATURE_HTML:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10667 case DW_FEATURE_HTML_RESULT:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10668 case DW_FEATURE_CONTAINER_STRIPE:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10669 case DW_FEATURE_MLE_WORD_WRAP:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10670 case DW_FEATURE_UTF8_UNICODE:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10671 return DW_FEATURE_ENABLED;
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10672 case DW_FEATURE_DARK_MODE:
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10673 {
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10674 if(DWObj)
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10675 {
2458
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10676 NSMutableArray *array = [[NSMutableArray alloc] init];
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10677 int retval = DW_FEATURE_UNSUPPORTED;
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10678 NSNumber *number;
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10679
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10680 [DWObj safeCall:@selector(getUserInterfaceStyle:) withObject:array];
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10681 number = [array lastObject];
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10682 if(number)
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10683 retval = [number intValue];
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10684 return retval;
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10685 }
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10686 return _dw_dark_mode_state;
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10687 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10688 default:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10689 return DW_FEATURE_UNSUPPORTED;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10690 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10691 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10692
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10693 /*
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10694 * Sets the state of the requested library feature.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10695 * Parameters:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10696 * feature: The requested feature for example DW_FEATURE_DARK_MODE
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10697 * state: DW_FEATURE_DISABLED, DW_FEATURE_ENABLED or any value greater than 1.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10698 * Returns:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10699 * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10700 * DW_ERROR_NONE if the feature is supported and successfully configured.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10701 * DW_ERROR_GENERAL if the feature is supported but could not be configured.
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10702 * Remarks:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10703 * These settings are typically used during dw_init() so issue before
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10704 * setting up the library with dw_init().
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10705 */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10706 int API dw_feature_set(DWFEATURE feature, int state)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10707 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10708 switch(feature)
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10709 {
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10710 /* These features are supported but not configurable */
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10711 case DW_FEATURE_NOTIFICATION:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10712 case DW_FEATURE_MLE_AUTO_COMPLETE:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10713 case DW_FEATURE_HTML:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10714 case DW_FEATURE_HTML_RESULT:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10715 case DW_FEATURE_CONTAINER_STRIPE:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10716 case DW_FEATURE_MLE_WORD_WRAP:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10717 case DW_FEATURE_UTF8_UNICODE:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10718 return DW_ERROR_GENERAL;
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10719 case DW_FEATURE_DARK_MODE:
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10720 {
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10721 /* Make sure DWObj is initialized */
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10722 if(DWObj)
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10723 {
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10724 /* Disabled forces the non-dark aqua theme */
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10725 if(state == DW_FEATURE_DISABLED)
2458
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10726 [DWObj safeCall:@selector(setUserInterfaceStyle:) withObject:[NSNumber numberWithInt:UIUserInterfaceStyleLight]];
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10727 /* Enabled lets the OS decide the mode */
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10728 else if(state == DW_FEATURE_ENABLED || state == DW_DARK_MODE_FULL)
2458
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10729 [DWObj safeCall:@selector(setUserInterfaceStyle:) withObject:[NSNumber numberWithInt:UIUserInterfaceStyleUnspecified]];
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10730 /* 2 forces dark mode aqua appearance */
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10731 else if(state == DW_DARK_MODE_FORCED)
2458
689261c29745 iOS: DWContainer should generate selection event on deselect too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2457
diff changeset
10732 [DWObj safeCall:@selector(setUserInterfaceStyle:) withObject:[NSNumber numberWithInt:UIUserInterfaceStyleDark]];
2456
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10733 }
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10734 else /* Save the requested state for dw_init() */
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10735 _dw_dark_mode_state = state;
54f760a257f3 iOS: initial support for iOS Dark Mode... untested. Part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2450
diff changeset
10736 }
2372
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10737 default:
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10738 return DW_FEATURE_UNSUPPORTED;
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10739 }
df0a66945296 iOS: Initial commit of iOS source... based on MacOS code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10740 }