comparison ios/dw.m @ 2399:1cbc316292c1

iOS: Move more functions into thread safety, iOS is very adamant about the thread that the functions run on.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 25 Mar 2021 23:38:40 +0000
parents 5bb3491ceba2
children 5e454dfab0db
comparison
equal deleted inserted replaced
2398:4de830d3bf9e 2399:1cbc316292c1
1113 -(void)viewWillLayoutSubviews 1113 -(void)viewWillLayoutSubviews
1114 { 1114 {
1115 DWWindow *window = (DWWindow *)[[self view] window]; 1115 DWWindow *window = (DWWindow *)[[self view] window];
1116 NSArray *array = [window subviews]; 1116 NSArray *array = [window subviews];
1117 DWView *view = [array firstObject]; 1117 DWView *view = [array firstObject];
1118 #if 0
1119 id object = [array lastObject];
1120 /* Remove the UITransitionView... for testing purposes */
1121 if(![object isMemberOfClass:[DWView class]])
1122 [object removeFromSuperview];
1123 #endif
1124 [view setFrame:[window frame]]; 1118 [view setFrame:[window frame]];
1125 [view windowResized:[window frame].size]; 1119 [view windowResized:[window frame].size];
1126 } 1120 }
1127 @end 1121 @end
1128 1122
3322 * height: Height in pixels of the item or -1 to be self determined. 3316 * height: Height in pixels of the item or -1 to be self determined.
3323 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. 3317 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
3324 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 3318 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
3325 * pad: Number of pixels of padding around the item. 3319 * pad: Number of pixels of padding around the item.
3326 */ 3320 */
3327 void API dw_box_pack_at_index(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad) 3321 DW_FUNCTION_DEFINITION(dw_box_pack_at_index, void, HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad)
3322 DW_FUNCTION_ADD_PARAM8(box, item, index, width, height, hsize, vsize, pad)
3323 DW_FUNCTION_NO_RETURN(dw_box_pack_at_index)
3324 DW_FUNCTION_RESTORE_PARAM8(box, HWND, item, HWND, index, int, width, int, height, int, hsize, int, vsize, int, pad, int)
3328 { 3325 {
3329 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()"); 3326 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()");
3327 DW_FUNCTION_RETURN_NOTHING;
3330 } 3328 }
3331 3329
3332 /* 3330 /*
3333 * Pack windows (widgets) into a box from the start (or top). 3331 * Pack windows (widgets) into a box from the start (or top).
3334 * Parameters: 3332 * Parameters:
3371 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()"); 3369 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()");
3372 DW_FUNCTION_RETURN_NOTHING; 3370 DW_FUNCTION_RETURN_NOTHING;
3373 } 3371 }
3374 3372
3375 /* Internal function to create a basic button, used by all button types */ 3373 /* Internal function to create a basic button, used by all button types */
3376 HWND _dw_button_new(const char *text, ULONG cid) 3374 HWND _dw_internal_button_new(const char *text, ULONG cid)
3377 { 3375 {
3378 DWButton *button = [[DWButton alloc] init]; 3376 DWButton *button = [[DWButton alloc] init];
3379 if(text) 3377 if(text)
3380 { 3378 {
3381 [button setTitle:[NSString stringWithUTF8String:text] forState:UIControlStateNormal]; 3379 [button setTitle:[NSString stringWithUTF8String:text] forState:UIControlStateNormal];
3395 * Create a new button window (widget) to be packed. 3393 * Create a new button window (widget) to be packed.
3396 * Parameters: 3394 * Parameters:
3397 * text: The text to be display by the static text widget. 3395 * text: The text to be display by the static text widget.
3398 * id: An ID to be used with dw_window_from_id() or 0L. 3396 * id: An ID to be used with dw_window_from_id() or 0L.
3399 */ 3397 */
3400 HWND API dw_button_new(const char *text, ULONG cid) 3398 DW_FUNCTION_DEFINITION(dw_button_new, HWND, const char *text, ULONG cid)
3401 { 3399 DW_FUNCTION_ADD_PARAM2(text, cid)
3402 DWButton *button = _dw_button_new(text, cid); 3400 DW_FUNCTION_RETURN(dw_button_new, HWND)
3401 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3402 {
3403 DWButton *button = _dw_internal_button_new(text, cid);
3403 [button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter]; 3404 [button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
3404 return button; 3405 DW_FUNCTION_RETURN_THIS(button);
3405 } 3406 }
3406 3407
3407 /* 3408 /*
3408 * Create a new Entryfield window (widget) to be packed. 3409 * Create a new Entryfield window (widget) to be packed.
3409 * Parameters: 3410 * Parameters:
3410 * text: The default text to be in the entryfield widget. 3411 * text: The default text to be in the entryfield widget.
3411 * id: An ID to be used with dw_window_from_id() or 0L. 3412 * id: An ID to be used with dw_window_from_id() or 0L.
3412 */ 3413 */
3413 HWND API dw_entryfield_new(const char *text, ULONG cid) 3414 DW_FUNCTION_DEFINITION(dw_entryfield_new, HWND, const char *text, ULONG cid)
3415 DW_FUNCTION_ADD_PARAM2(text, cid)
3416 DW_FUNCTION_RETURN(dw_entryfield_new, HWND)
3417 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3414 { 3418 {
3415 DWEntryField *entry = [[DWEntryField alloc] init]; 3419 DWEntryField *entry = [[DWEntryField alloc] init];
3416 [entry setText:[ NSString stringWithUTF8String:text ]]; 3420 [entry setText:[ NSString stringWithUTF8String:text ]];
3417 [entry setTag:cid]; 3421 [entry setTag:cid];
3418 return entry; 3422 DW_FUNCTION_RETURN_THIS(entry);
3419 } 3423 }
3420 3424
3421 /* 3425 /*
3422 * Create a new Entryfield (password) window (widget) to be packed. 3426 * Create a new Entryfield (password) window (widget) to be packed.
3423 * Parameters: 3427 * Parameters:
3424 * text: The default text to be in the entryfield widget. 3428 * text: The default text to be in the entryfield widget.
3425 * id: An ID to be used with dw_window_from_id() or 0L. 3429 * id: An ID to be used with dw_window_from_id() or 0L.
3426 */ 3430 */
3427 HWND API dw_entryfield_password_new(const char *text, ULONG cid) 3431 DW_FUNCTION_DEFINITION(dw_entryfield_password_new, HWND, const char *text, ULONG cid)
3432 DW_FUNCTION_ADD_PARAM2(text, cid)
3433 DW_FUNCTION_RETURN(dw_entryfield_password_new, HWND)
3434 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3428 { 3435 {
3429 DWEntryField *entry = dw_entryfield_new(text, cid); 3436 DWEntryField *entry = dw_entryfield_new(text, cid);
3430 [entry setSecureTextEntry:YES]; 3437 [entry setSecureTextEntry:YES];
3431 return entry; 3438 DW_FUNCTION_RETURN_THIS(entry);
3432 } 3439 }
3433 3440
3434 /* 3441 /*
3435 * Sets the entryfield character limit. 3442 * Sets the entryfield character limit.
3436 * Parameters: 3443 * Parameters:
3452 * Create a new bitmap button window (widget) to be packed. 3459 * Create a new bitmap button window (widget) to be packed.
3453 * Parameters: 3460 * Parameters:
3454 * text: Bubble help text to be displayed. 3461 * text: Bubble help text to be displayed.
3455 * id: An ID of a bitmap in the resource file. 3462 * id: An ID of a bitmap in the resource file.
3456 */ 3463 */
3457 HWND API dw_bitmapbutton_new(const char *text, ULONG resid) 3464 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new, HWND, DW_UNUSED(const char *text), ULONG cid)
3465 DW_FUNCTION_ADD_PARAM2(text, cid)
3466 DW_FUNCTION_RETURN(dw_bitmapbutton_new, HWND)
3467 DW_FUNCTION_RESTORE_PARAM2(DW_UNUSED(text), const char *, cid, ULONG)
3458 { 3468 {
3459 NSBundle *bundle = [NSBundle mainBundle]; 3469 NSBundle *bundle = [NSBundle mainBundle];
3460 NSString *respath = [bundle resourcePath]; 3470 NSString *respath = [bundle resourcePath];
3461 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid]; 3471 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", cid];
3462 UIImage *image = [[UIImage alloc] initWithContentsOfFile:filepath]; 3472 UIImage *image = [[UIImage alloc] initWithContentsOfFile:filepath];
3463 DWButton *button = _dw_button_new("", resid); 3473 DWButton *button = _dw_internal_button_new("", cid);
3464 if(image) 3474 if(image)
3465 { 3475 {
3466 [button setImage:image forState:UIControlStateNormal]; 3476 [button setImage:image forState:UIControlStateNormal];
3467 } 3477 }
3468 [image release]; 3478 [image release];
3469 return button; 3479 DW_FUNCTION_RETURN_THIS(button);
3470 } 3480 }
3471 3481
3472 /* 3482 /*
3473 * Create a new bitmap button window (widget) to be packed from a file. 3483 * Create a new bitmap button window (widget) to be packed from a file.
3474 * Parameters: 3484 * Parameters:
3476 * id: An ID to be used with dw_window_from_id() or 0L. 3486 * id: An ID to be used with dw_window_from_id() or 0L.
3477 * filename: Name of the file, omit extention to have 3487 * filename: Name of the file, omit extention to have
3478 * DW pick the appropriate file extension. 3488 * DW pick the appropriate file extension.
3479 * (BMP on OS/2 or Windows, XPM on Unix) 3489 * (BMP on OS/2 or Windows, XPM on Unix)
3480 */ 3490 */
3481 HWND API dw_bitmapbutton_new_from_file(const char *text, unsigned long cid, const char *filename) 3491 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new_from_file, HWND, const char *text, ULONG cid, const char *filename)
3492 DW_FUNCTION_ADD_PARAM3(text, cid, filename)
3493 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_file, HWND)
3494 DW_FUNCTION_RESTORE_PARAM3(text, const char *, cid, ULONG, filename, const char *)
3482 { 3495 {
3483 char *ext = _dw_get_image_extension(filename); 3496 char *ext = _dw_get_image_extension(filename);
3484 3497
3485 NSString *nstr = [ NSString stringWithUTF8String:filename ]; 3498 NSString *nstr = [ NSString stringWithUTF8String:filename ];
3486 UIImage *image = [[UIImage alloc] initWithContentsOfFile:nstr]; 3499 UIImage *image = [[UIImage alloc] initWithContentsOfFile:nstr];
3488 if(!image && ext) 3501 if(!image && ext)
3489 { 3502 {
3490 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]]; 3503 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
3491 image = [[UIImage alloc] initWithContentsOfFile:nstr]; 3504 image = [[UIImage alloc] initWithContentsOfFile:nstr];
3492 } 3505 }
3493 DWButton *button = _dw_button_new("", cid); 3506 DWButton *button = _dw_internal_button_new("", cid);
3494 if(image) 3507 if(image)
3495 { 3508 {
3496 [button setImage:image forState:UIControlStateNormal]; 3509 [button setImage:image forState:UIControlStateNormal];
3497 } 3510 }
3498 [image release]; 3511 [image release];
3499 return button; 3512 DW_FUNCTION_RETURN_THIS(button);
3500 } 3513 }
3501 3514
3502 /* 3515 /*
3503 * Create a new bitmap button window (widget) to be packed from data. 3516 * Create a new bitmap button window (widget) to be packed from data.
3504 * Parameters: 3517 * Parameters:
3506 * id: An ID to be used with dw_window_from_id() or 0L. 3519 * id: An ID to be used with dw_window_from_id() or 0L.
3507 * data: The contents of the image 3520 * data: The contents of the image
3508 * (BMP or ICO on OS/2 or Windows, XPM on Unix) 3521 * (BMP or ICO on OS/2 or Windows, XPM on Unix)
3509 * len: length of str 3522 * len: length of str
3510 */ 3523 */
3511 HWND API dw_bitmapbutton_new_from_data(const char *text, unsigned long cid, const char *data, int len) 3524 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new_from_data, HWND, DW_UNUSED(const char *text), ULONG cid, const char *data, int len)
3525 DW_FUNCTION_ADD_PARAM4(text, cid, data, len)
3526 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_data, HWND)
3527 DW_FUNCTION_RESTORE_PARAM4(DW_UNUSED(text), const char *, cid, ULONG, data, const char *, len, int)
3512 { 3528 {
3513 NSData *thisdata = [NSData dataWithBytes:data length:len]; 3529 NSData *thisdata = [NSData dataWithBytes:data length:len];
3514 UIImage *image = [[UIImage alloc] initWithData:thisdata]; 3530 UIImage *image = [[UIImage alloc] initWithData:thisdata];
3515 DWButton *button = _dw_button_new("", cid); 3531 DWButton *button = _dw_internal_button_new("", cid);
3516 if(image) 3532 if(image)
3517 { 3533 {
3518 [button setImage:image forState:UIControlStateNormal]; 3534 [button setImage:image forState:UIControlStateNormal];
3519 } 3535 }
3520 [image release]; 3536 [image release];
3521 return button; 3537 DW_FUNCTION_RETURN_THIS(button);
3522 } 3538 }
3523 3539
3524 /* 3540 /*
3525 * Create a new spinbutton window (widget) to be packed. 3541 * Create a new spinbutton window (widget) to be packed.
3526 * Parameters: 3542 * Parameters:
3527 * text: The text to be display by the static text widget. 3543 * text: The text to be display by the static text widget.
3528 * id: An ID to be used with dw_window_from_id() or 0L. 3544 * id: An ID to be used with dw_window_from_id() or 0L.
3529 */ 3545 */
3530 HWND API dw_spinbutton_new(const char *text, ULONG cid) 3546 DW_FUNCTION_DEFINITION(dw_spinbutton_new, HWND, const char *text, ULONG cid)
3547 DW_FUNCTION_ADD_PARAM2(text, cid)
3548 DW_FUNCTION_RETURN(dw_spinbutton_new, HWND)
3549 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3531 { 3550 {
3532 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; 3551 DWSpinButton *spinbutton = [[DWSpinButton alloc] init];
3533 UIStepper *stepper = [spinbutton stepper]; 3552 UIStepper *stepper = [spinbutton stepper];
3534 UITextField *textfield = [spinbutton textfield]; 3553 UITextField *textfield = [spinbutton textfield];
3535 long val = atol(text); 3554 long val = atol(text);
3538 [stepper setTag:cid]; 3557 [stepper setTag:cid];
3539 [stepper setMinimumValue:-65536]; 3558 [stepper setMinimumValue:-65536];
3540 [stepper setMaximumValue:65536]; 3559 [stepper setMaximumValue:65536];
3541 [stepper setValue:(float)val]; 3560 [stepper setValue:(float)val];
3542 [textfield setText:[NSString stringWithFormat:@"%ld",val]]; 3561 [textfield setText:[NSString stringWithFormat:@"%ld",val]];
3543 return spinbutton; 3562 DW_FUNCTION_RETURN_THIS(spinbutton);
3544 } 3563 }
3545 3564
3546 /* 3565 /*
3547 * Sets the spinbutton value. 3566 * Sets the spinbutton value.
3548 * Parameters: 3567 * Parameters:
3549 * handle: Handle to the spinbutton to be set. 3568 * handle: Handle to the spinbutton to be set.
3550 * position: Current value of the spinbutton. 3569 * position: Current value of the spinbutton.
3551 */ 3570 */
3552 void API dw_spinbutton_set_pos(HWND handle, long position) 3571 DW_FUNCTION_DEFINITION(dw_spinbutton_set_pos, void, HWND handle, long position)
3572 DW_FUNCTION_ADD_PARAM2(handle, position)
3573 DW_FUNCTION_NO_RETURN(dw_spinbutton_set_pos)
3574 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, long)
3553 { 3575 {
3554 DWSpinButton *spinbutton = handle; 3576 DWSpinButton *spinbutton = handle;
3555 UIStepper *stepper = [spinbutton stepper]; 3577 UIStepper *stepper = [spinbutton stepper];
3556 UITextField *textfield = [spinbutton textfield]; 3578 UITextField *textfield = [spinbutton textfield];
3557 [stepper setValue:(float)position]; 3579 [stepper setValue:(float)position];
3558 [textfield setText:[NSString stringWithFormat:@"%ld",position]]; 3580 [textfield setText:[NSString stringWithFormat:@"%ld",position]];
3581 DW_FUNCTION_RETURN_NOTHING;
3559 } 3582 }
3560 3583
3561 /* 3584 /*
3562 * Sets the spinbutton limits. 3585 * Sets the spinbutton limits.
3563 * Parameters: 3586 * Parameters:
3564 * handle: Handle to the spinbutton to be set. 3587 * handle: Handle to the spinbutton to be set.
3565 * upper: Upper limit. 3588 * upper: Upper limit.
3566 * lower: Lower limit. 3589 * lower: Lower limit.
3567 */ 3590 */
3568 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) 3591 DW_FUNCTION_DEFINITION(dw_spinbutton_set_limits, void, HWND handle, long upper, long lower)
3592 DW_FUNCTION_ADD_PARAM3(handle, upper, lower)
3593 DW_FUNCTION_NO_RETURN(dw_spinbutton_set_limits)
3594 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, upper, long, lower, long)
3569 { 3595 {
3570 DWSpinButton *spinbutton = handle; 3596 DWSpinButton *spinbutton = handle;
3571 UIStepper *stepper = [spinbutton stepper]; 3597 UIStepper *stepper = [spinbutton stepper];
3572 [stepper setMinimumValue:(double)lower]; 3598 [stepper setMinimumValue:(double)lower];
3573 [stepper setMaximumValue:(double)upper]; 3599 [stepper setMaximumValue:(double)upper];
3600 DW_FUNCTION_RETURN_NOTHING;
3574 } 3601 }
3575 3602
3576 /* 3603 /*
3577 * Returns the current value of the spinbutton. 3604 * Returns the current value of the spinbutton.
3578 * Parameters: 3605 * Parameters:
3579 * handle: Handle to the spinbutton to be queried. 3606 * handle: Handle to the spinbutton to be queried.
3580 */ 3607 */
3581 long API dw_spinbutton_get_pos(HWND handle) 3608 DW_FUNCTION_DEFINITION(dw_spinbutton_get_pos, long, HWND handle)
3609 DW_FUNCTION_ADD_PARAM1(handle)
3610 DW_FUNCTION_RETURN(dw_spinbutton_get_pos, long)
3611 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
3582 { 3612 {
3583 DWSpinButton *spinbutton = handle; 3613 DWSpinButton *spinbutton = handle;
3614 long retval;
3584 UIStepper *stepper = [spinbutton stepper]; 3615 UIStepper *stepper = [spinbutton stepper];
3585 return (long)[stepper value]; 3616 retval = (long)[stepper value];
3617 DW_FUNCTION_RETURN_THIS(retval);
3586 } 3618 }
3587 3619
3588 /* 3620 /*
3589 * Create a new radiobutton window (widget) to be packed. 3621 * Create a new radiobutton window (widget) to be packed.
3590 * Parameters: 3622 * Parameters:
3591 * text: The text to be display by the static text widget. 3623 * text: The text to be display by the static text widget.
3592 * id: An ID to be used with dw_window_from_id() or 0L. 3624 * id: An ID to be used with dw_window_from_id() or 0L.
3593 */ 3625 */
3594 HWND API dw_radiobutton_new(const char *text, ULONG cid) 3626 DW_FUNCTION_DEFINITION(dw_radiobutton_new, HWND, const char *text, ULONG cid)
3595 { 3627 DW_FUNCTION_ADD_PARAM2(text, cid)
3596 DWButton *button = _dw_button_new(text, cid); 3628 DW_FUNCTION_RETURN(dw_radiobutton_new, HWND)
3629 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3630 {
3631 DWButton *button = _dw_internal_button_new(text, cid);
3597 /* TODO: Customize to be a radio button https://github.com/DavydLiu/DLRadioButton */ 3632 /* TODO: Customize to be a radio button https://github.com/DavydLiu/DLRadioButton */
3598 return button; 3633 DW_FUNCTION_RETURN_THIS(button);
3599 } 3634 }
3600 3635
3601 /* 3636 /*
3602 * Create a new slider window (widget) to be packed. 3637 * Create a new slider window (widget) to be packed.
3603 * Parameters: 3638 * Parameters:
3604 * vertical: TRUE or FALSE if slider is vertical. 3639 * vertical: TRUE or FALSE if slider is vertical.
3605 * increments: Number of increments available. 3640 * increments: Number of increments available.
3606 * id: An ID to be used with dw_window_from_id() or 0L. 3641 * id: An ID to be used with dw_window_from_id() or 0L.
3607 */ 3642 */
3608 HWND API dw_slider_new(int vertical, int increments, ULONG cid) 3643 DW_FUNCTION_DEFINITION(dw_slider_new, HWND, int vertical, int increments, ULONG cid)
3644 DW_FUNCTION_ADD_PARAM3(vertical, increments, cid)
3645 DW_FUNCTION_RETURN(dw_slider_new, HWND)
3646 DW_FUNCTION_RESTORE_PARAM3(vertical, int, increments, int, cid, ULONG)
3609 { 3647 {
3610 DWSlider *slider = [[DWSlider alloc] init]; 3648 DWSlider *slider = [[DWSlider alloc] init];
3611 [slider setMaximumValue:(double)increments]; 3649 [slider setMaximumValue:(double)increments];
3612 [slider setMinimumValue:0]; 3650 [slider setMinimumValue:0];
3613 [slider setContinuous:YES]; 3651 [slider setContinuous:YES];
3614 [slider addTarget:slider 3652 [slider addTarget:slider
3615 action:@selector(sliderChanged:) 3653 action:@selector(sliderChanged:)
3616 forControlEvents:UIControlEventValueChanged]; 3654 forControlEvents:UIControlEventValueChanged];
3617 [slider setTag:cid]; 3655 [slider setTag:cid];
3618 return slider; 3656 DW_FUNCTION_RETURN_THIS(slider);
3619 } 3657 }
3620 3658
3621 /* 3659 /*
3622 * Returns the position of the slider. 3660 * Returns the position of the slider.
3623 * Parameters: 3661 * Parameters:
3692 /* 3730 /*
3693 * Create a new percent bar window (widget) to be packed. 3731 * Create a new percent bar window (widget) to be packed.
3694 * Parameters: 3732 * Parameters:
3695 * id: An ID to be used with dw_window_from_id() or 0L. 3733 * id: An ID to be used with dw_window_from_id() or 0L.
3696 */ 3734 */
3697 HWND API dw_percent_new(ULONG cid) 3735 DW_FUNCTION_DEFINITION(dw_percent_new, HWND, ULONG cid)
3736 DW_FUNCTION_ADD_PARAM1(cid)
3737 DW_FUNCTION_RETURN(dw_percent_new, HWND)
3738 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
3698 { 3739 {
3699 DWPercent *percent = [[DWPercent alloc] init]; 3740 DWPercent *percent = [[DWPercent alloc] init];
3700 /*[percent setTag:cid]; Why doesn't this work? */ 3741 [percent setTag:cid];
3701 return percent; 3742 DW_FUNCTION_RETURN_THIS(percent);
3702 } 3743 }
3703 3744
3704 /* 3745 /*
3705 * Sets the percent bar position. 3746 * Sets the percent bar position.
3706 * Parameters: 3747 * Parameters:
3732 * Create a new checkbox window (widget) to be packed. 3773 * Create a new checkbox window (widget) to be packed.
3733 * Parameters: 3774 * Parameters:
3734 * text: The text to be display by the static text widget. 3775 * text: The text to be display by the static text widget.
3735 * id: An ID to be used with dw_window_from_id() or 0L. 3776 * id: An ID to be used with dw_window_from_id() or 0L.
3736 */ 3777 */
3737 HWND API dw_checkbox_new(const char *text, ULONG cid) 3778 DW_FUNCTION_DEFINITION(dw_checkbox_new, HWND, const char *text, ULONG cid)
3738 { 3779 DW_FUNCTION_ADD_PARAM2(text, cid)
3739 DWButton *button = _dw_button_new(text, cid); 3780 DW_FUNCTION_RETURN(dw_checkbox_new, HWND)
3781 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3782 {
3783 DWButton *button = _dw_internal_button_new(text, cid);
3740 /* TODO: Switch to UISwitch control with text */ 3784 /* TODO: Switch to UISwitch control with text */
3741 return button; 3785 DW_FUNCTION_RETURN_THIS(button);
3742 } 3786 }
3743 3787
3744 /* 3788 /*
3745 * Returns the state of the checkbox. 3789 * Returns the state of the checkbox.
3746 * Parameters: 3790 * Parameters:
4174 /* 4218 /*
4175 * Create a new Multiline Editbox window (widget) to be packed. 4219 * Create a new Multiline Editbox window (widget) to be packed.
4176 * Parameters: 4220 * Parameters:
4177 * id: An ID to be used with dw_window_from_id() or 0L. 4221 * id: An ID to be used with dw_window_from_id() or 0L.
4178 */ 4222 */
4179 HWND API dw_mle_new(ULONG cid) 4223 DW_FUNCTION_DEFINITION(dw_mle_new, HWND, ULONG cid)
4224 DW_FUNCTION_ADD_PARAM1(cid)
4225 DW_FUNCTION_RETURN(dw_mle_new, HWND)
4226 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
4180 { 4227 {
4181 DWMLE *mle = [[DWMLE alloc] init]; 4228 DWMLE *mle = [[DWMLE alloc] init];
4182 UIScrollView *scrollview = [[UIScrollView alloc] init]; 4229 UIScrollView *scrollview = [[UIScrollView alloc] init];
4183 CGSize size = [mle intrinsicContentSize]; 4230 CGSize size = [mle intrinsicContentSize];
4184 4231
4185 size.width = size.height; 4232 size.width = size.height;
4186 [mle setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; 4233 [mle setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
4187 [mle setScrollview:scrollview]; 4234 [mle setScrollview:scrollview];
4188 /* [mle setTag:cid]; Why doesn't this work? */ 4235 [mle setTag:cid];
4189 [mle autorelease]; 4236 [mle autorelease];
4190 return mle; 4237 DW_FUNCTION_RETURN_THIS(mle);
4191 } 4238 }
4192 4239
4193 /* 4240 /*
4194 * Adds text to an MLE box and returns the current point. 4241 * Adds text to an MLE box and returns the current point.
4195 * Parameters: 4242 * Parameters:
4475 * Create a new static text window (widget) to be packed. 4522 * Create a new static text window (widget) to be packed.
4476 * Parameters: 4523 * Parameters:
4477 * text: The text to be display by the static text widget. 4524 * text: The text to be display by the static text widget.
4478 * id: An ID to be used with dw_window_from_id() or 0L. 4525 * id: An ID to be used with dw_window_from_id() or 0L.
4479 */ 4526 */
4480 HWND API dw_text_new(const char *text, ULONG cid) 4527 DW_FUNCTION_DEFINITION(dw_text_new, HWND, const char *text, ULONG cid)
4528 DW_FUNCTION_ADD_PARAM2(text, cid)
4529 DW_FUNCTION_RETURN(dw_text_new, HWND)
4530 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
4481 { 4531 {
4482 DWText *textfield = [[DWText alloc] init]; 4532 DWText *textfield = [[DWText alloc] init];
4483 [textfield setText:[NSString stringWithUTF8String:text]]; 4533 [textfield setText:[NSString stringWithUTF8String:text]];
4484 [textfield setTag:cid]; 4534 [textfield setTag:cid];
4485 if(DWDefaultFont) 4535 if(DWDefaultFont)
4486 { 4536 {
4487 [textfield setFont:DWDefaultFont]; 4537 [textfield setFont:DWDefaultFont];
4488 } 4538 }
4489 return textfield; 4539 DW_FUNCTION_RETURN_THIS(textfield);
4490 } 4540 }
4491 4541
4492 /* 4542 /*
4493 * Creates a rendering context widget (window) to be packed. 4543 * Creates a rendering context widget (window) to be packed.
4494 * Parameters: 4544 * Parameters:
4495 * id: An id to be used with dw_window_from_id. 4545 * id: An id to be used with dw_window_from_id.
4496 * Returns: 4546 * Returns:
4497 * A handle to the widget or NULL on failure. 4547 * A handle to the widget or NULL on failure.
4498 */ 4548 */
4499 HWND API dw_render_new(unsigned long cid) 4549 DW_FUNCTION_DEFINITION(dw_render_new, HWND, ULONG cid)
4550 DW_FUNCTION_ADD_PARAM1(cid)
4551 DW_FUNCTION_RETURN(dw_render_new, HWND)
4552 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
4500 { 4553 {
4501 DWRender *render = [[DWRender alloc] init]; 4554 DWRender *render = [[DWRender alloc] init];
4502 [render setTag:cid]; 4555 [render setTag:cid];
4503 return render; 4556 DW_FUNCTION_RETURN_THIS(render);
4504 } 4557 }
4505 4558
4506 /* 4559 /*
4507 * Invalidate the render widget triggering an expose event. 4560 * Invalidate the render widget triggering an expose event.
4508 * Parameters: 4561 * Parameters:
6624 * Not available under OS/2, eCS 6677 * Not available under OS/2, eCS
6625 * Parameters: 6678 * Parameters:
6626 * text: The text to be display by the static text widget. 6679 * text: The text to be display by the static text widget.
6627 * id: An ID to be used with dw_window_from_id() or 0L. 6680 * id: An ID to be used with dw_window_from_id() or 0L.
6628 */ 6681 */
6629 HWND API dw_calendar_new(ULONG cid) 6682 DW_FUNCTION_DEFINITION(dw_calendar_new, HWND, ULONG cid)
6683 DW_FUNCTION_ADD_PARAM1(cid)
6684 DW_FUNCTION_RETURN(dw_calendar_new, HWND)
6685 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
6630 { 6686 {
6631 DWCalendar *calendar = [[DWCalendar alloc] init]; 6687 DWCalendar *calendar = [[DWCalendar alloc] init];
6632 [calendar setDatePickerMode:UIDatePickerModeDate]; 6688 [calendar setDatePickerMode:UIDatePickerModeDate];
6633 [calendar setTag:cid]; 6689 [calendar setTag:cid];
6634 [calendar setDate:[NSDate date]]; 6690 [calendar setDate:[NSDate date]];
6635 return calendar; 6691 DW_FUNCTION_RETURN_THIS(calendar);
6636 } 6692 }
6637 6693
6638 /* 6694 /*
6639 * Sets the current date of a calendar. 6695 * Sets the current date of a calendar.
6640 * Parameters: 6696 * Parameters:
7078 * Create a notebook object to be packed. 7134 * Create a notebook object to be packed.
7079 * Parameters: 7135 * Parameters:
7080 * id: An ID to be used for getting the resource from the 7136 * id: An ID to be used for getting the resource from the
7081 * resource file. 7137 * resource file.
7082 */ 7138 */
7083 HWND API dw_notebook_new(ULONG cid, int top) 7139 DW_FUNCTION_DEFINITION(dw_notebook_new, HWND, ULONG cid, int top)
7140 DW_FUNCTION_ADD_PARAM2(cid, top)
7141 DW_FUNCTION_RETURN(dw_notebook_new, HWND)
7142 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, top, int)
7084 { 7143 {
7085 DWNotebook *notebook = [[DWNotebook alloc] init]; 7144 DWNotebook *notebook = [[DWNotebook alloc] init];
7086 [notebook addTarget:notebook 7145 [notebook addTarget:notebook
7087 action:@selector(pageChanged:) 7146 action:@selector(pageChanged:)
7088 forControlEvents:UIControlEventValueChanged]; 7147 forControlEvents:UIControlEventValueChanged];
7089 /* [notebook setTag:cid]; Why doesn't this work? */ 7148 [notebook setTag:cid];
7090 return notebook; 7149 DW_FUNCTION_RETURN_THIS(notebook);
7091 } 7150 }
7092 7151
7093 /* 7152 /*
7094 * Adds a new page to specified notebook. 7153 * Adds a new page to specified notebook.
7095 * Parameters: 7154 * Parameters:
7096 * handle: Window (widget) handle. 7155 * handle: Window (widget) handle.
7097 * flags: Any additional page creation flags. 7156 * flags: Any additional page creation flags.
7098 * front: If TRUE page is added at the beginning. 7157 * front: If TRUE page is added at the beginning.
7099 */ 7158 */
7100 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) 7159 DW_FUNCTION_DEFINITION(dw_notebook_page_new, ULONG, HWND handle, DW_UNUSED(ULONG flags), int front)
7160 DW_FUNCTION_ADD_PARAM3(handle, flags, front)
7161 DW_FUNCTION_RETURN(dw_notebook_page_new, ULONG)
7162 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, DW_UNUSED(flags), ULONG, front, int)
7101 { 7163 {
7102 DWNotebook *notebook = handle; 7164 DWNotebook *notebook = handle;
7103 NSInteger page = [notebook pageid]; 7165 NSInteger page = [notebook pageid];
7104 DWNotebookPage *notepage = [[DWNotebookPage alloc] init]; 7166 DWNotebookPage *notepage = [[DWNotebookPage alloc] init];
7105 NSMutableArray<DWNotebookPage *> *views = [notebook views]; 7167 NSMutableArray<DWNotebookPage *> *views = [notebook views];
7168 unsigned long retval;
7169
7106 [notepage setPageid:(int)page]; 7170 [notepage setPageid:(int)page];
7107 if(front) 7171 if(front)
7108 { 7172 {
7109 [notebook insertSegmentWithTitle:@"" atIndex:(NSInteger)0 animated:NO]; 7173 [notebook insertSegmentWithTitle:@"" atIndex:(NSInteger)0 animated:NO];
7110 [views addObject:notepage]; 7174 [views addObject:notepage];
7114 [notebook insertSegmentWithTitle:@"" atIndex:[notebook numberOfSegments] animated:NO]; 7178 [notebook insertSegmentWithTitle:@"" atIndex:[notebook numberOfSegments] animated:NO];
7115 [views addObject:notepage]; 7179 [views addObject:notepage];
7116 } 7180 }
7117 [notepage autorelease]; 7181 [notepage autorelease];
7118 [notebook setPageid:(int)(page+1)]; 7182 [notebook setPageid:(int)(page+1)];
7119 return (unsigned long)page; 7183 retval = (unsigned long)page;
7184 DW_FUNCTION_RETURN_THIS(retval);
7120 } 7185 }
7121 7186
7122 /* 7187 /*
7123 * Remove a page from a notebook. 7188 * Remove a page from a notebook.
7124 * Parameters: 7189 * Parameters:
7190 * Parameters: 7255 * Parameters:
7191 * handle: Notebook handle. 7256 * handle: Notebook handle.
7192 * pageid: Page ID of the tab to set. 7257 * pageid: Page ID of the tab to set.
7193 * text: Pointer to the text to set. 7258 * text: Pointer to the text to set.
7194 */ 7259 */
7195 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, const char *text) 7260 DW_FUNCTION_DEFINITION(dw_notebook_page_set_text, void, HWND handle, ULONG pageid, const char *text)
7261 DW_FUNCTION_ADD_PARAM3(handle, pageid, text)
7262 DW_FUNCTION_NO_RETURN(dw_notebook_page_set_text)
7263 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, pageid, ULONG, text, const char *)
7196 { 7264 {
7197 DWNotebook *notebook = handle; 7265 DWNotebook *notebook = handle;
7198 7266
7199 [notebook setTitle:[NSString stringWithUTF8String:text] forSegmentAtIndex:pageid]; 7267 [notebook setTitle:[NSString stringWithUTF8String:text] forSegmentAtIndex:pageid];
7268 DW_FUNCTION_RETURN_NOTHING;
7200 } 7269 }
7201 7270
7202 /* 7271 /*
7203 * Sets the text on the specified notebook tab status area. 7272 * Sets the text on the specified notebook tab status area.
7204 * Parameters: 7273 * Parameters:
7356 * Parameters: 7425 * Parameters:
7357 * handle: The window (widget) handle. 7426 * handle: The window (widget) handle.
7358 * fore: Foreground color in DW_RGB format or a default color index. 7427 * fore: Foreground color in DW_RGB format or a default color index.
7359 * back: Background color in DW_RGB format or a default color index. 7428 * back: Background color in DW_RGB format or a default color index.
7360 */ 7429 */
7361 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) 7430 DW_FUNCTION_DEFINITION(dw_window_set_color, int, HWND handle, unsigned long fore, unsigned long back)
7431 DW_FUNCTION_ADD_PARAM3(handle, fore, back)
7432 DW_FUNCTION_RETURN(dw_window_set_color, int)
7433 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, fore, unsigned long, back, unsigned long)
7362 { 7434 {
7363 id object = handle; 7435 id object = handle;
7364 unsigned long _fore = _dw_get_color(fore); 7436 unsigned long _fore = _dw_get_color(fore);
7365 unsigned long _back = _dw_get_color(back); 7437 unsigned long _back = _dw_get_color(back);
7366 UIColor *fg = NULL; 7438 UIColor *fg = NULL;
7367 UIColor *bg = NULL; 7439 UIColor *bg = NULL;
7440 int retval = DW_ERROR_NONE;
7368 7441
7369 /* Get the UIColor for non-default colors */ 7442 /* Get the UIColor for non-default colors */
7370 if(fore != DW_CLR_DEFAULT) 7443 if(fore != DW_CLR_DEFAULT)
7371 { 7444 {
7372 fg = [UIColor colorWithRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1]; 7445 fg = [UIColor colorWithRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1];
7411 { 7484 {
7412 DWMLE *mle = handle; 7485 DWMLE *mle = handle;
7413 [mle setBackgroundColor:(bg ? bg : [UIColor systemBackgroundColor])]; 7486 [mle setBackgroundColor:(bg ? bg : [UIColor systemBackgroundColor])];
7414 [mle setTextColor:(fg ? fg : [UIColor labelColor])]; 7487 [mle setTextColor:(fg ? fg : [UIColor labelColor])];
7415 } 7488 }
7416 return 0; 7489 DW_FUNCTION_RETURN_THIS(retval);
7417 } 7490 }
7418 7491
7419 /* 7492 /*
7420 * Sets the font used by a specified window (widget) handle. 7493 * Sets the font used by a specified window (widget) handle.
7421 * Parameters: 7494 * Parameters:
7432 * Parameters: 7505 * Parameters:
7433 * handle: Window (widget) handle. 7506 * handle: Window (widget) handle.
7434 * width: New width in pixels. 7507 * width: New width in pixels.
7435 * height: New height in pixels. 7508 * height: New height in pixels.
7436 */ 7509 */
7437 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) 7510 DW_FUNCTION_DEFINITION(dw_window_set_style, void, HWND handle, ULONG style, ULONG mask)
7511 DW_FUNCTION_ADD_PARAM3(handle, style, mask)
7512 DW_FUNCTION_NO_RETURN(dw_window_set_style)
7513 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, style, ULONG, mask, ULONG)
7438 { 7514 {
7439 id object = _text_handle(handle); 7515 id object = _text_handle(handle);
7440 7516
7441 if([object isKindOfClass:[UILabel class]]) 7517 if([object isKindOfClass:[UILabel class]])
7442 { 7518 {
7479 [object setEnabled:YES]; 7555 [object setEnabled:YES];
7480 else if(style & DW_MIS_DISABLED) 7556 else if(style & DW_MIS_DISABLED)
7481 [object setEnabled:NO]; 7557 [object setEnabled:NO];
7482 } 7558 }
7483 } 7559 }
7560 DW_FUNCTION_RETURN_NOTHING;
7484 } 7561 }
7485 7562
7486 /* 7563 /*
7487 * Sets the current focus item for a window/dialog. 7564 * Sets the current focus item for a window/dialog.
7488 * Parameters: 7565 * Parameters: