comparison mac/dw.m @ 1955:91541efcea10

Mac: Complete refactoring of the Mac code using a handful of macros. This allows using the old mutex system for thread safety pre-mojave. On Mojave and later instead we create two functions, an entrypoint and an actual code function which will get called on the main thread. This avoids Apples new artifical checks that the code is running on the main thread, since it actually is running on the main thread even though the actual caller might not be.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 24 Jul 2019 17:22:19 +0000
parents 85229fe9ae5a
children 2924bc788170
comparison
equal deleted inserted replaced
1954:85229fe9ae5a 1955:91541efcea10
26 26
27 /* Create a define to let us know to include Snow Leopard specific features */ 27 /* Create a define to let us know to include Snow Leopard specific features */
28 #if defined(MAC_OS_X_VERSION_10_7) && ((defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED)) 28 #if defined(MAC_OS_X_VERSION_10_7) && ((defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED))
29 #define BUILDING_FOR_LION 29 #define BUILDING_FOR_LION
30 #endif 30 #endif
31
32 /* Macros to protect access to thread unsafe classes */
33 #define DW_MUTEX_LOCK { \
34 if(DWThread != (DWTID)-1 && pthread_self() != DWThread && pthread_self() != _dw_mutex_locked) { \
35 dw_mutex_lock(DWThreadMutex); \
36 _dw_mutex_locked = pthread_self(); \
37 dw_mutex_lock(DWThreadMutex2); \
38 [DWObj performSelectorOnMainThread:@selector(synchronizeThread:) withObject:nil waitUntilDone:NO]; \
39 dw_mutex_lock(DWRunMutex); \
40 _locked_by_me = TRUE; } }
41 #define DW_MUTEX_UNLOCK { \
42 if(pthread_self() != DWThread && _locked_by_me == TRUE) { \
43 dw_mutex_unlock(DWRunMutex); \
44 dw_mutex_unlock(DWThreadMutex2); \
45 _dw_mutex_locked = (pthread_t)-1; \
46 dw_mutex_unlock(DWThreadMutex); \
47 _locked_by_me = FALSE; } }
48 31
49 /* Macros to handle local auto-release pools */ 32 /* Macros to handle local auto-release pools */
50 #define DW_LOCAL_POOL_IN NSAutoreleasePool *localpool = nil; \ 33 #define DW_LOCAL_POOL_IN NSAutoreleasePool *localpool = nil; \
51 if(DWThread != (DWTID)-1 && pthread_self() != DWThread) \ 34 if(DWThread != (DWTID)-1 && pthread_self() != DWThread) \
52 localpool = [[NSAutoreleasePool alloc] init]; 35 localpool = [[NSAutoreleasePool alloc] init];
154 #define BUILDING_FOR_MOJAVE 137 #define BUILDING_FOR_MOJAVE
155 #else 138 #else
156 #define DWProgressIndicatorStyleBar NSProgressIndicatorBarStyle 139 #define DWProgressIndicatorStyleBar NSProgressIndicatorBarStyle
157 #endif 140 #endif
158 141
142 /* Macros to encapsulate running functions on the main thread
143 * on Mojave or later... and locking mutexes on earlier versions.
144 */
145 #ifdef BUILDING_FOR_MOJAVE
146 #define DW_FUNCTION_INIT
147 #define DW_FUNCTION_DEFINITION(func, rettype, ...) void _##func(NSPointerArray *_args); \
148 rettype API func(__VA_ARGS__) { \
149 DW_LOCAL_POOL_IN; \
150 NSPointerArray *_args = [[NSPointerArray alloc] initWithOptions:NSPointerFunctionsOpaqueMemory]; \
151 [_args retain]; \
152 [_args addPointer:(void *)_##func];
153 #define DW_FUNCTION_ADD_PARAM1(param1) [_args addPointer:(void *)&param1];
154 #define DW_FUNCTION_ADD_PARAM2(param1, param2) [_args addPointer:(void *)&param1]; \
155 [_args addPointer:(void *)&param2];
156 #define DW_FUNCTION_ADD_PARAM3(param1, param2, param3) [_args addPointer:(void *)&param1]; \
157 [_args addPointer:(void *)&param2]; \
158 [_args addPointer:(void *)&param3];
159 #define DW_FUNCTION_ADD_PARAM4(param1, param2, param3, param4) [_args addPointer:(void *)&param1]; \
160 [_args addPointer:(void *)&param2]; \
161 [_args addPointer:(void *)&param3]; \
162 [_args addPointer:(void *)&param4];
163 #define DW_FUNCTION_ADD_PARAM5(param1, param2, param3, param4, param5) [_args addPointer:(void *)&param1]; \
164 [_args addPointer:(void *)&param2]; \
165 [_args addPointer:(void *)&param3]; \
166 [_args addPointer:(void *)&param4]; \
167 [_args addPointer:(void *)&param5];
168 #define DW_FUNCTION_ADD_PARAM6(param1, param2, param3, param4, param5, param6) \
169 [_args addPointer:(void *)&param1]; \
170 [_args addPointer:(void *)&param2]; \
171 [_args addPointer:(void *)&param3]; \
172 [_args addPointer:(void *)&param4]; \
173 [_args addPointer:(void *)&param5]; \
174 [_args addPointer:(void *)&param6];
175 #define DW_FUNCTION_ADD_PARAM7(param1, param2, param3, param4, param5, param6, param7) \
176 [_args addPointer:(void *)&param1]; \
177 [_args addPointer:(void *)&param2]; \
178 [_args addPointer:(void *)&param3]; \
179 [_args addPointer:(void *)&param4]; \
180 [_args addPointer:(void *)&param5]; \
181 [_args addPointer:(void *)&param6]; \
182 [_args addPointer:(void *)&param7];
183 #define DW_FUNCTION_ADD_PARAM8(param1, param2, param3, param4, param5, param6, param7, param8) \
184 [_args addPointer:(void *)&param1]; \
185 [_args addPointer:(void *)&param2]; \
186 [_args addPointer:(void *)&param3]; \
187 [_args addPointer:(void *)&param4]; \
188 [_args addPointer:(void *)&param5]; \
189 [_args addPointer:(void *)&param6]; \
190 [_args addPointer:(void *)&param7]; \
191 [_args addPointer:(void *)&param8];
192 #define DW_FUNCTION_ADD_PARAM9(param1, param2, param3, param4, param5, param6, param7, param8, param9) \
193 [_args addPointer:(void *)&param1]; \
194 [_args addPointer:(void *)&param2]; \
195 [_args addPointer:(void *)&param3]; \
196 [_args addPointer:(void *)&param4]; \
197 [_args addPointer:(void *)&param5]; \
198 [_args addPointer:(void *)&param6]; \
199 [_args addPointer:(void *)&param7]; \
200 [_args addPointer:(void *)&param8]; \
201 [_args addPointer:(void *)&param9];
202 #define DW_FUNCTION_RESTORE_PARAM1(param1, vartype1) vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]);
203 #define DW_FUNCTION_RESTORE_PARAM2(param1, vartype1, param2, vartype2) \
204 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
205 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]);
206 #define DW_FUNCTION_RESTORE_PARAM3(param1, vartype1, param2, vartype2, param3, vartype3) \
207 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
208 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
209 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]);
210 #define DW_FUNCTION_RESTORE_PARAM4(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4) \
211 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
212 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
213 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
214 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]);
215 #define DW_FUNCTION_RESTORE_PARAM5(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5) \
216 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
217 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
218 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
219 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
220 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]);
221 #define DW_FUNCTION_RESTORE_PARAM6(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6) \
222 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
223 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
224 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
225 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
226 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]); \
227 vartype6 param6 = *((vartype6 *)[_args pointerAtIndex:6]);
228 #define DW_FUNCTION_RESTORE_PARAM7(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7) \
229 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
230 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
231 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
232 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
233 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]); \
234 vartype6 param6 = *((vartype6 *)[_args pointerAtIndex:6]); \
235 vartype7 param7 = *((vartype7 *)[_args pointerAtIndex:7]);
236 #define DW_FUNCTION_RESTORE_PARAM8(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8) \
237 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
238 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
239 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
240 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
241 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]); \
242 vartype6 param6 = *((vartype6 *)[_args pointerAtIndex:6]); \
243 vartype7 param7 = *((vartype7 *)[_args pointerAtIndex:7]); \
244 vartype8 param8 = *((vartype8 *)[_args pointerAtIndex:8]);
245 #define DW_FUNCTION_RESTORE_PARAM9(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9) \
246 vartype1 param1 = *((vartype1 *)[_args pointerAtIndex:1]); \
247 vartype2 param2 = *((vartype2 *)[_args pointerAtIndex:2]); \
248 vartype3 param3 = *((vartype3 *)[_args pointerAtIndex:3]); \
249 vartype4 param4 = *((vartype4 *)[_args pointerAtIndex:4]); \
250 vartype5 param5 = *((vartype5 *)[_args pointerAtIndex:5]); \
251 vartype6 param6 = *((vartype6 *)[_args pointerAtIndex:6]); \
252 vartype7 param7 = *((vartype7 *)[_args pointerAtIndex:7]); \
253 vartype8 param8 = *((vartype8 *)[_args pointerAtIndex:8]); \
254 vartype9 param9 = *((vartype9 *)[_args pointerAtIndex:9]);
255 #define DW_FUNCTION_END }
256 #define DW_FUNCTION_NO_RETURN(func) [DWObj safeCall:@selector(callBack:) withObject:_args]; \
257 [_args release]; \
258 DW_LOCAL_POOL_OUT; } \
259 void _##func(NSPointerArray *_args) {
260 #define DW_FUNCTION_RETURN(func, rettype) [DWObj safeCall:@selector(callBack:) withObject:_args]; {\
261 void *tmp = [_args pointerAtIndex:[_args count]-1]; \
262 rettype myreturn = *((rettype *)tmp); \
263 free(tmp); \
264 return myreturn; } \
265 [_args release]; \
266 DW_LOCAL_POOL_OUT; } \
267 void _##func(NSPointerArray *_args) {
268 #define DW_FUNCTION_RETURN_THIS(_retvar) { void *_myreturn = malloc(sizeof(_retvar)); \
269 memcpy(_myreturn, (void *)&_retvar, sizeof(_retvar)); \
270 [_args addPointer:_myreturn]; }}
271 #define DW_FUNCTION_RETURN_NOTHING }
272 #else
273 /* Macros to protect access to thread unsafe classes */
274 #define DW_FUNCTION_INIT int _locked_by_me = FALSE; { \
275 if(DWThread != (DWTID)-1 && pthread_self() != DWThread && pthread_self() != _dw_mutex_locked) { \
276 dw_mutex_lock(DWThreadMutex); \
277 _dw_mutex_locked = pthread_self(); \
278 dw_mutex_lock(DWThreadMutex2); \
279 [DWObj performSelectorOnMainThread:@selector(synchronizeThread:) withObject:nil waitUntilDone:NO]; \
280 dw_mutex_lock(DWRunMutex); \
281 _locked_by_me = TRUE; } }
282 #define DW_FUNCTION_DEFINITION(func, rettype, ...) rettype API func(__VA_ARGS__)
283 #define DW_FUNCTION_ADD_PARAM1(param1)
284 #define DW_FUNCTION_ADD_PARAM2(param1, param2)
285 #define DW_FUNCTION_ADD_PARAM3(param1, param2, param3)
286 #define DW_FUNCTION_ADD_PARAM4(param1, param2, param3, param4)
287 #define DW_FUNCTION_ADD_PARAM5(param1, param2, param3, param4, param5)
288 #define DW_FUNCTION_ADD_PARAM6(param1, param2, param3, param4, param5, param6)
289 #define DW_FUNCTION_ADD_PARAM7(param1, param2, param3, param4, param5, param6, param7)
290 #define DW_FUNCTION_ADD_PARAM8(param1, param2, param3, param4, param5, param6, param7, param8)
291 #define DW_FUNCTION_ADD_PARAM9(param1, param2, param3, param4, param5, param6, param7, param8, param9)
292 #define DW_FUNCTION_RESTORE_PARAM1(param1, vartype1)
293 #define DW_FUNCTION_RESTORE_PARAM2(param1, vartype1, param2, vartype2)
294 #define DW_FUNCTION_RESTORE_PARAM3(param1, vartype1, param2, vartype2, param3, vartype3)
295 #define DW_FUNCTION_RESTORE_PARAM4(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4)
296 #define DW_FUNCTION_RESTORE_PARAM5(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5)
297 #define DW_FUNCTION_RESTORE_PARAM6(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6)
298 #define DW_FUNCTION_RESTORE_PARAM7(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7)
299 #define DW_FUNCTION_RESTORE_PARAM8(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8)
300 #define DW_FUNCTION_RESTORE_PARAM9(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9)
301 #define DW_FUNCTION_END
302 #define DW_FUNCTION_NO_RETURN(func)
303 #define DW_FUNCTION_RETURN(func, rettype)
304 #define DW_FUNCTION_RETURN_THIS(retvar) { \
305 if(pthread_self() != DWThread && _locked_by_me == TRUE) { \
306 dw_mutex_unlock(DWRunMutex); \
307 dw_mutex_unlock(DWThreadMutex2); \
308 _dw_mutex_locked = (pthread_t)-1; \
309 dw_mutex_unlock(DWThreadMutex); \
310 _locked_by_me = FALSE; } } \
311 return retvar;
312 #define DW_FUNCTION_RETURN_NOTHING { \
313 if(pthread_self() != DWThread && _locked_by_me == TRUE) { \
314 dw_mutex_unlock(DWRunMutex); \
315 dw_mutex_unlock(DWThreadMutex2); \
316 _dw_mutex_locked = (pthread_t)-1; \
317 dw_mutex_unlock(DWThreadMutex); \
318 _locked_by_me = FALSE; } }
319 HMTX DWRunMutex;
320 HMTX DWThreadMutex;
321 HMTX DWThreadMutex2;
322 DWTID _dw_mutex_locked = (DWTID)-1;
323 #endif
324
159 /* Apparently the WKWebKit API is only enabled on intel 64bit... 325 /* Apparently the WKWebKit API is only enabled on intel 64bit...
160 * Causing build failures on 32bit builds, so this should allow 326 * Causing build failures on 32bit builds, so this should allow
161 * WKWebKit on intel 64 and the old WebKit on intel 32 bit and earlier. 327 * WKWebKit on intel 64 and the old WebKit on intel 32 bit and earlier.
162 */ 328 */
163 #if WK_API_ENABLED 329 #if WK_API_ENABLED
618 #ifdef BUILDING_FOR_MOJAVE 784 #ifdef BUILDING_FOR_MOJAVE
619 NSMutableArray *_DWDirtyDrawables; 785 NSMutableArray *_DWDirtyDrawables;
620 #else 786 #else
621 HWND _DWLastDrawable; 787 HWND _DWLastDrawable;
622 #endif 788 #endif
623 HMTX DWRunMutex;
624 HMTX DWThreadMutex;
625 HMTX DWThreadMutex2;
626 DWTID DWThread = (DWTID)-1; 789 DWTID DWThread = (DWTID)-1;
627 DWTID _dw_mutex_locked = (DWTID)-1;
628 790
629 /* Send fake event to make sure the loop isn't stuck */ 791 /* Send fake event to make sure the loop isn't stuck */
630 void _dw_wakeup_app() 792 void _dw_wakeup_app()
631 { 793 {
632 [DWApp postEvent:[NSEvent otherEventWithType:DWEventTypeApplicationDefined 794 [DWApp postEvent:[NSEvent otherEventWithType:DWEventTypeApplicationDefined
657 } DWBitBlt; 819 } DWBitBlt;
658 820
659 /* Subclass for a test object type */ 821 /* Subclass for a test object type */
660 @interface DWObject : NSObject {} 822 @interface DWObject : NSObject {}
661 -(void)uselessThread:(id)sender; 823 -(void)uselessThread:(id)sender;
824 #ifndef BUILDING_FOR_MOJAVE
662 -(void)synchronizeThread:(id)param; 825 -(void)synchronizeThread:(id)param;
826 #endif
663 -(void)menuHandler:(id)param; 827 -(void)menuHandler:(id)param;
664 -(void)doBitBlt:(id)param; 828 -(void)doBitBlt:(id)param;
665 -(void)doFlush:(id)param; 829 -(void)doFlush:(id)param;
666 @end 830 @end
667 831
937 -(BOOL)acceptsFirstResponder { return YES; } 1101 -(BOOL)acceptsFirstResponder { return YES; }
938 @end 1102 @end
939 1103
940 @implementation DWObject 1104 @implementation DWObject
941 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ } 1105 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ }
1106 #ifndef BUILDING_FOR_MOJAVE
942 -(void)synchronizeThread:(id)param 1107 -(void)synchronizeThread:(id)param
943 { 1108 {
944 pthread_mutex_unlock(DWRunMutex); 1109 pthread_mutex_unlock(DWRunMutex);
945 pthread_mutex_lock(DWThreadMutex2); 1110 pthread_mutex_lock(DWThreadMutex2);
946 pthread_mutex_unlock(DWThreadMutex2); 1111 pthread_mutex_unlock(DWThreadMutex2);
947 pthread_mutex_lock(DWRunMutex); 1112 pthread_mutex_lock(DWRunMutex);
948 } 1113 }
1114 #endif
949 -(void)menuHandler:(id)param 1115 -(void)menuHandler:(id)param
950 { 1116 {
951 DWMenuItem *item = param; 1117 DWMenuItem *item = param;
952 if([item check]) 1118 if([item check])
953 { 1119 {
956 else 1122 else
957 [item setState:DWControlStateValueOn]; 1123 [item setState:DWControlStateValueOn];
958 } 1124 }
959 _event_handler(param, nil, 8); 1125 _event_handler(param, nil, 8);
960 } 1126 }
1127 #ifdef BUILDING_FOR_MOJAVE
1128 -(void)callBack:(NSPointerArray *)params
1129 {
1130 void (*mycallback)(NSPointerArray *) = [params pointerAtIndex:0];
1131 if(mycallback)
1132 mycallback(params);
1133 }
1134 #endif
961 -(void)safeCall:(SEL)sel withObject:(id)param 1135 -(void)safeCall:(SEL)sel withObject:(id)param
962 { 1136 {
963 if([self respondsToSelector:sel]) 1137 if([self respondsToSelector:sel])
964 { 1138 {
965 DWTID curr = pthread_self(); 1139 DWTID curr = pthread_self();
3416 /* 3590 /*
3417 * Runs a message loop for Dynamic Windows. 3591 * Runs a message loop for Dynamic Windows.
3418 */ 3592 */
3419 void API dw_main(void) 3593 void API dw_main(void)
3420 { 3594 {
3595 #ifndef BUILDING_FOR_MOJAVE
3421 dw_mutex_lock(DWRunMutex); 3596 dw_mutex_lock(DWRunMutex);
3597 #endif
3422 DWThread = dw_thread_id(); 3598 DWThread = dw_thread_id();
3423 /* Make sure any queued redraws are handled */ 3599 /* Make sure any queued redraws are handled */
3424 _dw_redraw(0, FALSE); 3600 _dw_redraw(0, FALSE);
3425 [DWApp run]; 3601 [DWApp run];
3426 DWThread = (DWTID)-1; 3602 DWThread = (DWTID)-1;
3603 #ifndef BUILDING_FOR_MOJAVE
3427 dw_mutex_unlock(DWRunMutex); 3604 dw_mutex_unlock(DWRunMutex);
3605 #endif
3428 } 3606 }
3429 3607
3430 /* 3608 /*
3431 * Causes running dw_main() to return. 3609 * Causes running dw_main() to return.
3432 */ 3610 */
3450 DWTID orig = DWThread; 3628 DWTID orig = DWThread;
3451 NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)]; 3629 NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)];
3452 3630
3453 if(orig == (DWTID)-1) 3631 if(orig == (DWTID)-1)
3454 { 3632 {
3633 #ifndef BUILDING_FOR_MOJAVE
3455 dw_mutex_lock(DWRunMutex); 3634 dw_mutex_lock(DWRunMutex);
3635 #endif
3456 DWThread = curr; 3636 DWThread = curr;
3457 } 3637 }
3458 /* Process any pending events */ 3638 /* Process any pending events */
3459 while(_dw_main_iteration(until)) 3639 while(_dw_main_iteration(until))
3460 { 3640 {
3461 /* Just loop */ 3641 /* Just loop */
3462 } 3642 }
3463 if(orig == (DWTID)-1) 3643 if(orig == (DWTID)-1)
3464 { 3644 {
3465 DWThread = orig; 3645 DWThread = orig;
3646 #ifndef BUILDING_FOR_MOJAVE
3466 dw_mutex_unlock(DWRunMutex); 3647 dw_mutex_unlock(DWRunMutex);
3648 #endif
3467 } 3649 }
3468 } 3650 }
3469 else 3651 else
3470 { 3652 {
3471 usleep(milliseconds * 1000); 3653 usleep(milliseconds * 1000);
3495 { 3677 {
3496 DWTID curr = pthread_self(); 3678 DWTID curr = pthread_self();
3497 3679
3498 if(DWThread == (DWTID)-1) 3680 if(DWThread == (DWTID)-1)
3499 { 3681 {
3682 #ifndef BUILDING_FOR_MOJAVE
3500 dw_mutex_lock(DWRunMutex); 3683 dw_mutex_lock(DWRunMutex);
3684 #endif
3501 DWThread = curr; 3685 DWThread = curr;
3502 _dw_main_iteration([NSDate distantPast]); 3686 _dw_main_iteration([NSDate distantPast]);
3503 DWThread = (DWTID)-1; 3687 DWThread = (DWTID)-1;
3688 #ifndef BUILDING_FOR_MOJAVE
3504 dw_mutex_unlock(DWRunMutex); 3689 dw_mutex_unlock(DWRunMutex);
3690 #endif
3505 } 3691 }
3506 else if(DWThread == curr) 3692 else if(DWThread == curr)
3507 { 3693 {
3508 _dw_main_iteration([NSDate distantPast]); 3694 _dw_main_iteration([NSDate distantPast]);
3509 } 3695 }
3946 * Create a new Box to be packed. 4132 * Create a new Box to be packed.
3947 * Parameters: 4133 * Parameters:
3948 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 4134 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3949 * pad: Number of pixels to pad around the box. 4135 * pad: Number of pixels to pad around the box.
3950 */ 4136 */
3951 HWND API dw_box_new(int type, int pad) 4137 DW_FUNCTION_DEFINITION(dw_box_new, HWND, int type, int pad)
3952 { 4138 DW_FUNCTION_ADD_PARAM2(type, pad)
3953 int _locked_by_me = FALSE; 4139 DW_FUNCTION_RETURN(dw_box_new, HWND)
3954 DW_MUTEX_LOCK; 4140 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int)
4141 {
4142 DW_FUNCTION_INIT;
3955 DWBox *view = [[DWBox alloc] init]; 4143 DWBox *view = [[DWBox alloc] init];
3956 Box *newbox = [view box]; 4144 Box *newbox = [view box];
3957 memset(newbox, 0, sizeof(Box)); 4145 memset(newbox, 0, sizeof(Box));
3958 newbox->pad = pad; 4146 newbox->pad = pad;
3959 newbox->type = type; 4147 newbox->type = type;
3960 DW_MUTEX_UNLOCK; 4148 DW_FUNCTION_RETURN_THIS(view);
3961 return view;
3962 } 4149 }
3963 4150
3964 /* 4151 /*
3965 * Create a new Group Box to be packed. 4152 * Create a new Group Box to be packed.
3966 * Parameters: 4153 * Parameters:
4318 } 4505 }
4319 4506
4320 /* Internal box packing function called by the other 3 functions */ 4507 /* Internal box packing function called by the other 3 functions */
4321 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname) 4508 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname)
4322 { 4509 {
4323 int _locked_by_me = FALSE; 4510 //int _locked_by_me = FALSE;
4324 DW_MUTEX_LOCK; 4511 //DW_MUTEX_LOCK;
4325 id object = box; 4512 id object = box;
4326 DWBox *view = box; 4513 DWBox *view = box;
4327 DWBox *this = item; 4514 DWBox *this = item;
4328 Box *thisbox; 4515 Box *thisbox;
4329 int z, x = 0; 4516 int z, x = 0;
4437 _dw_redraw([view window], TRUE); 4624 _dw_redraw([view window], TRUE);
4438 4625
4439 /* Free the old data */ 4626 /* Free the old data */
4440 if(thisitem) 4627 if(thisitem)
4441 free(thisitem); 4628 free(thisitem);
4442 DW_MUTEX_UNLOCK; 4629 //DW_MUTEX_UNLOCK;
4443 } 4630 }
4444 4631
4445 /* 4632 /*
4446 * Remove windows (widgets) from the box they are packed into. 4633 * Remove windows (widgets) from the box they are packed into.
4447 * Parameters: 4634 * Parameters:
4448 * handle: Window handle of the packed item to be removed. 4635 * handle: Window handle of the packed item to be removed.
4449 * Returns: 4636 * Returns:
4450 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. 4637 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
4451 */ 4638 */
4452 int API dw_box_unpack(HWND handle) 4639 DW_FUNCTION_DEFINITION(dw_box_unpack, int, HWND handle)
4453 { 4640 DW_FUNCTION_ADD_PARAM1(handle)
4454 int _locked_by_me = FALSE; 4641 DW_FUNCTION_RETURN(dw_box_unpack, int)
4642 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
4643 {
4644 DW_FUNCTION_INIT;
4455 DW_LOCAL_POOL_IN; 4645 DW_LOCAL_POOL_IN;
4456 DW_MUTEX_LOCK;
4457 id object = handle; 4646 id object = handle;
4647 int retval = DW_ERROR_NONE;
4458 4648
4459 if([object isKindOfClass:[NSView class]] || [object isKindOfClass:[NSControl class]]) 4649 if([object isKindOfClass:[NSView class]] || [object isKindOfClass:[NSControl class]])
4460 { 4650 {
4461 DWBox *parent = (DWBox *)[object superview]; 4651 DWBox *parent = (DWBox *)[object superview];
4462 4652
4485 if(thisitem[z].hwnd == object) 4675 if(thisitem[z].hwnd == object)
4486 index = z; 4676 index = z;
4487 } 4677 }
4488 4678
4489 if(index == -1) 4679 if(index == -1)
4680 retval = DW_ERROR_GENERAL;
4681 else
4490 { 4682 {
4491 DW_MUTEX_UNLOCK; 4683 [object retain];
4492 DW_LOCAL_POOL_OUT; 4684 [object removeFromSuperview];
4493 return DW_ERROR_GENERAL; 4685
4686 if(thisbox->count > 1)
4687 {
4688 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
4689
4690 /* Copy all but the current entry to the new list */
4691 for(z=0;z<index;z++)
4692 {
4693 tmpitem[z] = thisitem[z];
4694 }
4695 for(z=index+1;z<thisbox->count;z++)
4696 {
4697 tmpitem[z-1] = thisitem[z];
4698 }
4699 }
4700
4701 thisbox->items = tmpitem;
4702 if(thisitem)
4703 free(thisitem);
4704 if(tmpitem)
4705 thisbox->count--;
4706 else
4707 thisbox->count = 0;
4708 /* Queue a redraw on the top-level window */
4709 _dw_redraw(window, TRUE);
4494 } 4710 }
4495 4711 }
4496 [object retain]; 4712 }
4497 [object removeFromSuperview];
4498
4499 if(thisbox->count > 1)
4500 {
4501 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
4502
4503 /* Copy all but the current entry to the new list */
4504 for(z=0;z<index;z++)
4505 {
4506 tmpitem[z] = thisitem[z];
4507 }
4508 for(z=index+1;z<thisbox->count;z++)
4509 {
4510 tmpitem[z-1] = thisitem[z];
4511 }
4512 }
4513
4514 thisbox->items = tmpitem;
4515 if(thisitem)
4516 free(thisitem);
4517 if(tmpitem)
4518 thisbox->count--;
4519 else
4520 thisbox->count = 0;
4521 /* Queue a redraw on the top-level window */
4522 _dw_redraw(window, TRUE);
4523 }
4524 }
4525 DW_MUTEX_UNLOCK;
4526 DW_LOCAL_POOL_OUT; 4713 DW_LOCAL_POOL_OUT;
4527 return DW_ERROR_NONE; 4714 DW_FUNCTION_RETURN_THIS(retval);
4528 } 4715 }
4529 4716
4530 /* 4717 /*
4531 * Remove windows (widgets) from a box at an arbitrary location. 4718 * Remove windows (widgets) from a box at an arbitrary location.
4532 * Parameters: 4719 * Parameters:
4533 * box: Window handle of the box to be removed from. 4720 * box: Window handle of the box to be removed from.
4534 * index: 0 based index of packed items. 4721 * index: 0 based index of packed items.
4535 * Returns: 4722 * Returns:
4536 * Handle to the removed item on success, 0 on failure or padding. 4723 * Handle to the removed item on success, 0 on failure or padding.
4537 */ 4724 */
4538 HWND API dw_box_unpack_at_index(HWND box, int index) 4725 DW_FUNCTION_DEFINITION(dw_box_unpack_at_index, HWND, HWND box, int index)
4539 { 4726 DW_FUNCTION_ADD_PARAM2(box, index)
4540 int _locked_by_me = FALSE; 4727 DW_FUNCTION_RETURN(dw_box_unpack_at_index, HWND)
4728 DW_FUNCTION_RESTORE_PARAM2(box, HWND, index, int)
4729 {
4730 DW_FUNCTION_INIT;
4541 DW_LOCAL_POOL_IN; 4731 DW_LOCAL_POOL_IN;
4542 DW_MUTEX_LOCK;
4543 DWBox *parent = (DWBox *)box; 4732 DWBox *parent = (DWBox *)box;
4544 id object = nil; 4733 id object = nil;
4545 4734
4546 if([parent isKindOfClass:[DWBox class]] || [parent isKindOfClass:[DWGroupBox class]]) 4735 if([parent isKindOfClass:[DWBox class]] || [parent isKindOfClass:[DWGroupBox class]])
4547 { 4736 {
4586 4775
4587 /* Queue a redraw on the top-level window */ 4776 /* Queue a redraw on the top-level window */
4588 _dw_redraw(window, TRUE); 4777 _dw_redraw(window, TRUE);
4589 } 4778 }
4590 } 4779 }
4591 DW_MUTEX_UNLOCK;
4592 DW_LOCAL_POOL_OUT; 4780 DW_LOCAL_POOL_OUT;
4593 return object; 4781 DW_FUNCTION_RETURN_THIS(object);
4594 } 4782 }
4595 4783
4596 /* 4784 /*
4597 * Pack windows (widgets) into a box at an arbitrary location. 4785 * Pack windows (widgets) into a box at an arbitrary location.
4598 * Parameters: 4786 * Parameters:
5128 * Create a new listbox window (widget) to be packed. 5316 * Create a new listbox window (widget) to be packed.
5129 * Parameters: 5317 * Parameters:
5130 * id: An ID to be used with dw_window_from_id() or 0L. 5318 * id: An ID to be used with dw_window_from_id() or 0L.
5131 * multi: Multiple select TRUE or FALSE. 5319 * multi: Multiple select TRUE or FALSE.
5132 */ 5320 */
5133 HWND API dw_listbox_new(ULONG cid, int multi) 5321 DW_FUNCTION_DEFINITION(dw_listbox_new, HWND, ULONG cid, int multi)
5134 { 5322 DW_FUNCTION_ADD_PARAM2(cid, multi)
5135 int _locked_by_me = FALSE; 5323 DW_FUNCTION_RETURN(dw_listbox_new, HWND)
5136 DW_MUTEX_LOCK; 5324 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int)
5325 {
5326 DW_FUNCTION_INIT;
5137 DWContainer *cont = _cont_new(cid, multi); 5327 DWContainer *cont = _cont_new(cid, multi);
5138 [cont setHeaderView:nil]; 5328 [cont setHeaderView:nil];
5139 int type = DW_CFA_STRING; 5329 int type = DW_CFA_STRING;
5140 [cont setup]; 5330 [cont setup];
5141 NSTableColumn *column = [[[NSTableColumn alloc] init] autorelease]; 5331 NSTableColumn *column = [[[NSTableColumn alloc] init] autorelease];
5142 [column setEditable:NO]; 5332 [column setEditable:NO];
5143 [cont addTableColumn:column]; 5333 [cont addTableColumn:column];
5144 [cont addColumn:column andType:type]; 5334 [cont addColumn:column andType:type];
5145 DW_MUTEX_UNLOCK; 5335 DW_FUNCTION_RETURN_THIS(cont)
5146 return cont;
5147 } 5336 }
5148 5337
5149 /* 5338 /*
5150 * Appends the specified text to the listbox's (or combobox) entry list. 5339 * Appends the specified text to the listbox's (or combobox) entry list.
5151 * Parameters: 5340 * Parameters:
5152 * handle: Handle to the listbox to be appended to. 5341 * handle: Handle to the listbox to be appended to.
5153 * text: Text to append into listbox. 5342 * text: Text to append into listbox.
5154 */ 5343 */
5155 void API dw_listbox_append(HWND handle, char *text) 5344 DW_FUNCTION_DEFINITION(dw_listbox_append, void, HWND handle, char *text)
5156 { 5345 DW_FUNCTION_ADD_PARAM2(handle, text)
5157 int _locked_by_me = FALSE; 5346 DW_FUNCTION_NO_RETURN(dw_listbox_append)
5158 DW_MUTEX_LOCK; 5347 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
5348 {
5349 DW_FUNCTION_INIT;
5159 id object = handle; 5350 id object = handle;
5160 5351
5161 if([object isMemberOfClass:[DWComboBox class]]) 5352 if([object isMemberOfClass:[DWComboBox class]])
5162 { 5353 {
5163 DWComboBox *combo = handle; 5354 DWComboBox *combo = handle;
5175 withObject:newrow 5366 withObject:newrow
5176 waitUntilDone:YES];*/ 5367 waitUntilDone:YES];*/
5177 [cont reloadData]; 5368 [cont reloadData];
5178 [cont setNeedsDisplay:YES]; 5369 [cont setNeedsDisplay:YES];
5179 } 5370 }
5180 DW_MUTEX_UNLOCK; 5371 DW_FUNCTION_RETURN_NOTHING;
5181 } 5372 }
5182 5373
5183 /* 5374 /*
5184 * Inserts the specified text into the listbox's (or combobox) entry list. 5375 * Inserts the specified text into the listbox's (or combobox) entry list.
5185 * Parameters: 5376 * Parameters:
5186 * handle: Handle to the listbox to be inserted into. 5377 * handle: Handle to the listbox to be inserted into.
5187 * text: Text to insert into listbox. 5378 * text: Text to insert into listbox.
5188 * pos: 0-based position to insert text 5379 * pos: 0-based position to insert text
5189 */ 5380 */
5190 void API dw_listbox_insert(HWND handle, char *text, int pos) 5381 DW_FUNCTION_DEFINITION(dw_listbox_insert, void, HWND handle, char *text, int pos)
5191 { 5382 DW_FUNCTION_ADD_PARAM3(handle, text, pos)
5192 int _locked_by_me = FALSE; 5383 DW_FUNCTION_NO_RETURN(dw_listbox_insert)
5193 DW_MUTEX_LOCK; 5384 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, char *, pos, int)
5385 {
5386 DW_FUNCTION_INIT;
5194 id object = handle; 5387 id object = handle;
5195 5388
5196 if([object isMemberOfClass:[DWComboBox class]]) 5389 if([object isMemberOfClass:[DWComboBox class]])
5197 { 5390 {
5198 DWComboBox *combo = handle; 5391 DWComboBox *combo = handle;
5207 5400
5208 [cont insertRow:newrow at:pos]; 5401 [cont insertRow:newrow at:pos];
5209 [cont reloadData]; 5402 [cont reloadData];
5210 [cont setNeedsDisplay:YES]; 5403 [cont setNeedsDisplay:YES];
5211 } 5404 }
5212 DW_MUTEX_UNLOCK; 5405 DW_FUNCTION_RETURN_NOTHING;
5213 } 5406 }
5214 5407
5215 /* 5408 /*
5216 * Appends the specified text items to the listbox's (or combobox) entry list. 5409 * Appends the specified text items to the listbox's (or combobox) entry list.
5217 * Parameters: 5410 * Parameters:
5218 * handle: Handle to the listbox to be appended to. 5411 * handle: Handle to the listbox to be appended to.
5219 * text: Text strings to append into listbox. 5412 * text: Text strings to append into listbox.
5220 * count: Number of text strings to append 5413 * count: Number of text strings to append
5221 */ 5414 */
5222 void API dw_listbox_list_append(HWND handle, char **text, int count) 5415 DW_FUNCTION_DEFINITION(dw_listbox_list_append, void, HWND handle, char **text, int count)
5223 { 5416 DW_FUNCTION_ADD_PARAM3(handle, text, count)
5224 int _locked_by_me = FALSE; 5417 DW_FUNCTION_NO_RETURN(dw_listbox_list_append)
5225 DW_MUTEX_LOCK; 5418 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, char **, count, int)
5419 {
5420 DW_FUNCTION_INIT;
5226 id object = handle; 5421 id object = handle;
5227 5422
5228 if([object isMemberOfClass:[DWComboBox class]]) 5423 if([object isMemberOfClass:[DWComboBox class]])
5229 { 5424 {
5230 DWComboBox *combo = handle; 5425 DWComboBox *combo = handle;
5248 [cont addRow:newrow]; 5443 [cont addRow:newrow];
5249 } 5444 }
5250 [cont reloadData]; 5445 [cont reloadData];
5251 [cont setNeedsDisplay:YES]; 5446 [cont setNeedsDisplay:YES];
5252 } 5447 }
5253 DW_MUTEX_UNLOCK; 5448 DW_FUNCTION_RETURN_NOTHING;
5254 } 5449 }
5255 5450
5256 /* 5451 /*
5257 * Clears the listbox's (or combobox) list of all entries. 5452 * Clears the listbox's (or combobox) list of all entries.
5258 * Parameters: 5453 * Parameters:
5259 * handle: Handle to the listbox to be cleared. 5454 * handle: Handle to the listbox to be cleared.
5260 */ 5455 */
5261 void API dw_listbox_clear(HWND handle) 5456 DW_FUNCTION_DEFINITION(dw_listbox_clear, void, HWND handle)
5262 { 5457 DW_FUNCTION_ADD_PARAM1(handle)
5263 int _locked_by_me = FALSE; 5458 DW_FUNCTION_NO_RETURN(dw_listbox_clear)
5264 DW_MUTEX_LOCK; 5459 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
5460 {
5461 DW_FUNCTION_INIT;
5265 id object = handle; 5462 id object = handle;
5266 5463
5267 if([object isMemberOfClass:[DWComboBox class]]) 5464 if([object isMemberOfClass:[DWComboBox class]])
5268 { 5465 {
5269 DWComboBox *combo = handle; 5466 DWComboBox *combo = handle;
5276 5473
5277 [cont clear]; 5474 [cont clear];
5278 [cont reloadData]; 5475 [cont reloadData];
5279 [cont setNeedsDisplay:YES]; 5476 [cont setNeedsDisplay:YES];
5280 } 5477 }
5281 DW_MUTEX_UNLOCK; 5478 DW_FUNCTION_RETURN_NOTHING;
5282 } 5479 }
5283 5480
5284 /* 5481 /*
5285 * Returns the listbox's item count. 5482 * Returns the listbox's item count.
5286 * Parameters: 5483 * Parameters:
5287 * handle: Handle to the listbox to be cleared. 5484 * handle: Handle to the listbox to be cleared.
5288 */ 5485 */
5289 int API dw_listbox_count(HWND handle) 5486 DW_FUNCTION_DEFINITION(dw_listbox_count, int, HWND handle)
5290 { 5487 DW_FUNCTION_ADD_PARAM1(handle)
5488 DW_FUNCTION_RETURN(dw_listbox_count, int)
5489 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
5490 {
5491 DW_FUNCTION_INIT;
5291 id object = handle; 5492 id object = handle;
5493 int result = 0;
5292 5494
5293 if([object isMemberOfClass:[DWComboBox class]]) 5495 if([object isMemberOfClass:[DWComboBox class]])
5294 { 5496 {
5295 DWComboBox *combo = handle; 5497 DWComboBox *combo = handle;
5296 5498
5297 return (int)[combo numberOfItems]; 5499 result = (int)[combo numberOfItems];
5298 } 5500 }
5299 else if([object isMemberOfClass:[DWContainer class]]) 5501 else if([object isMemberOfClass:[DWContainer class]])
5300 { 5502 {
5301 int _locked_by_me = FALSE;
5302 DW_MUTEX_LOCK;
5303 DWContainer *cont = handle; 5503 DWContainer *cont = handle;
5304 int result = (int)[cont numberOfRowsInTableView:cont]; 5504 result = (int)[cont numberOfRowsInTableView:cont];
5305 DW_MUTEX_UNLOCK; 5505 }
5306 return result; 5506 DW_FUNCTION_RETURN_THIS(result);
5307 }
5308 return 0;
5309 } 5507 }
5310 5508
5311 /* 5509 /*
5312 * Sets the topmost item in the viewport. 5510 * Sets the topmost item in the viewport.
5313 * Parameters: 5511 * Parameters:
5314 * handle: Handle to the listbox to be cleared. 5512 * handle: Handle to the listbox to be cleared.
5315 * top: Index to the top item. 5513 * top: Index to the top item.
5316 */ 5514 */
5317 void API dw_listbox_set_top(HWND handle, int top) 5515 DW_FUNCTION_DEFINITION(dw_listbox_set_top, void, HWND handle, int top)
5318 { 5516 DW_FUNCTION_ADD_PARAM2(handle, top)
5319 int _locked_by_me = FALSE; 5517 DW_FUNCTION_NO_RETURN(dw_listbox_set_top)
5320 DW_MUTEX_LOCK; 5518 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, top, int)
5519 {
5520 DW_FUNCTION_INIT;
5321 id object = handle; 5521 id object = handle;
5322 5522
5323 if([object isMemberOfClass:[DWComboBox class]]) 5523 if([object isMemberOfClass:[DWComboBox class]])
5324 { 5524 {
5325 DWComboBox *combo = handle; 5525 DWComboBox *combo = handle;
5330 { 5530 {
5331 DWContainer *cont = handle; 5531 DWContainer *cont = handle;
5332 5532
5333 [cont scrollRowToVisible:top]; 5533 [cont scrollRowToVisible:top];
5334 } 5534 }
5335 DW_MUTEX_UNLOCK; 5535 DW_FUNCTION_RETURN_NOTHING;
5336 } 5536 }
5337 5537
5338 /* 5538 /*
5339 * Copies the given index item's text into buffer. 5539 * Copies the given index item's text into buffer.
5340 * Parameters: 5540 * Parameters:
5341 * handle: Handle to the listbox to be queried. 5541 * handle: Handle to the listbox to be queried.
5342 * index: Index into the list to be queried. 5542 * index: Index into the list to be queried.
5343 * buffer: Buffer where text will be copied. 5543 * buffer: Buffer where text will be copied.
5344 * length: Length of the buffer (including NULL). 5544 * length: Length of the buffer (including NULL).
5345 */ 5545 */
5346 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) 5546 DW_FUNCTION_DEFINITION(dw_listbox_get_text, void, HWND handle, unsigned int index, char *buffer, unsigned int length)
5347 { 5547 DW_FUNCTION_ADD_PARAM4(handle, index, buffer, length)
5348 int _locked_by_me = FALSE; 5548 DW_FUNCTION_NO_RETURN(dw_listbox_get_text)
5349 DW_MUTEX_LOCK; 5549 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, index, unsigned int, buffer, char *, length, unsigned int)
5550 {
5551 DW_FUNCTION_INIT;
5350 id object = handle; 5552 id object = handle;
5351 5553
5352 if([object isMemberOfClass:[DWComboBox class]]) 5554 if([object isMemberOfClass:[DWComboBox class]])
5353 { 5555 {
5354 DWComboBox *combo = handle; 5556 DWComboBox *combo = handle;
5378 NSString *nstr = [cont getRow:index and:0]; 5580 NSString *nstr = [cont getRow:index and:0];
5379 5581
5380 strncpy(buffer, [ nstr UTF8String ], length - 1); 5582 strncpy(buffer, [ nstr UTF8String ], length - 1);
5381 } 5583 }
5382 } 5584 }
5383 DW_MUTEX_UNLOCK; 5585 DW_FUNCTION_RETURN_NOTHING;
5384 } 5586 }
5385 5587
5386 /* 5588 /*
5387 * Sets the text of a given listbox entry. 5589 * Sets the text of a given listbox entry.
5388 * Parameters: 5590 * Parameters:
5389 * handle: Handle to the listbox to be queried. 5591 * handle: Handle to the listbox to be queried.
5390 * index: Index into the list to be queried. 5592 * index: Index into the list to be queried.
5391 * buffer: Buffer where text will be copied. 5593 * buffer: Buffer where text will be copied.
5392 */ 5594 */
5393 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) 5595 DW_FUNCTION_DEFINITION(dw_listbox_set_text, void, HWND handle, unsigned int index, char *buffer)
5394 { 5596 DW_FUNCTION_ADD_PARAM3(handle, index, buffer)
5395 int _locked_by_me = FALSE; 5597 DW_FUNCTION_NO_RETURN(dw_listbox_set_text)
5396 DW_MUTEX_LOCK; 5598 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, unsigned int, buffer, char *)
5599 {
5600 DW_FUNCTION_INIT;
5397 id object = handle; 5601 id object = handle;
5398 5602
5399 if([object isMemberOfClass:[DWComboBox class]]) 5603 if([object isMemberOfClass:[DWComboBox class]])
5400 { 5604 {
5401 DWComboBox *combo = handle; 5605 DWComboBox *combo = handle;
5419 [cont editCell:nstr at:index and:0]; 5623 [cont editCell:nstr at:index and:0];
5420 [cont reloadData]; 5624 [cont reloadData];
5421 [cont setNeedsDisplay:YES]; 5625 [cont setNeedsDisplay:YES];
5422 } 5626 }
5423 } 5627 }
5424 DW_MUTEX_UNLOCK; 5628 DW_FUNCTION_RETURN_NOTHING;
5425 } 5629 }
5426 5630
5427 /* 5631 /*
5428 * Returns the index to the item in the list currently selected. 5632 * Returns the index to the item in the list currently selected.
5429 * Parameters: 5633 * Parameters:
5430 * handle: Handle to the listbox to be queried. 5634 * handle: Handle to the listbox to be queried.
5431 */ 5635 */
5432 int API dw_listbox_selected(HWND handle) 5636 DW_FUNCTION_DEFINITION(dw_listbox_selected, int, HWND handle)
5433 { 5637 DW_FUNCTION_ADD_PARAM1(handle)
5638 DW_FUNCTION_RETURN(dw_listbox_selected, int)
5639 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
5640 {
5641 DW_FUNCTION_INIT;
5434 id object = handle; 5642 id object = handle;
5643 int result = -1;
5435 5644
5436 if([object isMemberOfClass:[DWComboBox class]]) 5645 if([object isMemberOfClass:[DWComboBox class]])
5437 { 5646 {
5438 DWComboBox *combo = handle; 5647 DWComboBox *combo = handle;
5439 return (int)[combo indexOfSelectedItem]; 5648 result = (int)[combo indexOfSelectedItem];
5440 } 5649 }
5441 else if([object isMemberOfClass:[DWContainer class]]) 5650 else if([object isMemberOfClass:[DWContainer class]])
5442 { 5651 {
5443 int _locked_by_me = FALSE;
5444 DW_MUTEX_LOCK;
5445 DWContainer *cont = handle; 5652 DWContainer *cont = handle;
5446 int result = (int)[cont selectedRow]; 5653 result = (int)[cont selectedRow];
5447 DW_MUTEX_UNLOCK; 5654 }
5448 return result; 5655 DW_FUNCTION_RETURN_THIS(result);
5449 }
5450 return -1;
5451 } 5656 }
5452 5657
5453 /* 5658 /*
5454 * Returns the index to the current selected item or -1 when done. 5659 * Returns the index to the current selected item or -1 when done.
5455 * Parameters: 5660 * Parameters:
5456 * handle: Handle to the listbox to be queried. 5661 * handle: Handle to the listbox to be queried.
5457 * where: Either the previous return or -1 to restart. 5662 * where: Either the previous return or -1 to restart.
5458 */ 5663 */
5459 int API dw_listbox_selected_multi(HWND handle, int where) 5664 DW_FUNCTION_DEFINITION(dw_listbox_selected_multi, int, HWND handle, int where)
5460 { 5665 DW_FUNCTION_ADD_PARAM2(handle, where)
5461 int _locked_by_me = FALSE; 5666 DW_FUNCTION_RETURN(dw_listbox_selected_multi, int)
5462 DW_MUTEX_LOCK; 5667 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, where, int)
5668 {
5669 DW_FUNCTION_INIT;
5463 id object = handle; 5670 id object = handle;
5464 int retval = -1; 5671 int retval = -1;
5465 5672
5466 if([object isMemberOfClass:[DWContainer class]]) 5673 if([object isMemberOfClass:[DWContainer class]])
5467 { 5674 {
5476 if(result != NSNotFound) 5683 if(result != NSNotFound)
5477 { 5684 {
5478 retval = (int)result; 5685 retval = (int)result;
5479 } 5686 }
5480 } 5687 }
5481 DW_MUTEX_UNLOCK; 5688 DW_FUNCTION_RETURN_THIS(retval)
5482 return retval;
5483 } 5689 }
5484 5690
5485 /* 5691 /*
5486 * Sets the selection state of a given index. 5692 * Sets the selection state of a given index.
5487 * Parameters: 5693 * Parameters:
5488 * handle: Handle to the listbox to be set. 5694 * handle: Handle to the listbox to be set.
5489 * index: Item index. 5695 * index: Item index.
5490 * state: TRUE if selected FALSE if unselected. 5696 * state: TRUE if selected FALSE if unselected.
5491 */ 5697 */
5492 void API dw_listbox_select(HWND handle, int index, int state) 5698 DW_FUNCTION_DEFINITION(dw_listbox_select, void, HWND handle, int index, int state)
5493 { 5699 DW_FUNCTION_ADD_PARAM3(handle, index, state)
5494 int _locked_by_me = FALSE; 5700 DW_FUNCTION_NO_RETURN(dw_listbox_select)
5495 DW_MUTEX_LOCK; 5701 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, int, state, int)
5702 {
5703 DW_FUNCTION_INIT;
5496 id object = handle; 5704 id object = handle;
5497 5705
5498 if([object isMemberOfClass:[DWComboBox class]]) 5706 if([object isMemberOfClass:[DWComboBox class]])
5499 { 5707 {
5500 DWComboBox *combo = handle; 5708 DWComboBox *combo = handle;
5509 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index]; 5717 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index];
5510 5718
5511 [cont selectRowIndexes:selected byExtendingSelection:YES]; 5719 [cont selectRowIndexes:selected byExtendingSelection:YES];
5512 [selected release]; 5720 [selected release];
5513 } 5721 }
5514 DW_MUTEX_UNLOCK; 5722 DW_FUNCTION_RETURN_NOTHING;
5515 } 5723 }
5516 5724
5517 /* 5725 /*
5518 * Deletes the item with given index from the list. 5726 * Deletes the item with given index from the list.
5519 * Parameters: 5727 * Parameters:
5520 * handle: Handle to the listbox to be set. 5728 * handle: Handle to the listbox to be set.
5521 * index: Item index. 5729 * index: Item index.
5522 */ 5730 */
5523 void API dw_listbox_delete(HWND handle, int index) 5731 DW_FUNCTION_DEFINITION(dw_listbox_delete, void, HWND handle, int index)
5524 { 5732 DW_FUNCTION_ADD_PARAM2(handle, index)
5525 int _locked_by_me = FALSE; 5733 DW_FUNCTION_NO_RETURN(dw_listbox_delete)
5526 DW_MUTEX_LOCK; 5734 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, index, int)
5735 {
5736 DW_FUNCTION_INIT;
5527 id object = handle; 5737 id object = handle;
5528 5738
5529 if([object isMemberOfClass:[DWComboBox class]]) 5739 if([object isMemberOfClass:[DWComboBox class]])
5530 { 5740 {
5531 DWComboBox *combo = handle; 5741 DWComboBox *combo = handle;
5538 5748
5539 [cont removeRow:index]; 5749 [cont removeRow:index];
5540 [cont reloadData]; 5750 [cont reloadData];
5541 [cont setNeedsDisplay:YES]; 5751 [cont setNeedsDisplay:YES];
5542 } 5752 }
5543 DW_MUTEX_UNLOCK; 5753 DW_FUNCTION_RETURN_NOTHING;
5544 } 5754 }
5545 5755
5546 /* 5756 /*
5547 * Create a new Combobox window (widget) to be packed. 5757 * Create a new Combobox window (widget) to be packed.
5548 * Parameters: 5758 * Parameters:
5549 * text: The default text to be in the combpbox widget. 5759 * text: The default text to be in the combpbox widget.
5550 * id: An ID to be used with dw_window_from_id() or 0L. 5760 * id: An ID to be used with dw_window_from_id() or 0L.
5551 */ 5761 */
5552 HWND API dw_combobox_new(char *text, ULONG cid) 5762 DW_FUNCTION_DEFINITION(dw_combobox_new, HWND, char *text, ULONG cid)
5553 { 5763 DW_FUNCTION_ADD_PARAM2(text, cid)
5764 DW_FUNCTION_RETURN(dw_combobox_new, HWND)
5765 DW_FUNCTION_RESTORE_PARAM2(text, char *, cid, ULONG)
5766 {
5767 DW_FUNCTION_INIT;
5554 DWComboBox *combo = [[DWComboBox alloc] init]; 5768 DWComboBox *combo = [[DWComboBox alloc] init];
5555 [combo setStringValue:[NSString stringWithUTF8String:text]]; 5769 [combo setStringValue:[NSString stringWithUTF8String:text]];
5556 [combo setDelegate:combo]; 5770 [combo setDelegate:combo];
5557 [combo setTag:cid]; 5771 [combo setTag:cid];
5558 return combo; 5772 DW_FUNCTION_RETURN_THIS(combo)
5559 } 5773 }
5560 5774
5561 /* 5775 /*
5562 * Create a new Multiline Editbox window (widget) to be packed. 5776 * Create a new Multiline Editbox window (widget) to be packed.
5563 * Parameters: 5777 * Parameters:
5592 * Parameters: 5806 * Parameters:
5593 * handle: Handle to the MLE to be queried. 5807 * handle: Handle to the MLE to be queried.
5594 * buffer: Text buffer to be imported. 5808 * buffer: Text buffer to be imported.
5595 * startpoint: Point to start entering text. 5809 * startpoint: Point to start entering text.
5596 */ 5810 */
5597 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) 5811 DW_FUNCTION_DEFINITION(dw_mle_import, unsigned int, HWND handle, char *buffer, int startpoint)
5598 { 5812 DW_FUNCTION_ADD_PARAM3(handle, buffer, startpoint)
5813 DW_FUNCTION_RETURN(dw_mle_import, unsigned int)
5814 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, buffer, char *, startpoint, int)
5815 {
5816 DW_FUNCTION_INIT;
5599 DWMLE *mle = handle; 5817 DWMLE *mle = handle;
5600 int _locked_by_me = FALSE; 5818 unsigned int retval;
5601 DW_MUTEX_LOCK;
5602 NSTextStorage *ts = [mle textStorage]; 5819 NSTextStorage *ts = [mle textStorage];
5603 NSString *nstr = [NSString stringWithUTF8String:buffer]; 5820 NSString *nstr = [NSString stringWithUTF8String:buffer];
5604 NSMutableString *ms = [ts mutableString]; 5821 NSMutableString *ms = [ts mutableString];
5605 NSUInteger length = [ms length]; 5822 NSUInteger length = [ms length];
5606 if(startpoint < 0) 5823 if(startpoint < 0)
5607 startpoint = 0; 5824 startpoint = 0;
5608 if(startpoint > length) 5825 if(startpoint > length)
5609 startpoint = (int)length; 5826 startpoint = (int)length;
5610 [ms insertString:nstr atIndex:startpoint]; 5827 [ms insertString:nstr atIndex:startpoint];
5611 DW_MUTEX_UNLOCK; 5828 retval = (unsigned int)strlen(buffer) + startpoint;
5612 return (unsigned int)strlen(buffer) + startpoint; 5829 DW_FUNCTION_RETURN_THIS(retval);
5613 } 5830 }
5614 5831
5615 /* 5832 /*
5616 * Grabs text from an MLE box. 5833 * Grabs text from an MLE box.
5617 * Parameters: 5834 * Parameters:
5618 * handle: Handle to the MLE to be queried. 5835 * handle: Handle to the MLE to be queried.
5619 * buffer: Text buffer to be exported. 5836 * buffer: Text buffer to be exported.
5620 * startpoint: Point to start grabbing text. 5837 * startpoint: Point to start grabbing text.
5621 * length: Amount of text to be grabbed. 5838 * length: Amount of text to be grabbed.
5622 */ 5839 */
5623 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) 5840 DW_FUNCTION_DEFINITION(dw_mle_export, void, HWND handle, char *buffer, int startpoint, int length)
5624 { 5841 DW_FUNCTION_ADD_PARAM4(handle, buffer, startpoint, length)
5842 DW_FUNCTION_NO_RETURN(dw_mle_export)
5843 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, buffer, char *, startpoint, int, length, int)
5844 {
5845 DW_FUNCTION_INIT;
5625 DWMLE *mle = handle; 5846 DWMLE *mle = handle;
5626 int _locked_by_me = FALSE;
5627 DW_MUTEX_LOCK;
5628 NSTextStorage *ts = [mle textStorage]; 5847 NSTextStorage *ts = [mle textStorage];
5629 NSMutableString *ms = [ts mutableString]; 5848 NSMutableString *ms = [ts mutableString];
5630 const char *tmp = [ms UTF8String]; 5849 const char *tmp = [ms UTF8String];
5631 strncpy(buffer, tmp+startpoint, length); 5850 strncpy(buffer, tmp+startpoint, length);
5632 buffer[length] = '\0'; 5851 buffer[length] = '\0';
5633 DW_MUTEX_UNLOCK; 5852 DW_FUNCTION_RETURN_NOTHING;
5634 } 5853 }
5635 5854
5636 /* 5855 /*
5637 * Obtains information about an MLE box. 5856 * Obtains information about an MLE box.
5638 * Parameters: 5857 * Parameters:
5639 * handle: Handle to the MLE to be queried. 5858 * handle: Handle to the MLE to be queried.
5640 * bytes: A pointer to a variable to return the total bytes. 5859 * bytes: A pointer to a variable to return the total bytes.
5641 * lines: A pointer to a variable to return the number of lines. 5860 * lines: A pointer to a variable to return the number of lines.
5642 */ 5861 */
5643 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines) 5862 DW_FUNCTION_DEFINITION(dw_mle_get_size, void, HWND handle, unsigned long *bytes, unsigned long *lines)
5644 { 5863 DW_FUNCTION_ADD_PARAM3(handle, bytes, lines)
5864 DW_FUNCTION_NO_RETURN(dw_mle_get_size)
5865 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, bytes, unsigned long *, lines, unsigned long *)
5866 {
5867 DW_FUNCTION_INIT;
5645 DWMLE *mle = handle; 5868 DWMLE *mle = handle;
5646 int _locked_by_me = FALSE;
5647 DW_MUTEX_LOCK;
5648 NSTextStorage *ts = [mle textStorage]; 5869 NSTextStorage *ts = [mle textStorage];
5649 NSMutableString *ms = [ts mutableString]; 5870 NSMutableString *ms = [ts mutableString];
5650 NSUInteger numberOfLines, index, stringLength = [ms length]; 5871 NSUInteger numberOfLines, index, stringLength = [ms length];
5651 5872
5652 if(bytes) 5873 if(bytes)
5656 for(index=0, numberOfLines=0; index < stringLength; numberOfLines++) 5877 for(index=0, numberOfLines=0; index < stringLength; numberOfLines++)
5657 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]); 5878 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]);
5658 5879
5659 *lines = numberOfLines; 5880 *lines = numberOfLines;
5660 } 5881 }
5661 DW_MUTEX_UNLOCK; 5882 DW_FUNCTION_RETURN_NOTHING;
5662 } 5883 }
5663 5884
5664 /* 5885 /*
5665 * Deletes text from an MLE box. 5886 * Deletes text from an MLE box.
5666 * Parameters: 5887 * Parameters:
5667 * handle: Handle to the MLE to be deleted from. 5888 * handle: Handle to the MLE to be deleted from.
5668 * startpoint: Point to start deleting text. 5889 * startpoint: Point to start deleting text.
5669 * length: Amount of text to be deleted. 5890 * length: Amount of text to be deleted.
5670 */ 5891 */
5671 void API dw_mle_delete(HWND handle, int startpoint, int length) 5892 DW_FUNCTION_DEFINITION(dw_mle_delete, void, HWND handle, int startpoint, int length)
5672 { 5893 DW_FUNCTION_ADD_PARAM3(handle, startpoint, length)
5894 DW_FUNCTION_NO_RETURN(dw_mle_delete)
5895 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, startpoint, int, length, int)
5896 {
5897 DW_FUNCTION_INIT;
5673 DWMLE *mle = handle; 5898 DWMLE *mle = handle;
5674 int _locked_by_me = FALSE;
5675 DW_MUTEX_LOCK;
5676 NSTextStorage *ts = [mle textStorage]; 5899 NSTextStorage *ts = [mle textStorage];
5677 NSMutableString *ms = [ts mutableString]; 5900 NSMutableString *ms = [ts mutableString];
5678 NSUInteger mslength = [ms length]; 5901 NSUInteger mslength = [ms length];
5679 if(startpoint < 0) 5902 if(startpoint < 0)
5680 startpoint = 0; 5903 startpoint = 0;
5681 if(startpoint > mslength) 5904 if(startpoint > mslength)
5682 startpoint = (int)mslength; 5905 startpoint = (int)mslength;
5683 if(startpoint + length > mslength) 5906 if(startpoint + length > mslength)
5684 length = (int)mslength - startpoint; 5907 length = (int)mslength - startpoint;
5685 [ms deleteCharactersInRange:NSMakeRange(startpoint, length)]; 5908 [ms deleteCharactersInRange:NSMakeRange(startpoint, length)];
5686 DW_MUTEX_UNLOCK; 5909 DW_FUNCTION_RETURN_NOTHING;
5687 } 5910 }
5688 5911
5689 /* 5912 /*
5690 * Clears all text from an MLE box. 5913 * Clears all text from an MLE box.
5691 * Parameters: 5914 * Parameters:
5692 * handle: Handle to the MLE to be cleared. 5915 * handle: Handle to the MLE to be cleared.
5693 */ 5916 */
5694 void API dw_mle_clear(HWND handle) 5917 DW_FUNCTION_DEFINITION(dw_mle_clear, void, HWND handle)
5695 { 5918 DW_FUNCTION_ADD_PARAM1(handle)
5919 DW_FUNCTION_NO_RETURN(dw_mle_clear)
5920 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
5921 {
5922 DW_FUNCTION_INIT;
5696 DWMLE *mle = handle; 5923 DWMLE *mle = handle;
5697 int _locked_by_me = FALSE;
5698 DW_MUTEX_LOCK;
5699 NSTextStorage *ts = [mle textStorage]; 5924 NSTextStorage *ts = [mle textStorage];
5700 NSMutableString *ms = [ts mutableString]; 5925 NSMutableString *ms = [ts mutableString];
5701 NSUInteger length = [ms length]; 5926 NSUInteger length = [ms length];
5702 [ms deleteCharactersInRange:NSMakeRange(0, length)]; 5927 [ms deleteCharactersInRange:NSMakeRange(0, length)];
5703 DW_MUTEX_UNLOCK; 5928 DW_FUNCTION_RETURN_NOTHING;
5704 } 5929 }
5705 5930
5706 /* 5931 /*
5707 * Sets the visible line of an MLE box. 5932 * Sets the visible line of an MLE box.
5708 * Parameters: 5933 * Parameters:
5709 * handle: Handle to the MLE to be positioned. 5934 * handle: Handle to the MLE to be positioned.
5710 * line: Line to be visible. 5935 * line: Line to be visible.
5711 */ 5936 */
5712 void API dw_mle_set_visible(HWND handle, int line) 5937 DW_FUNCTION_DEFINITION(dw_mle_set_visible, void, HWND handle, int line)
5713 { 5938 DW_FUNCTION_ADD_PARAM2(handle, line)
5939 DW_FUNCTION_NO_RETURN(dw_mle_set_visible)
5940 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, line, int)
5941 {
5942 DW_FUNCTION_INIT;
5714 DWMLE *mle = handle; 5943 DWMLE *mle = handle;
5715 int _locked_by_me = FALSE;
5716 DW_MUTEX_LOCK;
5717 NSTextStorage *ts = [mle textStorage]; 5944 NSTextStorage *ts = [mle textStorage];
5718 NSMutableString *ms = [ts mutableString]; 5945 NSMutableString *ms = [ts mutableString];
5719 NSUInteger numberOfLines, index, stringLength = [ms length]; 5946 NSUInteger numberOfLines, index, stringLength = [ms length];
5720 5947
5721 for(index=0, numberOfLines=0; index < stringLength && numberOfLines < line; numberOfLines++) 5948 for(index=0, numberOfLines=0; index < stringLength && numberOfLines < line; numberOfLines++)
5723 5950
5724 if(line == numberOfLines) 5951 if(line == numberOfLines)
5725 { 5952 {
5726 [mle scrollRangeToVisible:[ms lineRangeForRange:NSMakeRange(index, 0)]]; 5953 [mle scrollRangeToVisible:[ms lineRangeForRange:NSMakeRange(index, 0)]];
5727 } 5954 }
5728 DW_MUTEX_UNLOCK; 5955 DW_FUNCTION_RETURN_NOTHING;
5729 } 5956 }
5730 5957
5731 /* 5958 /*
5732 * Sets the editablity of an MLE box. 5959 * Sets the editablity of an MLE box.
5733 * Parameters: 5960 * Parameters:
5790 * Sets the current cursor position of an MLE box. 6017 * Sets the current cursor position of an MLE box.
5791 * Parameters: 6018 * Parameters:
5792 * handle: Handle to the MLE to be positioned. 6019 * handle: Handle to the MLE to be positioned.
5793 * point: Point to position cursor. 6020 * point: Point to position cursor.
5794 */ 6021 */
5795 void API dw_mle_set_cursor(HWND handle, int point) 6022 DW_FUNCTION_DEFINITION(dw_mle_set_cursor, void, HWND handle, int point)
5796 { 6023 DW_FUNCTION_ADD_PARAM2(handle, point)
6024 DW_FUNCTION_NO_RETURN(dw_mle_set_cursor)
6025 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, point, int)
6026 {
6027 DW_FUNCTION_INIT;
5797 DWMLE *mle = handle; 6028 DWMLE *mle = handle;
5798 int _locked_by_me = FALSE;
5799 DW_MUTEX_LOCK;
5800 NSTextStorage *ts = [mle textStorage]; 6029 NSTextStorage *ts = [mle textStorage];
5801 NSMutableString *ms = [ts mutableString]; 6030 NSMutableString *ms = [ts mutableString];
5802 NSUInteger length = [ms length]; 6031 NSUInteger length = [ms length];
5803 if(point < 0) 6032 if(point < 0)
5804 point = 0; 6033 point = 0;
5805 if(point > length) 6034 if(point > length)
5806 point = (int)length; 6035 point = (int)length;
5807 [mle setSelectedRange: NSMakeRange(point,point)]; 6036 [mle setSelectedRange: NSMakeRange(point,point)];
5808 [mle scrollRangeToVisible:NSMakeRange(point,point)]; 6037 [mle scrollRangeToVisible:NSMakeRange(point,point)];
5809 DW_MUTEX_UNLOCK; 6038 DW_FUNCTION_RETURN_NOTHING;
5810 } 6039 }
5811 6040
5812 /* 6041 /*
5813 * Finds text in an MLE box. 6042 * Finds text in an MLE box.
5814 * Parameters: 6043 * Parameters:
5815 * handle: Handle to the MLE to be cleared. 6044 * handle: Handle to the MLE to be cleared.
5816 * text: Text to search for. 6045 * text: Text to search for.
5817 * point: Start point of search. 6046 * point: Start point of search.
5818 * flags: Search specific flags. 6047 * flags: Search specific flags.
5819 */ 6048 */
5820 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) 6049 DW_FUNCTION_DEFINITION(dw_mle_search, int, HWND handle, char *text, int point, unsigned long flags)
5821 { 6050 DW_FUNCTION_ADD_PARAM4(handle, text, point, flags)
6051 DW_FUNCTION_RETURN(dw_mle_search, int)
6052 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, text, char *, point, int, flags, unsigned long)
6053 {
6054 DW_FUNCTION_INIT;
5822 DWMLE *mle = handle; 6055 DWMLE *mle = handle;
5823 int _locked_by_me = FALSE;
5824 DW_MUTEX_LOCK;
5825 NSTextStorage *ts = [mle textStorage]; 6056 NSTextStorage *ts = [mle textStorage];
5826 NSMutableString *ms = [ts mutableString]; 6057 NSMutableString *ms = [ts mutableString];
5827 NSString *searchForMe = [NSString stringWithUTF8String:text]; 6058 NSString *searchForMe = [NSString stringWithUTF8String:text];
5828 NSRange searchRange = NSMakeRange(point, [ms length] - point); 6059 NSRange searchRange = NSMakeRange(point, [ms length] - point);
5829 NSRange range = NSMakeRange(NSNotFound, 0); 6060 NSRange range = NSMakeRange(NSNotFound, 0);
5830 NSUInteger options = flags ? flags : NSCaseInsensitiveSearch; 6061 NSUInteger options = flags ? flags : NSCaseInsensitiveSearch;
6062 int retval = -1;
5831 6063
5832 if(ms) 6064 if(ms)
5833 {
5834 range = [ms rangeOfString:searchForMe options:options range:searchRange]; 6065 range = [ms rangeOfString:searchForMe options:options range:searchRange];
5835 } 6066 if(range.location == NSNotFound)
5836 DW_MUTEX_UNLOCK; 6067 retval = (int)range.location;
5837 if(range.location != NSNotFound) 6068 DW_FUNCTION_RETURN_THIS(retval);
5838 {
5839 return -1;
5840 }
5841 return (int)range.location;
5842 } 6069 }
5843 6070
5844 /* 6071 /*
5845 * Stops redrawing of an MLE box. 6072 * Stops redrawing of an MLE box.
5846 * Parameters: 6073 * Parameters:
6038 * handle: Handle to the window. 6265 * handle: Handle to the window.
6039 * pixmap: Handle to the pixmap. (choose only one of these) 6266 * pixmap: Handle to the pixmap. (choose only one of these)
6040 * x: X coordinate. 6267 * x: X coordinate.
6041 * y: Y coordinate. 6268 * y: Y coordinate.
6042 */ 6269 */
6043 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) 6270 DW_FUNCTION_DEFINITION(dw_draw_point, void, HWND handle, HPIXMAP pixmap, int x, int y)
6044 { 6271 DW_FUNCTION_ADD_PARAM4(handle, pixmap, x, y)
6045 int _locked_by_me = FALSE; 6272 DW_FUNCTION_NO_RETURN(dw_draw_point)
6273 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, pixmap, HPIXMAP, x, int, y, int)
6274 {
6275 DW_FUNCTION_INIT;
6046 DW_LOCAL_POOL_IN; 6276 DW_LOCAL_POOL_IN;
6047 DW_MUTEX_LOCK;
6048 id image = handle; 6277 id image = handle;
6049 NSBitmapImageRep *bi = nil; 6278 NSBitmapImageRep *bi = nil;
6279 bool bCanDraw = YES;
6050 6280
6051 if(pixmap) 6281 if(pixmap)
6052 bi = image = (id)pixmap->image; 6282 bi = image = (id)pixmap->image;
6053 else 6283 else
6054 { 6284 {
6058 DWRender *render = image; 6288 DWRender *render = image;
6059 6289
6060 bi = [render cachedDrawingRep]; 6290 bi = [render cachedDrawingRep];
6061 } 6291 }
6062 #else 6292 #else
6063 if([image lockFocusIfCanDraw] == NO) 6293 if((bCanDraw = [image lockFocusIfCanDraw]) == YES)
6064 { 6294 _DWLastDrawable = handle;
6065 DW_MUTEX_UNLOCK;
6066 DW_LOCAL_POOL_OUT;
6067 return;
6068 }
6069 _DWLastDrawable = handle;
6070 #endif 6295 #endif
6071 } 6296 }
6072 if(bi) 6297 if(bi)
6073 { 6298 {
6074 [NSGraphicsContext saveGraphicsState]; 6299 [NSGraphicsContext saveGraphicsState];
6075 [NSGraphicsContext setCurrentContext:_dw_draw_context(bi)]; 6300 [NSGraphicsContext setCurrentContext:_dw_draw_context(bi)];
6076 } 6301 }
6077 NSBezierPath* aPath = [NSBezierPath bezierPath]; 6302 if(bCanDraw == YES)
6078 [aPath setLineWidth: 0.5]; 6303 {
6079 NSColor *color = pthread_getspecific(_dw_fg_color_key); 6304 NSBezierPath* aPath = [NSBezierPath bezierPath];
6080 [color set]; 6305 [aPath setLineWidth: 0.5];
6081 6306 NSColor *color = pthread_getspecific(_dw_fg_color_key);
6082 [aPath moveToPoint:NSMakePoint(x, y)]; 6307 [color set];
6083 [aPath stroke]; 6308
6309 [aPath moveToPoint:NSMakePoint(x, y)];
6310 [aPath stroke];
6311 }
6084 if(bi) 6312 if(bi)
6085 [NSGraphicsContext restoreGraphicsState]; 6313 [NSGraphicsContext restoreGraphicsState];
6086 #ifndef BUILDING_FOR_MOJAVE 6314 #ifndef BUILDING_FOR_MOJAVE
6087 if(!pixmap) 6315 if(bCanDraw == YES && !pixmap)
6088 [image unlockFocus]; 6316 [image unlockFocus];
6089 #endif 6317 #endif
6090 DW_MUTEX_UNLOCK;
6091 DW_LOCAL_POOL_OUT; 6318 DW_LOCAL_POOL_OUT;
6319 DW_FUNCTION_RETURN_NOTHING;
6092 } 6320 }
6093 6321
6094 /* Draw a line on a window (preferably a render window). 6322 /* Draw a line on a window (preferably a render window).
6095 * Parameters: 6323 * Parameters:
6096 * handle: Handle to the window. 6324 * handle: Handle to the window.
6098 * x1: First X coordinate. 6326 * x1: First X coordinate.
6099 * y1: First Y coordinate. 6327 * y1: First Y coordinate.
6100 * x2: Second X coordinate. 6328 * x2: Second X coordinate.
6101 * y2: Second Y coordinate. 6329 * y2: Second Y coordinate.
6102 */ 6330 */
6103 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) 6331 DW_FUNCTION_DEFINITION(dw_draw_line, void, HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
6104 { 6332 DW_FUNCTION_ADD_PARAM6(handle, pixmap, x1, y1, x2, y2)
6105 int _locked_by_me = FALSE; 6333 DW_FUNCTION_NO_RETURN(dw_draw_line)
6334 DW_FUNCTION_RESTORE_PARAM6(handle, HWND, pixmap, HPIXMAP, x1, int, y1, int, x2, int, y2, int)
6335 {
6336 DW_FUNCTION_INIT;
6106 DW_LOCAL_POOL_IN; 6337 DW_LOCAL_POOL_IN;
6107 DW_MUTEX_LOCK;
6108 id image = handle; 6338 id image = handle;
6109 NSBitmapImageRep *bi = nil; 6339 NSBitmapImageRep *bi = nil;
6110 6340 bool bCanDraw = YES;
6341
6111 if(pixmap) 6342 if(pixmap)
6112 bi = image = (id)pixmap->image; 6343 bi = image = (id)pixmap->image;
6113 else 6344 else
6114 { 6345 {
6115 #ifdef BUILDING_FOR_MOJAVE 6346 #ifdef BUILDING_FOR_MOJAVE
6118 DWRender *render = image; 6349 DWRender *render = image;
6119 6350
6120 bi = [render cachedDrawingRep]; 6351 bi = [render cachedDrawingRep];
6121 } 6352 }
6122 #else 6353 #else
6123 if([image lockFocusIfCanDraw] == NO) 6354 if((bCanDraw = [image lockFocusIfCanDraw]) == YES)
6124 { 6355 _DWLastDrawable = handle;
6125 DW_MUTEX_UNLOCK;
6126 DW_LOCAL_POOL_OUT;
6127 return;
6128 }
6129 _DWLastDrawable = handle;
6130 #endif 6356 #endif
6131 } 6357 }
6132 if(bi) 6358 if(bi)
6133 { 6359 {
6134 [NSGraphicsContext saveGraphicsState]; 6360 [NSGraphicsContext saveGraphicsState];
6135 [NSGraphicsContext setCurrentContext:_dw_draw_context(bi)]; 6361 [NSGraphicsContext setCurrentContext:_dw_draw_context(bi)];
6136 } 6362 }
6137 NSBezierPath* aPath = [NSBezierPath bezierPath]; 6363 if(bCanDraw == YES)
6138 NSColor *color = pthread_getspecific(_dw_fg_color_key); 6364 {
6139 [color set]; 6365 NSBezierPath* aPath = [NSBezierPath bezierPath];
6140 6366 NSColor *color = pthread_getspecific(_dw_fg_color_key);
6141 [aPath moveToPoint:NSMakePoint(x1 + 0.5, y1 + 0.5)]; 6367 [color set];
6142 [aPath lineToPoint:NSMakePoint(x2 + 0.5, y2 + 0.5)]; 6368
6143 [aPath stroke]; 6369 [aPath moveToPoint:NSMakePoint(x1 + 0.5, y1 + 0.5)];
6370 [aPath lineToPoint:NSMakePoint(x2 + 0.5, y2 + 0.5)];
6371 [aPath stroke];
6372 }
6144 6373
6145 if(bi) 6374 if(bi)
6146 [NSGraphicsContext restoreGraphicsState]; 6375 [NSGraphicsContext restoreGraphicsState];
6147 #ifndef BUILDING_FOR_MOJAVE 6376 #ifndef BUILDING_FOR_MOJAVE
6148 if(!pixmap) 6377 if(bCanDraw == YES && !pixmap)
6149 [image unlockFocus]; 6378 [image unlockFocus];
6150 #endif 6379 #endif
6151 DW_MUTEX_UNLOCK;
6152 DW_LOCAL_POOL_OUT; 6380 DW_LOCAL_POOL_OUT;
6381 DW_FUNCTION_RETURN_NOTHING;
6153 } 6382 }
6154 6383
6155 /* Draw text on a window (preferably a render window). 6384 /* Draw text on a window (preferably a render window).
6156 * Parameters: 6385 * Parameters:
6157 * handle: Handle to the window. 6386 * handle: Handle to the window.
6158 * pixmap: Handle to the pixmap. (choose only one of these) 6387 * pixmap: Handle to the pixmap. (choose only one of these)
6159 * x: X coordinate. 6388 * x: X coordinate.
6160 * y: Y coordinate. 6389 * y: Y coordinate.
6161 * text: Text to be displayed. 6390 * text: Text to be displayed.
6162 */ 6391 */
6163 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) 6392 DW_FUNCTION_DEFINITION(dw_draw_text, void, HWND handle, HPIXMAP pixmap, int x, int y, char *text)
6164 { 6393 DW_FUNCTION_ADD_PARAM5(handle, pixmap, x, y, text)
6165 int _locked_by_me = FALSE; 6394 DW_FUNCTION_NO_RETURN(dw_draw_text)
6395 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pixmap, HPIXMAP, x, int, y, int, text, char *)
6396 {
6397 DW_FUNCTION_INIT;
6166 DW_LOCAL_POOL_IN; 6398 DW_LOCAL_POOL_IN;
6167 DW_MUTEX_LOCK;
6168 id image = handle; 6399 id image = handle;
6169 NSString *nstr = [ NSString stringWithUTF8String:text ]; 6400 NSString *nstr = [ NSString stringWithUTF8String:text ];
6170 NSBitmapImageRep *bi = nil; 6401 NSBitmapImageRep *bi = nil;
6171 NSFont *font = nil; 6402 NSFont *font = nil;
6172 DWRender *render; 6403 DWRender *render;
6173 #ifndef BUILDING_FOR_MOJAVE 6404 bool bCanDraw = YES;
6174 bool canDraw = NO;
6175 #endif
6176 6405
6177 if(pixmap) 6406 if(pixmap)
6178 { 6407 {
6179 bi = image = (id)pixmap->image; 6408 bi = image = (id)pixmap->image;
6180 font = pixmap->font; 6409 font = pixmap->font;
6190 render = image; 6419 render = image;
6191 font = [render font]; 6420 font = [render font];
6192 #ifdef BUILDING_FOR_MOJAVE 6421 #ifdef BUILDING_FOR_MOJAVE
6193 bi = [render cachedDrawingRep]; 6422 bi = [render cachedDrawingRep];
6194 #else 6423 #else
6195 canDraw = [image lockFocusIfCanDraw]; 6424 if((bCanDraw = [image lockFocusIfCanDraw]) == YES)
6196 if(canDraw == NO) 6425 _DWLastDrawable = handle;
6197 {
6198 DW_MUTEX_UNLOCK;
6199 DW_LOCAL_POOL_OUT;
6200 return;
6201 }
6202 _DWLastDrawable = handle;
6203 #endif 6426 #endif
6204 } 6427 }
6205 if(bi) 6428 if(bi)
6206 { 6429 {
6207 [NSGraphicsContext saveGraphicsState]; 6430 [NSGraphicsContext saveGraphicsState];
6208 [NSGraphicsContext setCurrentContext:_dw_draw_context(bi)]; 6431 [NSGraphicsContext setCurrentContext:_dw_draw_context(bi)];
6209 } 6432 }
6210 6433
6211 NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key); 6434 if(bCanDraw == YES)
6212 NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key); 6435 {
6213 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil]; 6436 NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key);
6214 if(bgcolor) 6437 NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key);
6215 [dict setValue:bgcolor forKey:NSBackgroundColorAttributeName]; 6438 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil];
6216 if(font) 6439 if(bgcolor)
6217 [dict setValue:font forKey:NSFontAttributeName]; 6440 [dict setValue:bgcolor forKey:NSBackgroundColorAttributeName];
6218 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; 6441 if(font)
6219 [dict release]; 6442 [dict setValue:font forKey:NSFontAttributeName];
6443 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict];
6444 [dict release];
6445 }
6220 6446
6221 if(bi) 6447 if(bi)
6222 [NSGraphicsContext restoreGraphicsState]; 6448 [NSGraphicsContext restoreGraphicsState];
6223 #ifndef BUILDING_FOR_MOJAVE 6449 #ifndef BUILDING_FOR_MOJAVE
6224 if(canDraw == YES) 6450 if(bCanDraw == YES && !pixmap)
6225 [image unlockFocus]; 6451 [image unlockFocus];
6226 #endif 6452 #endif
6227 DW_MUTEX_UNLOCK;
6228 DW_LOCAL_POOL_OUT; 6453 DW_LOCAL_POOL_OUT;
6454 DW_FUNCTION_RETURN_NOTHING;
6229 } 6455 }
6230 6456
6231 /* Query the width and height of a text string. 6457 /* Query the width and height of a text string.
6232 * Parameters: 6458 * Parameters:
6233 * handle: Handle to the window. 6459 * handle: Handle to the window.
6302 * x: X coordinate. 6528 * x: X coordinate.
6303 * y: Y coordinate. 6529 * y: Y coordinate.
6304 * width: Width of rectangle. 6530 * width: Width of rectangle.
6305 * height: Height of rectangle. 6531 * height: Height of rectangle.
6306 */ 6532 */
6307 void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y ) 6533 DW_FUNCTION_DEFINITION(dw_draw_polygon, void, HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
6308 { 6534 DW_FUNCTION_ADD_PARAM6(handle, pixmap, flags, npoints, x, y)
6309 int _locked_by_me = FALSE; 6535 DW_FUNCTION_NO_RETURN(dw_draw_polygon)
6536 DW_FUNCTION_RESTORE_PARAM6(handle, HWND, pixmap, HPIXMAP, flags, int, npoints, int, x, int *, y, int *)
6537 {
6538 DW_FUNCTION_INIT;
6310 DW_LOCAL_POOL_IN; 6539 DW_LOCAL_POOL_IN;
6311 DW_MUTEX_LOCK;
6312 id image = handle; 6540 id image = handle;
6313 NSBitmapImageRep *bi = nil; 6541 NSBitmapImageRep *bi = nil;
6542 bool bCanDraw = YES;
6314 int z; 6543 int z;
6315 6544
6316 if(pixmap) 6545 if(pixmap)
6317 bi = image = (id)pixmap->image; 6546 bi = image = (id)pixmap->image;
6318 else 6547 else
6323 DWRender *render = image; 6552 DWRender *render = image;
6324 6553
6325 bi = [render cachedDrawingRep]; 6554 bi = [render cachedDrawingRep];
6326 } 6555 }
6327 #else 6556 #else
6328 if([image lockFocusIfCanDraw] == NO) 6557 if((bCanDraw = [image lockFocusIfCanDraw]) == YES)
6329 { 6558 {
6330 DW_MUTEX_UNLOCK; 6559 _DWLastDrawable = handle;
6331 DW_LOCAL_POOL_OUT; 6560 [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
6332 return; 6561 }
6333 }
6334 [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
6335 _DWLastDrawable = handle;
6336 #endif 6562 #endif
6337 } 6563 }
6338 if(bi) 6564 if(bi)
6339 { 6565 {
6340 id gc = _create_gc(bi, flags & DW_DRAW_NOAA ? NO : YES); 6566 id gc = _create_gc(bi, flags & DW_DRAW_NOAA ? NO : YES);
6341 [NSGraphicsContext saveGraphicsState]; 6567 [NSGraphicsContext saveGraphicsState];
6342 [NSGraphicsContext setCurrentContext:gc]; 6568 [NSGraphicsContext setCurrentContext:gc];
6343 } 6569 }
6344 6570
6345 NSBezierPath* aPath = [NSBezierPath bezierPath]; 6571 if(bCanDraw == YES)
6346 NSColor *color = pthread_getspecific(_dw_fg_color_key); 6572 {
6347 [color set]; 6573 NSBezierPath* aPath = [NSBezierPath bezierPath];
6348 6574 NSColor *color = pthread_getspecific(_dw_fg_color_key);
6349 [aPath moveToPoint:NSMakePoint(*x + 0.5, *y + 0.5)]; 6575 [color set];
6350 for(z=1;z<npoints;z++) 6576
6351 { 6577 [aPath moveToPoint:NSMakePoint(*x + 0.5, *y + 0.5)];
6352 [aPath lineToPoint:NSMakePoint(x[z] + 0.5, y[z] + 0.5)]; 6578 for(z=1;z<npoints;z++)
6353 } 6579 {
6354 [aPath closePath]; 6580 [aPath lineToPoint:NSMakePoint(x[z] + 0.5, y[z] + 0.5)];
6355 if(flags & DW_DRAW_FILL) 6581 }
6356 { 6582 [aPath closePath];
6357 [aPath fill]; 6583 if(flags & DW_DRAW_FILL)
6358 } 6584 {
6359 [aPath stroke]; 6585 [aPath fill];
6586 }
6587 [aPath stroke];
6588 }
6589
6360 if(bi) 6590 if(bi)
6361 [NSGraphicsContext restoreGraphicsState]; 6591 [NSGraphicsContext restoreGraphicsState];
6362 #ifndef BUILDING_FOR_MOJAVE 6592 #ifndef BUILDING_FOR_MOJAVE
6363 if(!pixmap) 6593 if(bCanDraw == YES && !pixmap)
6364 [image unlockFocus]; 6594 [image unlockFocus];
6365 #endif 6595 #endif
6366 DW_MUTEX_UNLOCK;
6367 DW_LOCAL_POOL_OUT; 6596 DW_LOCAL_POOL_OUT;
6597 DW_FUNCTION_RETURN_NOTHING;
6368 } 6598 }
6369 6599
6370 /* Draw a rectangle on a window (preferably a render window). 6600 /* Draw a rectangle on a window (preferably a render window).
6371 * Parameters: 6601 * Parameters:
6372 * handle: Handle to the window. 6602 * handle: Handle to the window.
6375 * x: X coordinate. 6605 * x: X coordinate.
6376 * y: Y coordinate. 6606 * y: Y coordinate.
6377 * width: Width of rectangle. 6607 * width: Width of rectangle.
6378 * height: Height of rectangle. 6608 * height: Height of rectangle.
6379 */ 6609 */
6380 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height) 6610 DW_FUNCTION_DEFINITION(dw_draw_rect, void, HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
6381 { 6611 DW_FUNCTION_ADD_PARAM7(handle, pixmap, flags, x, y, width, height)
6382 int _locked_by_me = FALSE; 6612 DW_FUNCTION_NO_RETURN(dw_draw_rect)
6613 DW_FUNCTION_RESTORE_PARAM7(handle, HWND, pixmap, HPIXMAP, flags, int, x, int, y, int, width, int, height, int)
6614 {
6615 DW_FUNCTION_INIT;
6383 DW_LOCAL_POOL_IN; 6616 DW_LOCAL_POOL_IN;
6384 DW_MUTEX_LOCK;
6385 id image = handle; 6617 id image = handle;
6386 NSBitmapImageRep *bi = nil; 6618 NSBitmapImageRep *bi = nil;
6619 bool bCanDraw = YES;
6387 6620
6388 if(pixmap) 6621 if(pixmap)
6389 bi = image = (id)pixmap->image; 6622 bi = image = (id)pixmap->image;
6390 else 6623 else
6391 { 6624 {
6395 DWRender *render = image; 6628 DWRender *render = image;
6396 6629
6397 bi = [render cachedDrawingRep]; 6630 bi = [render cachedDrawingRep];
6398 } 6631 }
6399 #else 6632 #else
6400 if([image lockFocusIfCanDraw] == NO) 6633 if((bCanDraw = [image lockFocusIfCanDraw]) == YES)
6401 { 6634 {
6402 DW_MUTEX_UNLOCK; 6635 _DWLastDrawable = handle;
6403 DW_LOCAL_POOL_OUT; 6636 [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
6404 return; 6637 }
6405 }
6406 [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
6407 _DWLastDrawable = handle;
6408 #endif 6638 #endif
6409 } 6639 }
6410 if(bi) 6640 if(bi)
6411 { 6641 {
6412 id gc = _create_gc(bi, flags & DW_DRAW_NOAA ? NO : YES); 6642 id gc = _create_gc(bi, flags & DW_DRAW_NOAA ? NO : YES);
6413 [NSGraphicsContext saveGraphicsState]; 6643 [NSGraphicsContext saveGraphicsState];
6414 [NSGraphicsContext setCurrentContext:gc]; 6644 [NSGraphicsContext setCurrentContext:gc];
6415 } 6645 }
6416 6646
6417 NSColor *color = pthread_getspecific(_dw_fg_color_key); 6647 if(bCanDraw == YES)
6418 [color set]; 6648 {
6419 6649 NSColor *color = pthread_getspecific(_dw_fg_color_key);
6420 if(flags & DW_DRAW_FILL) 6650 [color set];
6421 [NSBezierPath fillRect:NSMakeRect(x, y, width, height)]; 6651
6422 else 6652 if(flags & DW_DRAW_FILL)
6423 [NSBezierPath strokeRect:NSMakeRect(x, y, width, height)]; 6653 [NSBezierPath fillRect:NSMakeRect(x, y, width, height)];
6654 else
6655 [NSBezierPath strokeRect:NSMakeRect(x, y, width, height)];
6656 }
6657
6424 if(bi) 6658 if(bi)
6425 [NSGraphicsContext restoreGraphicsState]; 6659 [NSGraphicsContext restoreGraphicsState];
6426 #ifndef BUILDING_FOR_MOJAVE 6660 #ifndef BUILDING_FOR_MOJAVE
6427 if(!pixmap) 6661 if(bCanDraw == YES && !pixmap)
6428 [image unlockFocus]; 6662 [image unlockFocus];
6429 #endif 6663 #endif
6430 DW_MUTEX_UNLOCK;
6431 DW_LOCAL_POOL_OUT; 6664 DW_LOCAL_POOL_OUT;
6665 DW_FUNCTION_RETURN_NOTHING;
6432 } 6666 }
6433 6667
6434 /* Draw an arc on a window (preferably a render window). 6668 /* Draw an arc on a window (preferably a render window).
6435 * Parameters: 6669 * Parameters:
6436 * handle: Handle to the window. 6670 * handle: Handle to the window.
6442 * x1: X coordinate of first segment of arc. 6676 * x1: X coordinate of first segment of arc.
6443 * y1: Y coordinate of first segment of arc. 6677 * y1: Y coordinate of first segment of arc.
6444 * x2: X coordinate of second segment of arc. 6678 * x2: X coordinate of second segment of arc.
6445 * y2: Y coordinate of second segment of arc. 6679 * y2: Y coordinate of second segment of arc.
6446 */ 6680 */
6447 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) 6681 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)
6448 { 6682 DW_FUNCTION_ADD_PARAM9(handle, pixmap, flags, xorigin, yorigin, x1, y1, x2, y2)
6449 int _locked_by_me = FALSE; 6683 DW_FUNCTION_NO_RETURN(dw_draw_arc)
6684 DW_FUNCTION_RESTORE_PARAM9(handle, HWND, pixmap, HPIXMAP, flags, int, xorigin, int, yorigin, int, x1, int, y1, int, x2, int, y2, int)
6685 {
6686 DW_FUNCTION_INIT;
6450 DW_LOCAL_POOL_IN; 6687 DW_LOCAL_POOL_IN;
6451 DW_MUTEX_LOCK;
6452 id image = handle; 6688 id image = handle;
6453 NSBitmapImageRep *bi = nil; 6689 NSBitmapImageRep *bi = nil;
6690 bool bCanDraw = YES;
6454 6691
6455 if(pixmap) 6692 if(pixmap)
6456 bi = image = (id)pixmap->image; 6693 bi = image = (id)pixmap->image;
6457 else 6694 else
6458 { 6695 {
6462 DWRender *render = image; 6699 DWRender *render = image;
6463 6700
6464 bi = [render cachedDrawingRep]; 6701 bi = [render cachedDrawingRep];
6465 } 6702 }
6466 #else 6703 #else
6467 if([image lockFocusIfCanDraw] == NO) 6704 if((bCanDraw = [image lockFocusIfCanDraw]) == YES)
6468 { 6705 {
6469 DW_MUTEX_UNLOCK; 6706 _DWLastDrawable = handle;
6470 DW_LOCAL_POOL_OUT; 6707 [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
6471 return; 6708 }
6472 }
6473 [[NSGraphicsContext currentContext] setShouldAntialias:(flags & DW_DRAW_NOAA ? NO : YES)];
6474 _DWLastDrawable = handle;
6475 #endif 6709 #endif
6476 } 6710 }
6477 if(bi) 6711 if(bi)
6478 { 6712 {
6479 id gc = _create_gc(bi, flags & DW_DRAW_NOAA ? NO : YES); 6713 id gc = _create_gc(bi, flags & DW_DRAW_NOAA ? NO : YES);
6480 [NSGraphicsContext saveGraphicsState]; 6714 [NSGraphicsContext saveGraphicsState];
6481 [NSGraphicsContext setCurrentContext:gc]; 6715 [NSGraphicsContext setCurrentContext:gc];
6482 } 6716 }
6483 6717
6484 NSBezierPath* aPath = [NSBezierPath bezierPath]; 6718 if(bCanDraw)
6485 NSColor *color = pthread_getspecific(_dw_fg_color_key); 6719 {
6486 [color set]; 6720 NSBezierPath* aPath = [NSBezierPath bezierPath];
6487 6721 NSColor *color = pthread_getspecific(_dw_fg_color_key);
6488 /* Special case of a full circle/oval */ 6722 [color set];
6489 if(flags & DW_DRAW_FULL) 6723
6490 { 6724 /* Special case of a full circle/oval */
6491 [aPath appendBezierPathWithOvalInRect:NSMakeRect(x1, y1, x2 - x1, y2 - y1)]; 6725 if(flags & DW_DRAW_FULL)
6492 } 6726 {
6493 else 6727 [aPath appendBezierPathWithOvalInRect:NSMakeRect(x1, y1, x2 - x1, y2 - y1)];
6494 { 6728 }
6495 double a1 = atan2((y1-yorigin), (x1-xorigin)); 6729 else
6496 double a2 = atan2((y2-yorigin), (x2-xorigin)); 6730 {
6497 double dx = xorigin - x1; 6731 double a1 = atan2((y1-yorigin), (x1-xorigin));
6498 double dy = yorigin - y1; 6732 double a2 = atan2((y2-yorigin), (x2-xorigin));
6499 double r = sqrt(dx*dx + dy*dy); 6733 double dx = xorigin - x1;
6500 6734 double dy = yorigin - y1;
6501 /* Convert to degrees */ 6735 double r = sqrt(dx*dx + dy*dy);
6502 a1 *= (180.0 / M_PI); 6736
6503 a2 *= (180.0 / M_PI); 6737 /* Convert to degrees */
6504 6738 a1 *= (180.0 / M_PI);
6505 /* Prepare to draw */ 6739 a2 *= (180.0 / M_PI);
6506 [aPath appendBezierPathWithArcWithCenter:NSMakePoint(xorigin, yorigin) 6740
6507 radius:r startAngle:a1 endAngle:a2]; 6741 /* Prepare to draw */
6508 } 6742 [aPath appendBezierPathWithArcWithCenter:NSMakePoint(xorigin, yorigin)
6509 /* If the fill flag is passed */ 6743 radius:r startAngle:a1 endAngle:a2];
6510 if(flags & DW_DRAW_FILL) 6744 }
6511 { 6745 /* If the fill flag is passed */
6512 [aPath fill]; 6746 if(flags & DW_DRAW_FILL)
6513 } 6747 {
6514 /* Actually do the drawing */ 6748 [aPath fill];
6515 [aPath stroke]; 6749 }
6750 /* Actually do the drawing */
6751 [aPath stroke];
6752 }
6753
6516 if(bi) 6754 if(bi)
6517 [NSGraphicsContext restoreGraphicsState]; 6755 [NSGraphicsContext restoreGraphicsState];
6518 #ifndef BUILDING_FOR_MOJAVE 6756 #ifndef BUILDING_FOR_MOJAVE
6519 if(!pixmap) 6757 if(bCanDraw == YES && !pixmap)
6520 [image unlockFocus]; 6758 [image unlockFocus];
6521 #endif 6759 #endif
6522 DW_MUTEX_UNLOCK;
6523 DW_LOCAL_POOL_OUT; 6760 DW_LOCAL_POOL_OUT;
6761 DW_FUNCTION_RETURN_NOTHING;
6524 } 6762 }
6525 6763
6526 /* 6764 /*
6527 * Create a tree object to be packed. 6765 * Create a tree object to be packed.
6528 * Parameters: 6766 * Parameters:
6529 * id: An ID to be used for getting the resource from the 6767 * id: An ID to be used for getting the resource from the
6530 * resource file. 6768 * resource file.
6531 */ 6769 */
6532 HWND API dw_tree_new(ULONG cid) 6770 DW_FUNCTION_DEFINITION(dw_tree_new, HWND, ULONG cid)
6533 { 6771 DW_FUNCTION_ADD_PARAM1(cid)
6534 int _locked_by_me = FALSE; 6772 DW_FUNCTION_RETURN(dw_tree_new, HWND)
6535 DW_MUTEX_LOCK; 6773 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
6774 {
6775 DW_FUNCTION_INIT;
6536 NSScrollView *scrollview = [[NSScrollView alloc] init]; 6776 NSScrollView *scrollview = [[NSScrollView alloc] init];
6537 DWTree *tree = [[DWTree alloc] init]; 6777 DWTree *tree = [[DWTree alloc] init];
6538 6778
6539 [tree setScrollview:scrollview]; 6779 [tree setScrollview:scrollview];
6540 [scrollview setBorderType:NSBezelBorder]; 6780 [scrollview setBorderType:NSBezelBorder];
6546 [tree setDelegate:tree]; 6786 [tree setDelegate:tree];
6547 [scrollview setDocumentView:tree]; 6787 [scrollview setDocumentView:tree];
6548 [tree setHeaderView:nil]; 6788 [tree setHeaderView:nil];
6549 [tree setTag:cid]; 6789 [tree setTag:cid];
6550 [tree autorelease]; 6790 [tree autorelease];
6551 DW_MUTEX_UNLOCK; 6791 DW_FUNCTION_RETURN_THIS(tree);
6552 return tree;
6553 } 6792 }
6554 6793
6555 /* 6794 /*
6556 * Inserts an item into a tree window (widget) after another item. 6795 * Inserts an item into a tree window (widget) after another item.
6557 * Parameters: 6796 * Parameters:
6560 * title: The text title of the entry. 6799 * title: The text title of the entry.
6561 * icon: Handle to coresponding icon. 6800 * icon: Handle to coresponding icon.
6562 * parent: Parent handle or 0 if root. 6801 * parent: Parent handle or 0 if root.
6563 * itemdata: Item specific data. 6802 * itemdata: Item specific data.
6564 */ 6803 */
6565 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata) 6804 DW_FUNCTION_DEFINITION(dw_tree_insert_after, HTREEITEM, HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata)
6566 { 6805 DW_FUNCTION_ADD_PARAM6(handle, item, title, icon, parent, itemdata)
6567 int _locked_by_me = FALSE; 6806 DW_FUNCTION_RETURN(dw_tree_insert_after, HTREEITEM)
6568 DW_MUTEX_LOCK; 6807 DW_FUNCTION_RESTORE_PARAM6(handle, HWND, item, HTREEITEM, title, char *, icon, HICN, parent, HTREEITEM, itemdata, void *)
6808 {
6809 DW_FUNCTION_INIT;
6569 DWTree *tree = handle; 6810 DWTree *tree = handle;
6570 NSString *nstr = [[NSString stringWithUTF8String:title] retain]; 6811 NSString *nstr = [[NSString stringWithUTF8String:title] retain];
6571 NSMutableArray *treenode = [[[NSMutableArray alloc] init] retain]; 6812 NSMutableArray *treenode = [[[NSMutableArray alloc] init] retain];
6572 if(icon) 6813 if(icon)
6573 [treenode addObject:icon]; 6814 [treenode addObject:icon];
6579 [tree addTree:treenode and:parent after:item]; 6820 [tree addTree:treenode and:parent after:item];
6580 if(parent) 6821 if(parent)
6581 [tree reloadItem:parent reloadChildren:YES]; 6822 [tree reloadItem:parent reloadChildren:YES];
6582 else 6823 else
6583 [tree reloadData]; 6824 [tree reloadData];
6584 DW_MUTEX_UNLOCK; 6825 DW_FUNCTION_RETURN_THIS(treenode);
6585 return treenode;
6586 } 6826 }
6587 6827
6588 /* 6828 /*
6589 * Inserts an item into a tree window (widget). 6829 * Inserts an item into a tree window (widget).
6590 * Parameters: 6830 * Parameters:
6603 * Gets the text an item in a tree window (widget). 6843 * Gets the text an item in a tree window (widget).
6604 * Parameters: 6844 * Parameters:
6605 * handle: Handle to the tree containing the item. 6845 * handle: Handle to the tree containing the item.
6606 * item: Handle of the item to be modified. 6846 * item: Handle of the item to be modified.
6607 */ 6847 */
6608 char * API dw_tree_get_title(HWND handle, HTREEITEM item) 6848 DW_FUNCTION_DEFINITION(dw_tree_get_title, char *, HWND handle, HTREEITEM item)
6609 { 6849 DW_FUNCTION_ADD_PARAM2(handle, item)
6610 int _locked_by_me = FALSE; 6850 DW_FUNCTION_RETURN(dw_tree_get_title, char *)
6611 DW_MUTEX_LOCK; 6851 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6852 {
6853 DW_FUNCTION_INIT;
6854 char *retval = NULL;
6612 NSMutableArray *array = (NSMutableArray *)item; 6855 NSMutableArray *array = (NSMutableArray *)item;
6613 NSString *nstr = (NSString *)[array objectAtIndex:1]; 6856 NSString *nstr = (NSString *)[array objectAtIndex:1];
6614 DW_MUTEX_UNLOCK; 6857 retval = strdup([nstr UTF8String]);
6615 return strdup([nstr UTF8String]); 6858 DW_FUNCTION_RETURN_THIS(retval);
6616 } 6859 }
6617 6860
6618 /* 6861 /*
6619 * Gets the text an item in a tree window (widget). 6862 * Gets the text an item in a tree window (widget).
6620 * Parameters: 6863 * Parameters:
6621 * handle: Handle to the tree containing the item. 6864 * handle: Handle to the tree containing the item.
6622 * item: Handle of the item to be modified. 6865 * item: Handle of the item to be modified.
6623 */ 6866 */
6624 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item) 6867 DW_FUNCTION_DEFINITION(dw_tree_get_parent, HTREEITEM, HWND handle, HTREEITEM item)
6625 { 6868 DW_FUNCTION_ADD_PARAM2(handle, item)
6626 int _locked_by_me = FALSE; 6869 DW_FUNCTION_RETURN(dw_tree_get_parent, HTREEITEM)
6870 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6871 {
6872 DW_FUNCTION_INIT;
6627 HTREEITEM parent; 6873 HTREEITEM parent;
6628 DWTree *tree = handle; 6874 DWTree *tree = handle;
6629 6875
6630 DW_MUTEX_LOCK;
6631 parent = [tree parentForItem:item]; 6876 parent = [tree parentForItem:item];
6632 DW_MUTEX_UNLOCK; 6877 DW_FUNCTION_RETURN_THIS(parent);
6633 return parent;
6634 } 6878 }
6635 6879
6636 /* 6880 /*
6637 * Sets the text and icon of an item in a tree window (widget). 6881 * Sets the text and icon of an item in a tree window (widget).
6638 * Parameters: 6882 * Parameters:
6639 * handle: Handle to the tree containing the item. 6883 * handle: Handle to the tree containing the item.
6640 * item: Handle of the item to be modified. 6884 * item: Handle of the item to be modified.
6641 * title: The text title of the entry. 6885 * title: The text title of the entry.
6642 * icon: Handle to coresponding icon. 6886 * icon: Handle to coresponding icon.
6643 */ 6887 */
6644 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon) 6888 DW_FUNCTION_DEFINITION(dw_tree_item_change, void, HWND handle, HTREEITEM item, char *title, HICN icon)
6645 { 6889 DW_FUNCTION_ADD_PARAM4(handle, item, title, icon)
6646 int _locked_by_me = FALSE; 6890 DW_FUNCTION_NO_RETURN(dw_tree_item_change)
6647 DW_MUTEX_LOCK; 6891 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, item, HTREEITEM, title, char *, icon, HICN)
6892 {
6893 DW_FUNCTION_INIT;
6648 DWTree *tree = handle; 6894 DWTree *tree = handle;
6649 NSMutableArray *array = (NSMutableArray *)item; 6895 NSMutableArray *array = (NSMutableArray *)item;
6650 DW_LOCAL_POOL_IN; 6896 DW_LOCAL_POOL_IN;
6651 6897
6652 if(title) 6898 if(title)
6660 { 6906 {
6661 [array replaceObjectAtIndex:0 withObject:icon]; 6907 [array replaceObjectAtIndex:0 withObject:icon];
6662 } 6908 }
6663 [tree reloadData]; 6909 [tree reloadData];
6664 DW_LOCAL_POOL_OUT; 6910 DW_LOCAL_POOL_OUT;
6665 DW_MUTEX_UNLOCK; 6911 DW_FUNCTION_RETURN_NOTHING;
6666 } 6912 }
6667 6913
6668 /* 6914 /*
6669 * Sets the item data of a tree item. 6915 * Sets the item data of a tree item.
6670 * Parameters: 6916 * Parameters:
6671 * handle: Handle to the tree containing the item. 6917 * handle: Handle to the tree containing the item.
6672 * item: Handle of the item to be modified. 6918 * item: Handle of the item to be modified.
6673 * itemdata: User defined data to be associated with item. 6919 * itemdata: User defined data to be associated with item.
6674 */ 6920 */
6675 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata) 6921 DW_FUNCTION_DEFINITION(dw_tree_item_set_data, void, HWND handle, HTREEITEM item, void *itemdata)
6676 { 6922 DW_FUNCTION_ADD_PARAM3(handle, item, itemdata)
6677 int _locked_by_me = FALSE; 6923 DW_FUNCTION_NO_RETURN(dw_tree_item_set_data)
6678 DW_MUTEX_LOCK; 6924 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, item, HTREEITEM, itemdata, void *)
6925 {
6926 DW_FUNCTION_INIT;
6679 NSMutableArray *array = (NSMutableArray *)item; 6927 NSMutableArray *array = (NSMutableArray *)item;
6680 [array replaceObjectAtIndex:2 withObject:[NSValue valueWithPointer:itemdata]]; 6928 [array replaceObjectAtIndex:2 withObject:[NSValue valueWithPointer:itemdata]];
6681 DW_MUTEX_UNLOCK; 6929 DW_FUNCTION_RETURN_NOTHING;
6682 } 6930 }
6683 6931
6684 /* 6932 /*
6685 * Gets the item data of a tree item. 6933 * Gets the item data of a tree item.
6686 * Parameters: 6934 * Parameters:
6687 * handle: Handle to the tree containing the item. 6935 * handle: Handle to the tree containing the item.
6688 * item: Handle of the item to be modified. 6936 * item: Handle of the item to be modified.
6689 */ 6937 */
6690 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item) 6938 DW_FUNCTION_DEFINITION(dw_tree_item_get_data, void *, HWND handle, HTREEITEM item)
6691 { 6939 DW_FUNCTION_ADD_PARAM2(handle, item)
6692 int _locked_by_me = FALSE; 6940 DW_FUNCTION_RETURN(dw_tree_item_get_data, void *)
6941 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6942 {
6943 DW_FUNCTION_INIT;
6693 void *result = NULL; 6944 void *result = NULL;
6694 DW_MUTEX_LOCK;
6695 NSMutableArray *array = (NSMutableArray *)item; 6945 NSMutableArray *array = (NSMutableArray *)item;
6696 NSValue *value = [array objectAtIndex:2]; 6946 NSValue *value = [array objectAtIndex:2];
6697 if(value) 6947 if(value)
6698 {
6699 result = [value pointerValue]; 6948 result = [value pointerValue];
6700 } 6949 DW_FUNCTION_RETURN_THIS(result);
6701 DW_MUTEX_UNLOCK;
6702 return result;
6703 } 6950 }
6704 6951
6705 /* 6952 /*
6706 * Sets this item as the active selection. 6953 * Sets this item as the active selection.
6707 * Parameters: 6954 * Parameters:
6708 * handle: Handle to the tree window (widget) to be selected. 6955 * handle: Handle to the tree window (widget) to be selected.
6709 * item: Handle to the item to be selected. 6956 * item: Handle to the item to be selected.
6710 */ 6957 */
6711 void API dw_tree_item_select(HWND handle, HTREEITEM item) 6958 DW_FUNCTION_DEFINITION(dw_tree_item_select, void, HWND handle, HTREEITEM item)
6712 { 6959 DW_FUNCTION_ADD_PARAM2(handle, item)
6713 int _locked_by_me = FALSE; 6960 DW_FUNCTION_NO_RETURN(dw_tree_item_select)
6714 DW_MUTEX_LOCK; 6961 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6962 {
6963 DW_FUNCTION_INIT;
6715 DWTree *tree = handle; 6964 DWTree *tree = handle;
6716 NSInteger itemIndex = [tree rowForItem:item]; 6965 NSInteger itemIndex = [tree rowForItem:item];
6717 if(itemIndex > -1) 6966 if(itemIndex > -1)
6718 { 6967 {
6719 [tree selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO]; 6968 [tree selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO];
6720 } 6969 }
6721 DW_MUTEX_UNLOCK; 6970 DW_FUNCTION_RETURN_NOTHING;
6722 } 6971 }
6723 6972
6724 /* 6973 /*
6725 * Removes all nodes from a tree. 6974 * Removes all nodes from a tree.
6726 * Parameters: 6975 * Parameters:
6727 * handle: Handle to the window (widget) to be cleared. 6976 * handle: Handle to the window (widget) to be cleared.
6728 */ 6977 */
6729 void API dw_tree_clear(HWND handle) 6978 DW_FUNCTION_DEFINITION(dw_tree_clear, void, HWND handle)
6730 { 6979 DW_FUNCTION_ADD_PARAM1(handle)
6731 int _locked_by_me = FALSE; 6980 DW_FUNCTION_NO_RETURN(dw_tree_clear)
6732 DW_MUTEX_LOCK; 6981 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
6982 {
6983 DW_FUNCTION_INIT;
6733 DWTree *tree = handle; 6984 DWTree *tree = handle;
6734 [tree clear]; 6985 [tree clear];
6735 DW_MUTEX_UNLOCK; 6986 DW_FUNCTION_RETURN_NOTHING;
6736 } 6987 }
6737 6988
6738 /* 6989 /*
6739 * Expands a node on a tree. 6990 * Expands a node on a tree.
6740 * Parameters: 6991 * Parameters:
6741 * handle: Handle to the tree window (widget). 6992 * handle: Handle to the tree window (widget).
6742 * item: Handle to node to be expanded. 6993 * item: Handle to node to be expanded.
6743 */ 6994 */
6744 void API dw_tree_item_expand(HWND handle, HTREEITEM item) 6995 DW_FUNCTION_DEFINITION(dw_tree_item_expand, void, HWND handle, HTREEITEM item)
6745 { 6996 DW_FUNCTION_ADD_PARAM2(handle, item)
6746 int _locked_by_me = FALSE; 6997 DW_FUNCTION_NO_RETURN(dw_tree_item_expand)
6747 DW_MUTEX_LOCK; 6998 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6999 {
7000 DW_FUNCTION_INIT;
6748 DWTree *tree = handle; 7001 DWTree *tree = handle;
6749 [tree expandItem:item]; 7002 [tree expandItem:item];
6750 DW_MUTEX_UNLOCK; 7003 DW_FUNCTION_RETURN_NOTHING;
6751 } 7004 }
6752 7005
6753 /* 7006 /*
6754 * Collapses a node on a tree. 7007 * Collapses a node on a tree.
6755 * Parameters: 7008 * Parameters:
6756 * handle: Handle to the tree window (widget). 7009 * handle: Handle to the tree window (widget).
6757 * item: Handle to node to be collapsed. 7010 * item: Handle to node to be collapsed.
6758 */ 7011 */
6759 void API dw_tree_item_collapse(HWND handle, HTREEITEM item) 7012 DW_FUNCTION_DEFINITION(dw_tree_item_collapse, void, HWND handle, HTREEITEM item)
6760 { 7013 DW_FUNCTION_ADD_PARAM2(handle, item)
6761 int _locked_by_me = FALSE; 7014 DW_FUNCTION_NO_RETURN(dw_tree_item_collapse)
6762 DW_MUTEX_LOCK; 7015 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
7016 {
7017 DW_FUNCTION_INIT;
6763 DWTree *tree = handle; 7018 DWTree *tree = handle;
6764 [tree collapseItem:item]; 7019 [tree collapseItem:item];
6765 DW_MUTEX_UNLOCK; 7020 DW_FUNCTION_RETURN_NOTHING;
6766 } 7021 }
6767 7022
6768 /* 7023 /*
6769 * Removes a node from a tree. 7024 * Removes a node from a tree.
6770 * Parameters: 7025 * Parameters:
6771 * handle: Handle to the window (widget) to be cleared. 7026 * handle: Handle to the window (widget) to be cleared.
6772 * item: Handle to node to be deleted. 7027 * item: Handle to node to be deleted.
6773 */ 7028 */
6774 void API dw_tree_item_delete(HWND handle, HTREEITEM item) 7029 DW_FUNCTION_DEFINITION(dw_tree_item_delete, void, HWND handle, HTREEITEM item)
6775 { 7030 DW_FUNCTION_ADD_PARAM2(handle, item)
6776 int _locked_by_me = FALSE; 7031 DW_FUNCTION_NO_RETURN(dw_tree_item_delete)
6777 DW_MUTEX_LOCK; 7032 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
7033 {
7034 DW_FUNCTION_INIT;
6778 DWTree *tree = handle; 7035 DWTree *tree = handle;
6779 [tree deleteNode:item]; 7036 [tree deleteNode:item];
6780 [tree reloadData]; 7037 [tree reloadData];
6781 DW_MUTEX_UNLOCK; 7038 DW_FUNCTION_RETURN_NOTHING;
6782 } 7039 }
6783 7040
6784 /* 7041 /*
6785 * Create a container object to be packed. 7042 * Create a container object to be packed.
6786 * Parameters: 7043 * Parameters:
6787 * id: An ID to be used for getting the resource from the 7044 * id: An ID to be used for getting the resource from the
6788 * resource file. 7045 * resource file.
6789 */ 7046 */
6790 HWND API dw_container_new(ULONG cid, int multi) 7047 DW_FUNCTION_DEFINITION(dw_container_new, HWND, ULONG cid, int multi)
6791 { 7048 DW_FUNCTION_ADD_PARAM2(cid, multi)
6792 int _locked_by_me = FALSE; 7049 DW_FUNCTION_RETURN(dw_container_new, HWND)
6793 DW_MUTEX_LOCK; 7050 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int)
7051 {
7052 DW_FUNCTION_INIT;
6794 DWContainer *cont = _cont_new(cid, multi); 7053 DWContainer *cont = _cont_new(cid, multi);
6795 NSScrollView *scrollview = [cont scrollview]; 7054 NSScrollView *scrollview = [cont scrollview];
6796 [scrollview setHasHorizontalScroller:YES]; 7055 [scrollview setHasHorizontalScroller:YES];
6797 NSTableHeaderView *header = [[[NSTableHeaderView alloc] init] autorelease]; 7056 NSTableHeaderView *header = [[[NSTableHeaderView alloc] init] autorelease];
6798 [cont setHeaderView:header]; 7057 [cont setHeaderView:header];
6799 [cont setTarget:cont]; 7058 [cont setTarget:cont];
6800 [cont setDoubleAction:@selector(doubleClicked:)]; 7059 [cont setDoubleAction:@selector(doubleClicked:)];
6801 DW_MUTEX_UNLOCK; 7060 DW_FUNCTION_RETURN_THIS(cont);
6802 return cont;
6803 } 7061 }
6804 7062
6805 /* 7063 /*
6806 * Sets up the container columns. 7064 * Sets up the container columns.
6807 * Parameters: 7065 * Parameters:
6810 * titles: An array of strings with column text titles. 7068 * titles: An array of strings with column text titles.
6811 * count: The number of columns (this should match the arrays). 7069 * count: The number of columns (this should match the arrays).
6812 * separator: The column number that contains the main separator. 7070 * separator: The column number that contains the main separator.
6813 * (this item may only be used in OS/2) 7071 * (this item may only be used in OS/2)
6814 */ 7072 */
6815 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) 7073 DW_FUNCTION_DEFINITION(dw_container_setup, int, HWND handle, unsigned long *flags, char **titles, int count, int separator)
6816 { 7074 DW_FUNCTION_ADD_PARAM5(handle, flags, titles, count, separator)
6817 int _locked_by_me = FALSE; 7075 DW_FUNCTION_RETURN(dw_container_setup, int)
6818 DW_MUTEX_LOCK; 7076 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, flags, unsigned long *, titles, char **, count, int, separator, int)
6819 int z; 7077 {
7078 DW_FUNCTION_INIT;
7079 int z, retval = DW_ERROR_NONE;
6820 DWContainer *cont = handle; 7080 DWContainer *cont = handle;
6821 7081
6822 [cont setup]; 7082 [cont setup];
6823 7083
6824 for(z=0;z<count;z++) 7084 for(z=0;z<count;z++)
6851 [column setEditable:NO]; 7111 [column setEditable:NO];
6852 [cont addTableColumn:column]; 7112 [cont addTableColumn:column];
6853 [cont addColumn:column andType:(int)flags[z]]; 7113 [cont addColumn:column andType:(int)flags[z]];
6854 [column release]; 7114 [column release];
6855 } 7115 }
6856 DW_MUTEX_UNLOCK; 7116 DW_FUNCTION_RETURN_THIS(retval);
6857 return DW_ERROR_NONE;
6858 } 7117 }
6859 7118
6860 /* 7119 /*
6861 * Configures the main filesystem columnn title for localization. 7120 * Configures the main filesystem columnn title for localization.
6862 * Parameters: 7121 * Parameters:
6909 * Allocates memory used to populate a container. 7168 * Allocates memory used to populate a container.
6910 * Parameters: 7169 * Parameters:
6911 * handle: Handle to the container window (widget). 7170 * handle: Handle to the container window (widget).
6912 * rowcount: The number of items to be populated. 7171 * rowcount: The number of items to be populated.
6913 */ 7172 */
6914 void * API dw_container_alloc(HWND handle, int rowcount) 7173 DW_FUNCTION_DEFINITION(dw_container_alloc, void *, HWND handle, int rowcount)
6915 { 7174 DW_FUNCTION_ADD_PARAM2(handle, rowcount)
6916 int _locked_by_me = FALSE; 7175 DW_FUNCTION_RETURN(dw_container_alloc, void *)
6917 DW_MUTEX_LOCK; 7176 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, rowcount, int)
7177 {
7178 DW_FUNCTION_INIT;
6918 DWContainer *cont = handle; 7179 DWContainer *cont = handle;
6919 [cont addRows:rowcount]; 7180 [cont addRows:rowcount];
6920 DW_MUTEX_UNLOCK; 7181 DW_FUNCTION_RETURN_THIS(cont);
6921 return cont;
6922 } 7182 }
6923 7183
6924 /* 7184 /*
6925 * Sets an item in specified row and column to the given data. 7185 * Sets an item in specified row and column to the given data.
6926 * Parameters: 7186 * Parameters:
6928 * pointer: Pointer to the allocated memory in dw_container_alloc(). 7188 * pointer: Pointer to the allocated memory in dw_container_alloc().
6929 * column: Zero based column of data being set. 7189 * column: Zero based column of data being set.
6930 * row: Zero based row of data being set. 7190 * row: Zero based row of data being set.
6931 * data: Pointer to the data to be added. 7191 * data: Pointer to the data to be added.
6932 */ 7192 */
6933 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) 7193 DW_FUNCTION_DEFINITION(dw_container_set_item, void, HWND handle, void *pointer, int column, int row, void *data)
6934 { 7194 DW_FUNCTION_ADD_PARAM5(handle, pointer, column, row, data)
6935 int _locked_by_me = FALSE; 7195 DW_FUNCTION_NO_RETURN(dw_container_set_item)
6936 DW_MUTEX_LOCK; 7196 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pointer, void *, column, int, row, int, data, void *)
7197 {
7198 DW_FUNCTION_INIT;
6937 DWContainer *cont = handle; 7199 DWContainer *cont = handle;
6938 id object = nil; 7200 id object = nil;
6939 int type = [cont cellType:column]; 7201 int type = [cont cellType:column];
6940 int lastadd = 0; 7202 int lastadd = 0;
6941 7203
6995 } 7257 }
6996 } 7258 }
6997 7259
6998 [cont editCell:object at:(row+lastadd) and:column]; 7260 [cont editCell:object at:(row+lastadd) and:column];
6999 [cont setNeedsDisplay:YES]; 7261 [cont setNeedsDisplay:YES];
7000 DW_MUTEX_UNLOCK; 7262 DW_FUNCTION_RETURN_NOTHING;
7001 } 7263 }
7002 7264
7003 /* 7265 /*
7004 * Changes an existing item in specified row and column to the given data. 7266 * Changes an existing item in specified row and column to the given data.
7005 * Parameters: 7267 * Parameters:
7047 * pointer: Pointer to the allocated memory in dw_container_alloc(). 7309 * pointer: Pointer to the allocated memory in dw_container_alloc().
7048 * column: Zero based column of data being set. 7310 * column: Zero based column of data being set.
7049 * row: Zero based row of data being set. 7311 * row: Zero based row of data being set.
7050 * data: Pointer to the data to be added. 7312 * data: Pointer to the data to be added.
7051 */ 7313 */
7052 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon) 7314 DW_FUNCTION_DEFINITION(dw_filesystem_set_file, void, HWND handle, void *pointer, int row, char *filename, HICN icon)
7053 { 7315 DW_FUNCTION_ADD_PARAM5(handle, pointer, row, filename, icon)
7054 int _locked_by_me = FALSE; 7316 DW_FUNCTION_NO_RETURN(dw_filesystem_set_file)
7055 DW_MUTEX_LOCK; 7317 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pointer, void *, row, int, filename, char *, icon, HICN)
7318 {
7319 DW_FUNCTION_INIT;
7056 DWContainer *cont = handle; 7320 DWContainer *cont = handle;
7057 DWImageAndTextCell *browsercell; 7321 DWImageAndTextCell *browsercell;
7058 int lastadd = 0; 7322 int lastadd = 0;
7059 7323
7060 /* If pointer is NULL we are getting a change request instead of set */ 7324 /* If pointer is NULL we are getting a change request instead of set */
7066 browsercell = [[[DWImageAndTextCell alloc] init] autorelease]; 7330 browsercell = [[[DWImageAndTextCell alloc] init] autorelease];
7067 [browsercell setImage:icon]; 7331 [browsercell setImage:icon];
7068 [browsercell setStringValue:[ NSString stringWithUTF8String:filename ]]; 7332 [browsercell setStringValue:[ NSString stringWithUTF8String:filename ]];
7069 [cont editCell:browsercell at:(row+lastadd) and:0]; 7333 [cont editCell:browsercell at:(row+lastadd) and:0];
7070 [cont setNeedsDisplay:YES]; 7334 [cont setNeedsDisplay:YES];
7071 DW_MUTEX_UNLOCK; 7335 DW_FUNCTION_RETURN_NOTHING;
7072 } 7336 }
7073 7337
7074 /* 7338 /*
7075 * Sets an item in specified row and column to the given data. 7339 * Sets an item in specified row and column to the given data.
7076 * Parameters: 7340 * Parameters:
7089 * Gets column type for a container column 7353 * Gets column type for a container column
7090 * Parameters: 7354 * Parameters:
7091 * handle: Handle to the container window (widget). 7355 * handle: Handle to the container window (widget).
7092 * column: Zero based column. 7356 * column: Zero based column.
7093 */ 7357 */
7094 int API dw_container_get_column_type(HWND handle, int column) 7358 DW_FUNCTION_DEFINITION(dw_container_get_column_type, int, HWND handle, int column)
7095 { 7359 DW_FUNCTION_ADD_PARAM2(handle, column)
7096 int _locked_by_me = FALSE; 7360 DW_FUNCTION_RETURN(dw_container_get_column_type, int)
7097 DW_MUTEX_LOCK; 7361 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, column, int)
7362 {
7363 DW_FUNCTION_INIT;
7098 DWContainer *cont = handle; 7364 DWContainer *cont = handle;
7099 int rc; 7365 int rc;
7100 int flag = [cont cellType:column]; 7366 int flag = [cont cellType:column];
7101 if(flag & DW_CFA_BITMAPORICON) 7367 if(flag & DW_CFA_BITMAPORICON)
7102 rc = DW_CFA_BITMAPORICON; 7368 rc = DW_CFA_BITMAPORICON;
7108 rc = DW_CFA_DATE; 7374 rc = DW_CFA_DATE;
7109 else if(flag & DW_CFA_TIME) 7375 else if(flag & DW_CFA_TIME)
7110 rc = DW_CFA_TIME; 7376 rc = DW_CFA_TIME;
7111 else 7377 else
7112 rc = 0; 7378 rc = 0;
7113 DW_MUTEX_UNLOCK; 7379 DW_FUNCTION_RETURN_THIS(rc);
7114 return rc;
7115 } 7380 }
7116 7381
7117 /* 7382 /*
7118 * Gets column type for a filesystem container column 7383 * Gets column type for a filesystem container column
7119 * Parameters: 7384 * Parameters:
7132 * oddcolor: Odd row background color in DW_RGB format or a default color index. 7397 * oddcolor: Odd row background color in DW_RGB format or a default color index.
7133 * evencolor: Even row background color in DW_RGB format or a default color index. 7398 * evencolor: Even row background color in DW_RGB format or a default color index.
7134 * DW_RGB_TRANSPARENT will disable coloring rows. 7399 * DW_RGB_TRANSPARENT will disable coloring rows.
7135 * DW_CLR_DEFAULT will use the system default alternating row colors. 7400 * DW_CLR_DEFAULT will use the system default alternating row colors.
7136 */ 7401 */
7137 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor) 7402 DW_FUNCTION_DEFINITION(dw_container_set_stripe, void, HWND handle, unsigned long oddcolor, unsigned long evencolor)
7138 { 7403 DW_FUNCTION_ADD_PARAM3(handle, oddcolor, evencolor)
7139 int _locked_by_me = FALSE; 7404 DW_FUNCTION_NO_RETURN(dw_container_set_stripe)
7140 DW_MUTEX_LOCK; 7405 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, oddcolor, unsigned long, evencolor, unsigned long)
7406 {
7407 DW_FUNCTION_INIT;
7141 DWContainer *cont = handle; 7408 DWContainer *cont = handle;
7142 [cont setRowBgOdd:(oddcolor == DW_CLR_DEFAULT ? DW_RGB(230,230,230) : oddcolor) 7409 [cont setRowBgOdd:(oddcolor == DW_CLR_DEFAULT ? DW_RGB(230,230,230) : oddcolor)
7143 andEven:(evencolor == DW_CLR_DEFAULT ? DW_RGB_TRANSPARENT : evencolor)]; 7410 andEven:(evencolor == DW_CLR_DEFAULT ? DW_RGB_TRANSPARENT : evencolor)];
7144 DW_MUTEX_UNLOCK; 7411 DW_FUNCTION_RETURN_NOTHING;
7145 } 7412 }
7146 7413
7147 /* 7414 /*
7148 * Sets the width of a column in the container. 7415 * Sets the width of a column in the container.
7149 * Parameters: 7416 * Parameters:
7150 * handle: Handle to window (widget) of container. 7417 * handle: Handle to window (widget) of container.
7151 * column: Zero based column of width being set. 7418 * column: Zero based column of width being set.
7152 * width: Width of column in pixels. 7419 * width: Width of column in pixels.
7153 */ 7420 */
7154 void API dw_container_set_column_width(HWND handle, int column, int width) 7421 DW_FUNCTION_DEFINITION(dw_container_set_column_width, void, HWND handle, int column, int width)
7155 { 7422 DW_FUNCTION_ADD_PARAM3(handle, column, width)
7156 int _locked_by_me = FALSE; 7423 DW_FUNCTION_NO_RETURN(dw_container_set_column_width)
7157 DW_MUTEX_LOCK; 7424 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, column, int, width, int)
7425 {
7426 DW_FUNCTION_INIT;
7158 DWContainer *cont = handle; 7427 DWContainer *cont = handle;
7159 if([cont filesystem]) 7428 if([cont filesystem])
7160 {
7161 column++; 7429 column++;
7162 }
7163 NSTableColumn *col = [cont getColumn:column]; 7430 NSTableColumn *col = [cont getColumn:column];
7164 7431
7165 [col setWidth:width]; 7432 [col setWidth:width];
7166 DW_MUTEX_UNLOCK; 7433 DW_FUNCTION_RETURN_NOTHING;
7167 } 7434 }
7168 7435
7169 /* 7436 /*
7170 * Sets the title of a row in the container. 7437 * Sets the title of a row in the container.
7171 * Parameters: 7438 * Parameters:
7172 * pointer: Pointer to the allocated memory in dw_container_alloc(). 7439 * pointer: Pointer to the allocated memory in dw_container_alloc().
7173 * row: Zero based row of data being set. 7440 * row: Zero based row of data being set.
7174 * title: String title of the item. 7441 * title: String title of the item.
7175 */ 7442 */
7176 void API dw_container_set_row_title(void *pointer, int row, char *title) 7443 DW_FUNCTION_DEFINITION(dw_container_set_row_title, void, void *pointer, int row, char *title)
7177 { 7444 DW_FUNCTION_ADD_PARAM3(pointer, row, title)
7178 int _locked_by_me = FALSE; 7445 DW_FUNCTION_NO_RETURN(dw_container_set_row_title)
7179 DW_MUTEX_LOCK; 7446 DW_FUNCTION_RESTORE_PARAM3(pointer, void *, row, int, title, char *)
7447 {
7448 DW_FUNCTION_INIT;
7180 DWContainer *cont = pointer; 7449 DWContainer *cont = pointer;
7181 int lastadd = [cont lastAddPoint]; 7450 int lastadd = [cont lastAddPoint];
7182 [cont setRow:(row+lastadd) title:title]; 7451 [cont setRow:(row+lastadd) title:title];
7183 DW_MUTEX_UNLOCK; 7452 DW_FUNCTION_RETURN_NOTHING;
7184 } 7453 }
7185 7454
7186 7455
7187 /* 7456 /*
7188 * Sets the data pointer of a row in the container. 7457 * Sets the data pointer of a row in the container.
7189 * Parameters: 7458 * Parameters:
7190 * pointer: Pointer to the allocated memory in dw_container_alloc(). 7459 * pointer: Pointer to the allocated memory in dw_container_alloc().
7191 * row: Zero based row of data being set. 7460 * row: Zero based row of data being set.
7192 * data: Data pointer. 7461 * data: Data pointer.
7193 */ 7462 */
7194 void API dw_container_set_row_data(void *pointer, int row, void *data) 7463 DW_FUNCTION_DEFINITION(dw_container_set_row_data, void, void *pointer, int row, void *data)
7195 { 7464 DW_FUNCTION_ADD_PARAM3(pointer, row, data)
7196 int _locked_by_me = FALSE; 7465 DW_FUNCTION_NO_RETURN(dw_container_set_row_data)
7197 DW_MUTEX_LOCK; 7466 DW_FUNCTION_RESTORE_PARAM3(pointer, void *, row, int, data, void *)
7467 {
7468 DW_FUNCTION_INIT;
7198 DWContainer *cont = pointer; 7469 DWContainer *cont = pointer;
7199 int lastadd = [cont lastAddPoint]; 7470 int lastadd = [cont lastAddPoint];
7200 [cont setRowData:(row+lastadd) title:data]; 7471 [cont setRowData:(row+lastadd) title:data];
7201 DW_MUTEX_UNLOCK; 7472 DW_FUNCTION_RETURN_NOTHING;
7202 } 7473 }
7203 7474
7204 7475
7205 /* 7476 /*
7206 * Sets the title of a row in the container. 7477 * Sets the title of a row in the container.
7207 * Parameters: 7478 * Parameters:
7208 * handle: Handle to window (widget) of container. 7479 * handle: Handle to window (widget) of container.
7209 * row: Zero based row of data being set. 7480 * row: Zero based row of data being set.
7210 * title: String title of the item. 7481 * title: String title of the item.
7211 */ 7482 */
7212 void API dw_container_change_row_title(HWND handle, int row, char *title) 7483 DW_FUNCTION_DEFINITION(dw_container_change_row_title, void, HWND handle, int row, char *title)
7213 { 7484 DW_FUNCTION_ADD_PARAM3(handle, row, title)
7214 int _locked_by_me = FALSE; 7485 DW_FUNCTION_NO_RETURN(dw_container_change_row_title)
7215 DW_MUTEX_LOCK; 7486 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, row, int, title, char *)
7487 {
7488 DW_FUNCTION_INIT;
7216 DWContainer *cont = handle; 7489 DWContainer *cont = handle;
7217 [cont setRow:row title:title]; 7490 [cont setRow:row title:title];
7218 DW_MUTEX_UNLOCK; 7491 DW_FUNCTION_RETURN_NOTHING;
7219 } 7492 }
7220 7493
7221 /* 7494 /*
7222 * Sets the data pointer of a row in the container. 7495 * Sets the data pointer of a row in the container.
7223 * Parameters: 7496 * Parameters:
7224 * handle: Handle to window (widget) of container. 7497 * handle: Handle to window (widget) of container.
7225 * row: Zero based row of data being set. 7498 * row: Zero based row of data being set.
7226 * data: Data pointer. 7499 * data: Data pointer.
7227 */ 7500 */
7228 void API dw_container_change_row_data(HWND handle, int row, void *data) 7501 DW_FUNCTION_DEFINITION(dw_container_change_row_data, void, HWND handle, int row, void *data)
7229 { 7502 DW_FUNCTION_ADD_PARAM3(handle, row, data)
7230 int _locked_by_me = FALSE; 7503 DW_FUNCTION_NO_RETURN(dw_container_change_row_data)
7231 DW_MUTEX_LOCK; 7504 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, row, int, data, void *)
7505 {
7506 DW_FUNCTION_INIT;
7232 DWContainer *cont = handle; 7507 DWContainer *cont = handle;
7233 [cont setRowData:row title:data]; 7508 [cont setRowData:row title:data];
7234 DW_MUTEX_UNLOCK; 7509 DW_FUNCTION_RETURN_NOTHING;
7235 } 7510 }
7236 7511
7237 /* 7512 /*
7238 * Sets the title of a row in the container. 7513 * Sets the title of a row in the container.
7239 * Parameters: 7514 * Parameters:
7240 * handle: Handle to the container window (widget). 7515 * handle: Handle to the container window (widget).
7241 * pointer: Pointer to the allocated memory in dw_container_alloc(). 7516 * pointer: Pointer to the allocated memory in dw_container_alloc().
7242 * rowcount: The number of rows to be inserted. 7517 * rowcount: The number of rows to be inserted.
7243 */ 7518 */
7244 void API dw_container_insert(HWND handle, void *pointer, int rowcount) 7519 DW_FUNCTION_DEFINITION(dw_container_insert, void, HWND handle, void *pointer, int rowcount)
7245 { 7520 DW_FUNCTION_ADD_PARAM3(handle, pointer, rowcount)
7246 int _locked_by_me = FALSE; 7521 DW_FUNCTION_NO_RETURN(dw_container_insert)
7247 DW_MUTEX_LOCK; 7522 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, pointer, void *, rowcount, int)
7523 {
7524 DW_FUNCTION_INIT;
7248 DWContainer *cont = handle; 7525 DWContainer *cont = handle;
7249 [cont reloadData]; 7526 [cont reloadData];
7250 DW_MUTEX_UNLOCK; 7527 DW_FUNCTION_RETURN_NOTHING;
7251 } 7528 }
7252 7529
7253 /* 7530 /*
7254 * Removes all rows from a container. 7531 * Removes all rows from a container.
7255 * Parameters: 7532 * Parameters:
7256 * handle: Handle to the window (widget) to be cleared. 7533 * handle: Handle to the window (widget) to be cleared.
7257 * redraw: TRUE to cause the container to redraw immediately. 7534 * redraw: TRUE to cause the container to redraw immediately.
7258 */ 7535 */
7259 void API dw_container_clear(HWND handle, int redraw) 7536 DW_FUNCTION_DEFINITION(dw_container_clear, void, HWND handle, int redraw)
7260 { 7537 DW_FUNCTION_ADD_PARAM2(handle, redraw)
7261 int _locked_by_me = FALSE; 7538 DW_FUNCTION_NO_RETURN(dw_container_clear)
7262 DW_MUTEX_LOCK; 7539 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, redraw, int)
7540 {
7541 DW_FUNCTION_INIT;
7263 DWContainer *cont = handle; 7542 DWContainer *cont = handle;
7264 [cont clear]; 7543 [cont clear];
7265 if(redraw) 7544 if(redraw)
7266 {
7267 [cont reloadData]; 7545 [cont reloadData];
7268 } 7546 DW_FUNCTION_RETURN_NOTHING;
7269 DW_MUTEX_UNLOCK;
7270 } 7547 }
7271 7548
7272 /* 7549 /*
7273 * Removes the first x rows from a container. 7550 * Removes the first x rows from a container.
7274 * Parameters: 7551 * Parameters:
7275 * handle: Handle to the window (widget) to be deleted from. 7552 * handle: Handle to the window (widget) to be deleted from.
7276 * rowcount: The number of rows to be deleted. 7553 * rowcount: The number of rows to be deleted.
7277 */ 7554 */
7278 void API dw_container_delete(HWND handle, int rowcount) 7555 DW_FUNCTION_DEFINITION(dw_container_delete, void, HWND handle, int rowcount)
7279 { 7556 DW_FUNCTION_ADD_PARAM2(handle, rowcount)
7280 int _locked_by_me = FALSE; 7557 DW_FUNCTION_NO_RETURN(dw_container_delete)
7281 DW_MUTEX_LOCK; 7558 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, rowcount, int)
7559 {
7560 DW_FUNCTION_INIT;
7282 DWContainer *cont = handle; 7561 DWContainer *cont = handle;
7283 int x; 7562 int x;
7284 7563
7285 for(x=0;x<rowcount;x++) 7564 for(x=0;x<rowcount;x++)
7286 { 7565 {
7287 [cont removeRow:0]; 7566 [cont removeRow:0];
7288 } 7567 }
7289 [cont reloadData]; 7568 [cont reloadData];
7290 DW_MUTEX_UNLOCK; 7569 DW_FUNCTION_RETURN_NOTHING;
7291 } 7570 }
7292 7571
7293 /* 7572 /*
7294 * Scrolls container up or down. 7573 * Scrolls container up or down.
7295 * Parameters: 7574 * Parameters:
7296 * handle: Handle to the window (widget) to be scrolled. 7575 * handle: Handle to the window (widget) to be scrolled.
7297 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or 7576 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
7298 * DW_SCROLL_BOTTOM. (rows is ignored for last two) 7577 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
7299 * rows: The number of rows to be scrolled. 7578 * rows: The number of rows to be scrolled.
7300 */ 7579 */
7301 void API dw_container_scroll(HWND handle, int direction, long rows) 7580 DW_FUNCTION_DEFINITION(dw_container_scroll, void, HWND handle, int direction, long rows)
7302 { 7581 DW_FUNCTION_ADD_PARAM3(handle, direction, rows)
7582 DW_FUNCTION_NO_RETURN(dw_container_scroll)
7583 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, direction, int, rows, long)
7584 {
7585 DW_FUNCTION_INIT;
7303 DWContainer *cont = handle; 7586 DWContainer *cont = handle;
7304 NSScrollView *sv = [cont scrollview]; 7587 NSScrollView *sv = [cont scrollview];
7305 NSScroller *scrollbar = [sv verticalScroller]; 7588 NSScroller *scrollbar = [sv verticalScroller];
7306 int rowcount = (int)[cont numberOfRowsInTableView:cont]; 7589 int rowcount = (int)[cont numberOfRowsInTableView:cont];
7307 float currpos = [scrollbar floatValue]; 7590 float currpos = [scrollbar floatValue];
7346 } 7629 }
7347 [scrollbar setFloatValue:newpos]; 7630 [scrollbar setFloatValue:newpos];
7348 break; 7631 break;
7349 } 7632 }
7350 } 7633 }
7634 DW_FUNCTION_RETURN_NOTHING;
7351 } 7635 }
7352 7636
7353 /* 7637 /*
7354 * Starts a new query of a container. 7638 * Starts a new query of a container.
7355 * Parameters: 7639 * Parameters:
7356 * handle: Handle to the window (widget) to be queried. 7640 * handle: Handle to the window (widget) to be queried.
7357 * flags: If this parameter is DW_CRA_SELECTED it will only 7641 * flags: If this parameter is DW_CRA_SELECTED it will only
7358 * return items that are currently selected. Otherwise 7642 * return items that are currently selected. Otherwise
7359 * it will return all records in the container. 7643 * it will return all records in the container.
7360 */ 7644 */
7361 char * API dw_container_query_start(HWND handle, unsigned long flags) 7645 DW_FUNCTION_DEFINITION(dw_container_query_start, char *, HWND handle, unsigned long flags)
7362 { 7646 DW_FUNCTION_ADD_PARAM2(handle, flags)
7363 int _locked_by_me = FALSE; 7647 DW_FUNCTION_RETURN(dw_container_query_start, char *)
7364 DW_MUTEX_LOCK; 7648 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long)
7649 {
7650 DW_FUNCTION_INIT;
7365 DWContainer *cont = handle; 7651 DWContainer *cont = handle;
7366 NSIndexSet *selected = [cont selectedRowIndexes]; 7652 NSIndexSet *selected = [cont selectedRowIndexes];
7367 NSUInteger result = [selected indexGreaterThanOrEqualToIndex:0]; 7653 NSUInteger result = [selected indexGreaterThanOrEqualToIndex:0];
7368 void *retval = NULL; 7654 void *retval = NULL;
7369 7655
7377 if(temp) 7663 if(temp)
7378 retval = strdup(temp); 7664 retval = strdup(temp);
7379 } 7665 }
7380 [cont setLastQueryPoint:(int)result]; 7666 [cont setLastQueryPoint:(int)result];
7381 } 7667 }
7382 DW_MUTEX_UNLOCK; 7668 DW_FUNCTION_RETURN_THIS(retval);
7383 return retval;
7384 } 7669 }
7385 7670
7386 /* 7671 /*
7387 * Continues an existing query of a container. 7672 * Continues an existing query of a container.
7388 * Parameters: 7673 * Parameters:
7389 * handle: Handle to the window (widget) to be queried. 7674 * handle: Handle to the window (widget) to be queried.
7390 * flags: If this parameter is DW_CRA_SELECTED it will only 7675 * flags: If this parameter is DW_CRA_SELECTED it will only
7391 * return items that are currently selected. Otherwise 7676 * return items that are currently selected. Otherwise
7392 * it will return all records in the container. 7677 * it will return all records in the container.
7393 */ 7678 */
7394 char * API dw_container_query_next(HWND handle, unsigned long flags) 7679 DW_FUNCTION_DEFINITION(dw_container_query_next, char *, HWND handle, unsigned long flags)
7395 { 7680 DW_FUNCTION_ADD_PARAM2(handle, flags)
7396 int _locked_by_me = FALSE; 7681 DW_FUNCTION_RETURN(dw_container_query_next, char *)
7397 DW_MUTEX_LOCK; 7682 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long)
7683 {
7684 DW_FUNCTION_INIT;
7398 DWContainer *cont = handle; 7685 DWContainer *cont = handle;
7399 int lastQueryPoint = [cont lastQueryPoint]; 7686 int lastQueryPoint = [cont lastQueryPoint];
7400 NSIndexSet *selected = [cont selectedRowIndexes]; 7687 NSIndexSet *selected = [cont selectedRowIndexes];
7401 NSUInteger result = [selected indexGreaterThanIndex:lastQueryPoint]; 7688 NSUInteger result = [selected indexGreaterThanIndex:lastQueryPoint];
7402 void *retval = NULL; 7689 void *retval = NULL;
7411 if(temp) 7698 if(temp)
7412 retval = strdup(temp); 7699 retval = strdup(temp);
7413 } 7700 }
7414 [cont setLastQueryPoint:(int)result]; 7701 [cont setLastQueryPoint:(int)result];
7415 } 7702 }
7416 DW_MUTEX_UNLOCK; 7703 DW_FUNCTION_RETURN_THIS(retval);
7417 return retval;
7418 } 7704 }
7419 7705
7420 /* 7706 /*
7421 * Cursors the item with the text speficied, and scrolls to that item. 7707 * Cursors the item with the text speficied, and scrolls to that item.
7422 * Parameters: 7708 * Parameters:
7423 * handle: Handle to the window (widget) to be queried. 7709 * handle: Handle to the window (widget) to be queried.
7424 * text: Text usually returned by dw_container_query(). 7710 * text: Text usually returned by dw_container_query().
7425 */ 7711 */
7426 void API dw_container_cursor(HWND handle, char *text) 7712 DW_FUNCTION_DEFINITION(dw_container_cursor, void, HWND handle, char *text)
7427 { 7713 DW_FUNCTION_ADD_PARAM2(handle, text)
7428 int _locked_by_me = FALSE; 7714 DW_FUNCTION_NO_RETURN(dw_container_cursor)
7715 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
7716 {
7717 DW_FUNCTION_INIT;
7429 DW_LOCAL_POOL_IN; 7718 DW_LOCAL_POOL_IN;
7430 DW_MUTEX_LOCK;
7431 DWContainer *cont = handle; 7719 DWContainer *cont = handle;
7432 char *thistext; 7720 char *thistext;
7433 int x, count = (int)[cont numberOfRowsInTableView:cont]; 7721 int x, count = (int)[cont numberOfRowsInTableView:cont];
7434 7722
7435 for(x=0;x<count;x++) 7723 for(x=0;x<count;x++)
7441 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x]; 7729 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x];
7442 7730
7443 [cont selectRowIndexes:selected byExtendingSelection:YES]; 7731 [cont selectRowIndexes:selected byExtendingSelection:YES];
7444 [selected release]; 7732 [selected release];
7445 [cont scrollRowToVisible:x]; 7733 [cont scrollRowToVisible:x];
7446 DW_MUTEX_UNLOCK; 7734 x=count;
7447 DW_LOCAL_POOL_OUT; 7735 break;
7448 return; 7736 }
7449 } 7737 }
7450 }
7451 DW_MUTEX_UNLOCK;
7452 DW_LOCAL_POOL_OUT; 7738 DW_LOCAL_POOL_OUT;
7739 DW_FUNCTION_RETURN_NOTHING;
7453 } 7740 }
7454 7741
7455 /* 7742 /*
7456 * Cursors the item with the data speficied, and scrolls to that item. 7743 * Cursors the item with the data speficied, and scrolls to that item.
7457 * Parameters: 7744 * Parameters:
7458 * handle: Handle to the window (widget) to be queried. 7745 * handle: Handle to the window (widget) to be queried.
7459 * data: Data associated with the row. 7746 * data: Data associated with the row.
7460 */ 7747 */
7461 void API dw_container_cursor_by_data(HWND handle, void *data) 7748 DW_FUNCTION_DEFINITION(dw_container_cursor_by_data, void, HWND handle, void *data)
7462 { 7749 DW_FUNCTION_ADD_PARAM2(handle, data)
7463 int _locked_by_me = FALSE; 7750 DW_FUNCTION_NO_RETURN(dw_container_cursor_by_data)
7751 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, data, void *)
7752 {
7753 DW_FUNCTION_INIT;
7464 DW_LOCAL_POOL_IN; 7754 DW_LOCAL_POOL_IN;
7465 DW_MUTEX_LOCK;
7466 DWContainer *cont = handle; 7755 DWContainer *cont = handle;
7467 void *thisdata; 7756 void *thisdata;
7468 int x, count = (int)[cont numberOfRowsInTableView:cont]; 7757 int x, count = (int)[cont numberOfRowsInTableView:cont];
7469 7758
7470 for(x=0;x<count;x++) 7759 for(x=0;x<count;x++)
7476 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x]; 7765 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x];
7477 7766
7478 [cont selectRowIndexes:selected byExtendingSelection:YES]; 7767 [cont selectRowIndexes:selected byExtendingSelection:YES];
7479 [selected release]; 7768 [selected release];
7480 [cont scrollRowToVisible:x]; 7769 [cont scrollRowToVisible:x];
7481 DW_MUTEX_UNLOCK; 7770 x=count;
7482 DW_LOCAL_POOL_OUT; 7771 break;
7483 return; 7772 }
7484 } 7773 }
7485 }
7486 DW_MUTEX_UNLOCK;
7487 DW_LOCAL_POOL_OUT; 7774 DW_LOCAL_POOL_OUT;
7775 DW_FUNCTION_RETURN_NOTHING;
7488 } 7776 }
7489 7777
7490 /* 7778 /*
7491 * Deletes the item with the text speficied. 7779 * Deletes the item with the text speficied.
7492 * Parameters: 7780 * Parameters:
7493 * handle: Handle to the window (widget). 7781 * handle: Handle to the window (widget).
7494 * text: Text usually returned by dw_container_query(). 7782 * text: Text usually returned by dw_container_query().
7495 */ 7783 */
7496 void API dw_container_delete_row(HWND handle, char *text) 7784 DW_FUNCTION_DEFINITION(dw_container_delete_row, void, HWND handle, char *text)
7497 { 7785 DW_FUNCTION_ADD_PARAM2(handle, text)
7498 int _locked_by_me = FALSE; 7786 DW_FUNCTION_NO_RETURN(dw_container_delete_row)
7499 DW_MUTEX_LOCK; 7787 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
7788 {
7789 DW_FUNCTION_INIT;
7500 DWContainer *cont = handle; 7790 DWContainer *cont = handle;
7501 char *thistext; 7791 char *thistext;
7502 int x, count = (int)[cont numberOfRowsInTableView:cont]; 7792 int x, count = (int)[cont numberOfRowsInTableView:cont];
7503 7793
7504 for(x=0;x<count;x++) 7794 for(x=0;x<count;x++)
7507 7797
7508 if(thistext && strcmp(thistext, text) == 0) 7798 if(thistext && strcmp(thistext, text) == 0)
7509 { 7799 {
7510 [cont removeRow:x]; 7800 [cont removeRow:x];
7511 [cont reloadData]; 7801 [cont reloadData];
7512 DW_MUTEX_UNLOCK; 7802 x=count;
7513 return; 7803 break;
7514 } 7804 }
7515 } 7805 }
7516 DW_MUTEX_UNLOCK; 7806 DW_FUNCTION_RETURN_NOTHING;
7517 } 7807 }
7518 7808
7519 /* 7809 /*
7520 * Deletes the item with the data speficied. 7810 * Deletes the item with the data speficied.
7521 * Parameters: 7811 * Parameters:
7522 * handle: Handle to the window (widget). 7812 * handle: Handle to the window (widget).
7523 * data: Data specified. 7813 * data: Data specified.
7524 */ 7814 */
7525 void API dw_container_delete_row_by_data(HWND handle, void *data) 7815 DW_FUNCTION_DEFINITION(dw_container_delete_row_by_data, void, HWND handle, void *data)
7526 { 7816 DW_FUNCTION_ADD_PARAM2(handle, data)
7527 int _locked_by_me = FALSE; 7817 DW_FUNCTION_NO_RETURN(dw_container_delete_row_by_data)
7528 DW_MUTEX_LOCK; 7818 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, data, void *)
7819 {
7820 DW_FUNCTION_INIT;
7529 DWContainer *cont = handle; 7821 DWContainer *cont = handle;
7530 void *thisdata; 7822 void *thisdata;
7531 int x, count = (int)[cont numberOfRowsInTableView:cont]; 7823 int x, count = (int)[cont numberOfRowsInTableView:cont];
7532 7824
7533 for(x=0;x<count;x++) 7825 for(x=0;x<count;x++)
7536 7828
7537 if(thisdata == data) 7829 if(thisdata == data)
7538 { 7830 {
7539 [cont removeRow:x]; 7831 [cont removeRow:x];
7540 [cont reloadData]; 7832 [cont reloadData];
7541 DW_MUTEX_UNLOCK; 7833 x=count;
7542 return; 7834 break;
7543 } 7835 }
7544 } 7836 }
7545 DW_MUTEX_UNLOCK; 7837 DW_FUNCTION_RETURN_NOTHING;
7546 } 7838 }
7547 7839
7548 /* 7840 /*
7549 * Optimizes the column widths so that all data is visible. 7841 * Optimizes the column widths so that all data is visible.
7550 * Parameters: 7842 * Parameters:
7551 * handle: Handle to the window (widget) to be optimized. 7843 * handle: Handle to the window (widget) to be optimized.
7552 */ 7844 */
7553 void API dw_container_optimize(HWND handle) 7845 DW_FUNCTION_DEFINITION(dw_container_optimize, void, HWND handle)
7554 { 7846 DW_FUNCTION_ADD_PARAM1(handle)
7555 int _locked_by_me = FALSE; 7847 DW_FUNCTION_NO_RETURN(dw_container_optimize)
7556 DW_MUTEX_LOCK; 7848 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
7849 {
7850 DW_FUNCTION_INIT;
7557 DWContainer *cont = handle; 7851 DWContainer *cont = handle;
7558 [cont optimize]; 7852 [cont optimize];
7559 DW_MUTEX_UNLOCK; 7853 DW_FUNCTION_RETURN_NOTHING;
7560 } 7854 }
7561 7855
7562 /* 7856 /*
7563 * Inserts an icon into the taskbar. 7857 * Inserts an icon into the taskbar.
7564 * Parameters: 7858 * Parameters:
7716 * topleft: Handle to the window to be top or left. 8010 * topleft: Handle to the window to be top or left.
7717 * bottomright: Handle to the window to be bottom or right. 8011 * bottomright: Handle to the window to be bottom or right.
7718 * Returns: 8012 * Returns:
7719 * A handle to a splitbar window or NULL on failure. 8013 * A handle to a splitbar window or NULL on failure.
7720 */ 8014 */
7721 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long cid) 8015 DW_FUNCTION_DEFINITION(dw_splitbar_new, HWND, int type, HWND topleft, HWND bottomright, unsigned long cid)
7722 { 8016 DW_FUNCTION_ADD_PARAM4(type, topleft, bottomright, cid)
8017 DW_FUNCTION_RETURN(dw_splitbar_new, HWND)
8018 DW_FUNCTION_RESTORE_PARAM4(type, int, topleft, HWND, bottomright, HWND, cid, unsigned long)
8019 {
8020 DW_FUNCTION_INIT;
7723 id tmpbox = dw_box_new(DW_VERT, 0); 8021 id tmpbox = dw_box_new(DW_VERT, 0);
7724 int _locked_by_me = FALSE;
7725 DW_MUTEX_LOCK;
7726 DWSplitBar *split = [[DWSplitBar alloc] init]; 8022 DWSplitBar *split = [[DWSplitBar alloc] init];
7727 [split setDelegate:split]; 8023 [split setDelegate:split];
7728 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); 8024 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0);
7729 [split addSubview:tmpbox]; 8025 [split addSubview:tmpbox];
7730 [tmpbox autorelease]; 8026 [tmpbox autorelease];
7741 [split setVertical:YES]; 8037 [split setVertical:YES];
7742 } 8038 }
7743 /* Set the default percent to 50% split */ 8039 /* Set the default percent to 50% split */
7744 [split setPercent:50.0]; 8040 [split setPercent:50.0];
7745 /* [split setTag:cid]; Why doesn't this work? */ 8041 /* [split setTag:cid]; Why doesn't this work? */
7746 DW_MUTEX_UNLOCK; 8042 DW_FUNCTION_RETURN_THIS(split);
7747 return split;
7748 } 8043 }
7749 8044
7750 /* 8045 /*
7751 * Sets the position of a splitbar (pecentage). 8046 * Sets the position of a splitbar (pecentage).
7752 * Parameters: 8047 * Parameters:
7753 * handle: The handle to the splitbar returned by dw_splitbar_new(). 8048 * handle: The handle to the splitbar returned by dw_splitbar_new().
7754 * percent: The position of the splitbar. 8049 * percent: The position of the splitbar.
7755 */ 8050 */
7756 void API dw_splitbar_set(HWND handle, float percent) 8051 DW_FUNCTION_DEFINITION(dw_splitbar_set, void, HWND handle, float percent)
7757 { 8052 DW_FUNCTION_ADD_PARAM2(handle, percent)
8053 DW_FUNCTION_NO_RETURN(dw_splitbar_set)
8054 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, percent, float)
8055 {
8056 DW_FUNCTION_INIT;
7758 DWSplitBar *split = handle; 8057 DWSplitBar *split = handle;
7759 int _locked_by_me = FALSE;
7760 DW_MUTEX_LOCK;
7761 NSRect rect = [split frame]; 8058 NSRect rect = [split frame];
7762 float pos; 8059 float pos;
7763 /* Calculate the position based on the size */ 8060 /* Calculate the position based on the size */
7764 if([split isVertical]) 8061 if([split isVertical])
7765 { 8062 {
7779 * event when we get an actual size to try 8076 * event when we get an actual size to try
7780 * to set the splitbar again. 8077 * to set the splitbar again.
7781 */ 8078 */
7782 [split setPercent:percent]; 8079 [split setPercent:percent];
7783 } 8080 }
7784 DW_MUTEX_UNLOCK; 8081 DW_FUNCTION_RETURN_NOTHING;
7785 } 8082 }
7786 8083
7787 /* 8084 /*
7788 * Gets the position of a splitbar (pecentage). 8085 * Gets the position of a splitbar (pecentage).
7789 * Parameters: 8086 * Parameters:
7835 /* 8132 /*
7836 * Create a bitmap object to be packed. 8133 * Create a bitmap object to be packed.
7837 * Parameters: 8134 * Parameters:
7838 * id: An ID to be used with dw_window_from_id() or 0L. 8135 * id: An ID to be used with dw_window_from_id() or 0L.
7839 */ 8136 */
7840 HWND API dw_bitmap_new(ULONG cid) 8137 DW_FUNCTION_DEFINITION(dw_bitmap_new, HWND, ULONG cid)
7841 { 8138 DW_FUNCTION_ADD_PARAM1(cid)
7842 int _locked_by_me = FALSE; 8139 DW_FUNCTION_RETURN(dw_bitmap_new, HWND)
7843 DW_MUTEX_LOCK; 8140 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
8141 {
8142 DW_FUNCTION_INIT;
7844 NSImageView *bitmap = [[NSImageView alloc] init]; 8143 NSImageView *bitmap = [[NSImageView alloc] init];
7845 [bitmap setImageFrameStyle:NSImageFrameNone]; 8144 [bitmap setImageFrameStyle:NSImageFrameNone];
7846 [bitmap setImageScaling:NSImageScaleNone]; 8145 [bitmap setImageScaling:NSImageScaleNone];
7847 [bitmap setEditable:NO]; 8146 [bitmap setEditable:NO];
7848 [bitmap setTag:cid]; 8147 [bitmap setTag:cid];
7849 DW_MUTEX_UNLOCK; 8148 DW_FUNCTION_RETURN_THIS(bitmap);
7850 return bitmap;
7851 } 8149 }
7852 8150
7853 /* 8151 /*
7854 * Creates a pixmap with given parameters. 8152 * Creates a pixmap with given parameters.
7855 * Parameters: 8153 * Parameters:
8350 * Not available under OS/2, eCS 8648 * Not available under OS/2, eCS
8351 * Parameters: 8649 * Parameters:
8352 * text: The default text to be in the entryfield widget. 8650 * text: The default text to be in the entryfield widget.
8353 * id: An ID to be used with dw_window_from_id() or 0L. 8651 * id: An ID to be used with dw_window_from_id() or 0L.
8354 */ 8652 */
8355 HWND API dw_html_new(unsigned long cid) 8653 DW_FUNCTION_DEFINITION(dw_html_new, HWND, ULONG cid)
8356 { 8654 DW_FUNCTION_ADD_PARAM1(cid)
8357 int _locked_by_me = FALSE; 8655 DW_FUNCTION_RETURN(dw_html_new, HWND)
8358 DW_MUTEX_LOCK; 8656 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
8657 {
8658 DW_FUNCTION_INIT;
8359 DWWebView *web = [[DWWebView alloc] init]; 8659 DWWebView *web = [[DWWebView alloc] init];
8360 /* [web setTag:cid]; Why doesn't this work? */ 8660 /* [web setTag:cid]; Why doesn't this work? */
8361 DW_MUTEX_UNLOCK; 8661 DW_FUNCTION_RETURN_THIS(web);
8362 return web;
8363 } 8662 }
8364 8663
8365 /* 8664 /*
8366 * Returns the current X and Y coordinates of the mouse pointer. 8665 * Returns the current X and Y coordinates of the mouse pointer.
8367 * Parameters: 8666 * Parameters:
8818 * Parameters: 9117 * Parameters:
8819 * owner: The Owner's window handle or HWND_DESKTOP. 9118 * owner: The Owner's window handle or HWND_DESKTOP.
8820 * title: The Window title. 9119 * title: The Window title.
8821 * flStyle: Style flags, see the PM reference. 9120 * flStyle: Style flags, see the PM reference.
8822 */ 9121 */
8823 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) 9122 DW_FUNCTION_DEFINITION(dw_window_new, HWND, HWND hwndOwner, char *title, ULONG flStyle)
8824 { 9123 DW_FUNCTION_ADD_PARAM3(hwndOwner, title, flStyle)
8825 int _locked_by_me = FALSE; 9124 DW_FUNCTION_RETURN(dw_window_new, HWND)
8826 DW_MUTEX_LOCK; 9125 DW_FUNCTION_RESTORE_PARAM3(hwndOwner, HWND, title, char *, flStyle, ULONG)
9126 {
9127 DW_FUNCTION_INIT;
8827 NSRect frame = NSMakeRect(1,1,1,1); 9128 NSRect frame = NSMakeRect(1,1,1,1);
8828 DWWindow *window = [[DWWindow alloc] 9129 DWWindow *window = [[DWWindow alloc]
8829 initWithContentRect:frame 9130 initWithContentRect:frame
8830 styleMask:(flStyle) 9131 styleMask:(flStyle)
8831 backing:NSBackingStoreBuffered 9132 backing:NSBackingStoreBuffered
8859 /* Set the window level to be floating */ 9160 /* Set the window level to be floating */
8860 [window setLevel:NSFloatingWindowLevel]; 9161 [window setLevel:NSFloatingWindowLevel];
8861 [window setHidesOnDeactivate:YES]; 9162 [window setHidesOnDeactivate:YES];
8862 } 9163 }
8863 } 9164 }
8864 DW_MUTEX_UNLOCK; 9165 DW_FUNCTION_RETURN_THIS(window);
8865 return (HWND)window;
8866 } 9166 }
8867 9167
8868 /* 9168 /*
8869 * Call a function from the window (widget)'s context. 9169 * Call a function from the window (widget)'s context.
8870 * Parameters: 9170 * Parameters:
9460 /* 9760 /*
9461 * Destroys a window and all of it's children. 9761 * Destroys a window and all of it's children.
9462 * Parameters: 9762 * Parameters:
9463 * handle: The window handle to destroy. 9763 * handle: The window handle to destroy.
9464 */ 9764 */
9465 int API dw_window_destroy(HWND handle) 9765 DW_FUNCTION_DEFINITION(dw_window_destroy, int, HWND handle)
9466 { 9766 DW_FUNCTION_ADD_PARAM1(handle)
9467 int _locked_by_me = FALSE; 9767 DW_FUNCTION_RETURN(dw_window_destroy, int)
9768 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
9769 {
9770 DW_FUNCTION_INIT;
9468 DW_LOCAL_POOL_IN; 9771 DW_LOCAL_POOL_IN;
9469 DW_MUTEX_LOCK;
9470 id object = handle; 9772 id object = handle;
9773 int retval = 0;
9471 9774
9472 /* Handle destroying a top-level window */ 9775 /* Handle destroying a top-level window */
9473 if([ object isKindOfClass:[ NSWindow class ] ]) 9776 if([ object isKindOfClass:[ NSWindow class ] ])
9474 { 9777 {
9475 DWWindow *window = handle; 9778 DWWindow *window = handle;
9511 { 9814 {
9512 if(thisitem[z].hwnd == object) 9815 if(thisitem[z].hwnd == object)
9513 index = z; 9816 index = z;
9514 } 9817 }
9515 9818
9516 if(index == -1) 9819 if(index != -1)
9517 { 9820 {
9518 DW_MUTEX_UNLOCK; 9821 [object removeFromSuperview];
9519 DW_LOCAL_POOL_OUT; 9822
9520 return 0; 9823 if(thisbox->count > 1)
9824 {
9825 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
9826
9827 /* Copy all but the current entry to the new list */
9828 for(z=0;z<index;z++)
9829 {
9830 tmpitem[z] = thisitem[z];
9831 }
9832 for(z=index+1;z<thisbox->count;z++)
9833 {
9834 tmpitem[z-1] = thisitem[z];
9835 }
9836 }
9837
9838 thisbox->items = tmpitem;
9839 if(thisitem)
9840 free(thisitem);
9841 if(tmpitem)
9842 thisbox->count--;
9843 else
9844 thisbox->count = 0;
9845
9846 /* Queue a redraw on the top-level window */
9847 _dw_redraw(window, TRUE);
9521 } 9848 }
9522 9849 }
9523 [object removeFromSuperview]; 9850 }
9524
9525 if(thisbox->count > 1)
9526 {
9527 tmpitem = calloc(sizeof(Item), (thisbox->count-1));
9528
9529 /* Copy all but the current entry to the new list */
9530 for(z=0;z<index;z++)
9531 {
9532 tmpitem[z] = thisitem[z];
9533 }
9534 for(z=index+1;z<thisbox->count;z++)
9535 {
9536 tmpitem[z-1] = thisitem[z];
9537 }
9538 }
9539
9540 thisbox->items = tmpitem;
9541 if(thisitem)
9542 free(thisitem);
9543 if(tmpitem)
9544 thisbox->count--;
9545 else
9546 thisbox->count = 0;
9547
9548 /* Queue a redraw on the top-level window */
9549 _dw_redraw(window, TRUE);
9550 }
9551 }
9552 DW_MUTEX_UNLOCK;
9553 DW_LOCAL_POOL_OUT; 9851 DW_LOCAL_POOL_OUT;
9554 return 0; 9852 DW_FUNCTION_RETURN_THIS(retval);
9555 } 9853 }
9556 9854
9557 /* 9855 /*
9558 * Gets the text used for a given window. 9856 * Gets the text used for a given window.
9559 * Parameters: 9857 * Parameters:
9560 * handle: Handle to the window. 9858 * handle: Handle to the window.
9561 * Returns: 9859 * Returns:
9562 * text: The text associsated with a given window. 9860 * text: The text associsated with a given window.
9563 */ 9861 */
9564 char * API dw_window_get_text(HWND handle) 9862 DW_FUNCTION_DEFINITION(dw_window_get_text, char *, HWND handle)
9565 { 9863 DW_FUNCTION_ADD_PARAM1(handle)
9864 DW_FUNCTION_RETURN(dw_window_get_text, char *)
9865 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
9866 {
9867 DW_FUNCTION_INIT;
9566 id object = _text_handle(handle); 9868 id object = _text_handle(handle);
9869 char *retval = NULL;
9567 9870
9568 if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ]) 9871 if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ])
9569 { 9872 {
9570 id window = object; 9873 id window = object;
9571 NSString *nsstr = [ window title]; 9874 NSString *nsstr = [ window title];
9572 9875
9573 return strdup([ nsstr UTF8String ]); 9876 retval = strdup([ nsstr UTF8String ]);
9574 } 9877 }
9575 else if([ object isKindOfClass:[ NSControl class ] ]) 9878 else if([ object isKindOfClass:[ NSControl class ] ])
9576 { 9879 {
9577 NSControl *control = object; 9880 NSControl *control = object;
9578 NSString *nsstr = [ control stringValue]; 9881 NSString *nsstr = [ control stringValue];
9579 9882
9580 return strdup([ nsstr UTF8String ]); 9883 retval = strdup([ nsstr UTF8String ]);
9581 } 9884 }
9582 return NULL; 9885 DW_FUNCTION_RETURN_THIS(retval);
9583 } 9886 }
9584 9887
9585 /* 9888 /*
9586 * Sets the text used for a given window. 9889 * Sets the text used for a given window.
9587 * Parameters: 9890 * Parameters:
9588 * handle: Handle to the window. 9891 * handle: Handle to the window.
9589 * text: The text associsated with a given window. 9892 * text: The text associsated with a given window.
9590 */ 9893 */
9591 void API dw_window_set_text(HWND handle, char *text) 9894 DW_FUNCTION_DEFINITION(dw_window_set_text, void, HWND handle, char *text)
9592 { 9895 DW_FUNCTION_ADD_PARAM2(handle, text)
9896 DW_FUNCTION_NO_RETURN(dw_window_set_text)
9897 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
9898 {
9899 DW_FUNCTION_INIT;
9593 id object = _text_handle(handle); 9900 id object = _text_handle(handle);
9594 9901
9595 if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ]) 9902 if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ])
9596 [object setTitle:[ NSString stringWithUTF8String:text ]]; 9903 [object setTitle:[ NSString stringWithUTF8String:text ]];
9597 else if([ object isKindOfClass:[ NSControl class ] ]) 9904 else if([ object isKindOfClass:[ NSControl class ] ])
9626 item->height = newheight; 9933 item->height = newheight;
9627 /* Queue a redraw on the top-level window */ 9934 /* Queue a redraw on the top-level window */
9628 _dw_redraw([object window], TRUE); 9935 _dw_redraw([object window], TRUE);
9629 } 9936 }
9630 } 9937 }
9938 DW_FUNCTION_RETURN_NOTHING;
9631 } 9939 }
9632 9940
9633 /* 9941 /*
9634 * Sets the text used for a given window's floating bubble help. 9942 * Sets the text used for a given window's floating bubble help.
9635 * Parameters: 9943 * Parameters:
9636 * handle: Handle to the window (widget). 9944 * handle: Handle to the window (widget).
9637 * bubbletext: The text in the floating bubble tooltip. 9945 * bubbletext: The text in the floating bubble tooltip.
9638 */ 9946 */
9639 void API dw_window_set_tooltip(HWND handle, char *bubbletext) 9947 DW_FUNCTION_DEFINITION(dw_window_set_tooltip, void, HWND handle, char *bubbletext)
9640 { 9948 DW_FUNCTION_ADD_PARAM2(handle, bubbletext)
9949 DW_FUNCTION_NO_RETURN(dw_window_set_tooltip)
9950 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, bubbletext, char *)
9951 {
9952 DW_FUNCTION_INIT;
9641 id object = handle; 9953 id object = handle;
9642 if(bubbletext && *bubbletext) 9954 if(bubbletext && *bubbletext)
9643 [object setToolTip:[NSString stringWithUTF8String:bubbletext]]; 9955 [object setToolTip:[NSString stringWithUTF8String:bubbletext]];
9644 else 9956 else
9645 [object setToolTip:nil]; 9957 [object setToolTip:nil];
9958 DW_FUNCTION_RETURN_NOTHING;
9646 } 9959 }
9647 9960
9648 /* 9961 /*
9649 * Disables given window (widget). 9962 * Disables given window (widget).
9650 * Parameters: 9963 * Parameters:
9651 * handle: Handle to the window. 9964 * handle: Handle to the window.
9652 */ 9965 */
9653 void API dw_window_disable(HWND handle) 9966 DW_FUNCTION_DEFINITION(dw_window_disable, void, HWND handle)
9654 { 9967 DW_FUNCTION_ADD_PARAM1(handle)
9968 DW_FUNCTION_NO_RETURN(dw_window_disable)
9969 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
9970 {
9971 DW_FUNCTION_INIT;
9655 id object = handle; 9972 id object = handle;
9656 9973
9657 if([object isMemberOfClass:[NSScrollView class]]) 9974 if([object isMemberOfClass:[NSScrollView class]])
9658 { 9975 {
9659 NSScrollView *sv = handle; 9976 NSScrollView *sv = handle;
9667 { 9984 {
9668 NSTextView *mle = object; 9985 NSTextView *mle = object;
9669 9986
9670 [mle setEditable:NO]; 9987 [mle setEditable:NO];
9671 } 9988 }
9989 DW_FUNCTION_RETURN_NOTHING;
9672 } 9990 }
9673 9991
9674 /* 9992 /*
9675 * Enables given window (widget). 9993 * Enables given window (widget).
9676 * Parameters: 9994 * Parameters:
9677 * handle: Handle to the window. 9995 * handle: Handle to the window.
9678 */ 9996 */
9679 void API dw_window_enable(HWND handle) 9997 DW_FUNCTION_DEFINITION(dw_window_enable, void, HWND handle)
9680 { 9998 DW_FUNCTION_ADD_PARAM1(handle)
9999 DW_FUNCTION_NO_RETURN(dw_window_enable)
10000 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
10001 {
10002 DW_FUNCTION_INIT;
9681 id object = handle; 10003 id object = handle;
9682 10004
9683 if([object isMemberOfClass:[NSScrollView class]]) 10005 if([object isMemberOfClass:[NSScrollView class]])
9684 { 10006 {
9685 NSScrollView *sv = handle; 10007 NSScrollView *sv = handle;
9693 { 10015 {
9694 NSTextView *mle = object; 10016 NSTextView *mle = object;
9695 10017
9696 [mle setEditable:YES]; 10018 [mle setEditable:YES];
9697 } 10019 }
10020 DW_FUNCTION_RETURN_NOTHING;
9698 } 10021 }
9699 10022
9700 /* 10023 /*
9701 * Sets the bitmap used for a given static window. 10024 * Sets the bitmap used for a given static window.
9702 * Parameters: 10025 * Parameters:
9881 * Parameters: 10204 * Parameters:
9882 * handle: Window (widget) handle. 10205 * handle: Window (widget) handle.
9883 * width: New width in pixels. 10206 * width: New width in pixels.
9884 * height: New height in pixels. 10207 * height: New height in pixels.
9885 */ 10208 */
9886 void API dw_window_set_size(HWND handle, ULONG width, ULONG height) 10209 DW_FUNCTION_DEFINITION(dw_window_set_size, void, HWND handle, ULONG width, ULONG height)
9887 { 10210 DW_FUNCTION_ADD_PARAM3(handle, width, height)
9888 int _locked_by_me = FALSE; 10211 DW_FUNCTION_NO_RETURN(dw_window_set_size)
9889 DW_MUTEX_LOCK; 10212 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, width, ULONG, height, ULONG)
10213 {
10214 DW_FUNCTION_INIT;
9890 NSObject *object = handle; 10215 NSObject *object = handle;
9891 10216
9892 if([ object isMemberOfClass:[ DWWindow class ] ]) 10217 if([ object isMemberOfClass:[ DWWindow class ] ])
9893 { 10218 {
9894 DWWindow *window = handle; 10219 DWWindow *window = handle;
9915 } 10240 }
9916 10241
9917 /* Finally set the size */ 10242 /* Finally set the size */
9918 [window setContentSize:content.size]; 10243 [window setContentSize:content.size];
9919 } 10244 }
9920 DW_MUTEX_UNLOCK; 10245 DW_FUNCTION_RETURN_NOTHING;
9921 } 10246 }
9922 10247
9923 /* 10248 /*
9924 * Gets the size the system thinks the widget should be. 10249 * Gets the size the system thinks the widget should be.
9925 * Parameters: 10250 * Parameters:
10041 * Parameters: 10366 * Parameters:
10042 * handle: Window (widget) handle. 10367 * handle: Window (widget) handle.
10043 * x: X location from the bottom left. 10368 * x: X location from the bottom left.
10044 * y: Y location from the bottom left. 10369 * y: Y location from the bottom left.
10045 */ 10370 */
10046 void API dw_window_set_pos(HWND handle, LONG x, LONG y) 10371 DW_FUNCTION_DEFINITION(dw_window_set_pos, void, HWND handle, LONG x, LONG y)
10047 { 10372 DW_FUNCTION_ADD_PARAM3(handle, x, y)
10048 int _locked_by_me = FALSE; 10373 DW_FUNCTION_NO_RETURN(dw_window_set_pos)
10049 DW_MUTEX_LOCK; 10374 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, x, LONG, y, LONG)
10375 {
10376 DW_FUNCTION_INIT;
10050 NSObject *object = handle; 10377 NSObject *object = handle;
10051 10378
10052 if([ object isMemberOfClass:[ DWWindow class ] ]) 10379 if([ object isMemberOfClass:[ DWWindow class ] ])
10053 { 10380 {
10054 DWWindow *window = handle; 10381 DWWindow *window = handle;
10070 10397
10071 [window setFrameOrigin:point]; 10398 [window setFrameOrigin:point];
10072 /* Position set manually... don't auto-position */ 10399 /* Position set manually... don't auto-position */
10073 [window setShown:YES]; 10400 [window setShown:YES];
10074 } 10401 }
10075 DW_MUTEX_UNLOCK; 10402 DW_FUNCTION_RETURN_NOTHING;
10076 } 10403 }
10077 10404
10078 /* 10405 /*
10079 * Sets the position and size of a given window (widget). 10406 * Sets the position and size of a given window (widget).
10080 * Parameters: 10407 * Parameters:
11416 DWMainMenu = _generate_main_menu(); 11743 DWMainMenu = _generate_main_menu();
11417 [DWMainMenu retain]; 11744 [DWMainMenu retain];
11418 [DWApp setMainMenu:DWMainMenu]; 11745 [DWApp setMainMenu:DWMainMenu];
11419 DWObj = [[DWObject alloc] init]; 11746 DWObj = [[DWObject alloc] init];
11420 DWDefaultFont = nil; 11747 DWDefaultFont = nil;
11748 #ifdef BUILDING_FOR_MOJAVE
11749 _DWDirtyDrawables = [[NSMutableArray alloc] init];
11750 #else
11421 /* Create mutexes for thread safety */ 11751 /* Create mutexes for thread safety */
11422 DWRunMutex = dw_mutex_new(); 11752 DWRunMutex = dw_mutex_new();
11423 DWThreadMutex = dw_mutex_new(); 11753 DWThreadMutex = dw_mutex_new();
11424 DWThreadMutex2 = dw_mutex_new(); 11754 DWThreadMutex2 = dw_mutex_new();
11425 #ifdef BUILDING_FOR_MOJAVE
11426 _DWDirtyDrawables = [[NSMutableArray alloc] init];
11427 #endif 11755 #endif
11428 /* Use NSThread to start a dummy thread to initialize the threading subsystem */ 11756 /* Use NSThread to start a dummy thread to initialize the threading subsystem */
11429 NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil]; 11757 NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil];
11430 [thread start]; 11758 [thread start];
11431 [thread release]; 11759 [thread release];