Mercurial > dwindows
comparison ios/dw.m @ 2450:2c03987c95bd
iOS: Fix dw_window_set_bitmap*() on buttons... uses a different method on
iOS for the ImageView than the button, on MacOS they were the same.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 10 Apr 2021 20:09:58 +0000 |
parents | 6edaa9382046 |
children | 54f760a257f3 |
comparison
equal
deleted
inserted
replaced
2449:6edaa9382046 | 2450:2c03987c95bd |
---|---|
8504 */ | 8504 */ |
8505 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len) | 8505 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len) |
8506 { | 8506 { |
8507 id object = handle; | 8507 id object = handle; |
8508 | 8508 |
8509 if([ object isKindOfClass:[ UIImageView class ] ] || [ object isKindOfClass:[ UIButton class ]]) | 8509 if([object isKindOfClass:[UIImageView class]] || [object isMemberOfClass:[DWButton class]]) |
8510 { | 8510 { |
8511 if(data) | 8511 if(data) |
8512 { | 8512 { |
8513 DW_LOCAL_POOL_IN; | 8513 DW_LOCAL_POOL_IN; |
8514 NSData *thisdata = [NSData dataWithBytes:data length:len]; | 8514 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
8515 UIImage *pixmap = [[[UIImage alloc] initWithData:thisdata] autorelease]; | 8515 UIImage *pixmap = [[[UIImage alloc] initWithData:thisdata] autorelease]; |
8516 | 8516 |
8517 if(pixmap) | 8517 if(pixmap) |
8518 { | 8518 { |
8519 [object setImage:pixmap]; | 8519 if([object isMemberOfClass:[DWButton class]]) |
8520 { | |
8521 DWButton *button = object; | |
8522 [button setImage:pixmap forState:UIControlStateNormal]; | |
8523 } | |
8524 else | |
8525 { | |
8526 UIImageView *iv = object; | |
8527 [iv setImage:pixmap]; | |
8528 } | |
8520 } | 8529 } |
8521 /* If we changed the bitmap... */ | 8530 /* If we changed the bitmap... */ |
8522 Item *item = _dw_box_item(handle); | 8531 Item *item = _dw_box_item(handle); |
8523 | 8532 |
8524 /* Check to see if any of the sizes need to be recalculated */ | 8533 /* Check to see if any of the sizes need to be recalculated */ |
8548 void API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename) | 8557 void API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename) |
8549 { | 8558 { |
8550 id object = handle; | 8559 id object = handle; |
8551 DW_LOCAL_POOL_IN; | 8560 DW_LOCAL_POOL_IN; |
8552 | 8561 |
8553 if([ object isKindOfClass:[ UIImageView class ] ] || [ object isKindOfClass:[ UIButton class ]]) | 8562 if([object isKindOfClass:[UIImageView class]] || [object isMemberOfClass:[DWButton class]]) |
8554 { | 8563 { |
8555 UIImage *bitmap = nil; | 8564 UIImage *bitmap = nil; |
8556 | 8565 |
8557 if(filename) | 8566 if(filename) |
8558 { | 8567 { |
8572 bitmap = _dw_icon_load(resid); | 8581 bitmap = _dw_icon_load(resid); |
8573 } | 8582 } |
8574 | 8583 |
8575 if(bitmap) | 8584 if(bitmap) |
8576 { | 8585 { |
8577 [object setImage:bitmap]; | 8586 if([object isMemberOfClass:[DWButton class]]) |
8587 { | |
8588 DWButton *button = object; | |
8589 [button setImage:bitmap forState:UIControlStateNormal]; | |
8590 } | |
8591 else | |
8592 { | |
8593 UIImageView *iv = object; | |
8594 [iv setImage:bitmap]; | |
8595 } | |
8578 | 8596 |
8579 /* If we changed the bitmap... */ | 8597 /* If we changed the bitmap... */ |
8580 Item *item = _dw_box_item(handle); | 8598 Item *item = _dw_box_item(handle); |
8581 | 8599 |
8582 /* Check to see if any of the sizes need to be recalculated */ | 8600 /* Check to see if any of the sizes need to be recalculated */ |