Mercurial > dwindows
comparison mac/dw.m @ 675:48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
may not be possible. A few of the functions still don't work perfectly.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 28 Feb 2011 08:27:53 +0000 |
parents | 78f9aa6d6d89 |
children | 9861d264925d |
comparison
equal
deleted
inserted
replaced
674:78f9aa6d6d89 | 675:48f8efba898f |
---|---|
562 void *userdata; | 562 void *userdata; |
563 NSMutableArray *tvcols; | 563 NSMutableArray *tvcols; |
564 NSMutableArray *data; | 564 NSMutableArray *data; |
565 NSMutableArray *types; | 565 NSMutableArray *types; |
566 NSPointerArray *titles; | 566 NSPointerArray *titles; |
567 int lastAddPoint; | 567 int lastAddPoint, lastQueryPoint; |
568 id scrollview; | 568 id scrollview; |
569 } | 569 } |
570 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; | 570 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; |
571 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; | 571 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; |
572 /*-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;*/ | 572 /*-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;*/ |
573 -(void *)userdata; | 573 -(void *)userdata; |
574 -(void)setUserdata:(void *)input; | 574 -(void)setUserdata:(void *)input; |
575 -(id)scrollview; | 575 -(id)scrollview; |
576 -(void)setScrollview:(id)input; | 576 -(void)setScrollview:(id)input; |
577 -(void)addColumn:(NSTableColumn *)input andType:(int)type; | 577 -(void)addColumn:(NSTableColumn *)input andType:(int)type; |
578 -(NSTableColumn *)getColumn:(int)col; | |
578 -(int)addRow:(NSArray *)input; | 579 -(int)addRow:(NSArray *)input; |
579 -(int)addRows:(int)number; | 580 -(int)addRows:(int)number; |
580 -(void)editCell:(id)input at:(int)row and:(int)col; | 581 -(void)editCell:(id)input at:(int)row and:(int)col; |
581 -(void)removeRow:(int)row; | 582 -(void)removeRow:(int)row; |
582 -(void)setRow:(int)row title:(void *)input; | 583 -(void)setRow:(int)row title:(void *)input; |
583 -(void *)getRowTitle:(int)row; | 584 -(void *)getRowTitle:(int)row; |
584 -(id)getRow:(int)row and:(int)col; | 585 -(id)getRow:(int)row and:(int)col; |
585 -(int)cellType:(int)col; | 586 -(int)cellType:(int)col; |
586 -(int)lastAddPoint; | 587 -(int)lastAddPoint; |
588 -(int)lastQueryPoint; | |
589 -(void)setLastQueryPoint:(int)input; | |
587 -(void)clear; | 590 -(void)clear; |
588 -(void)setup; | 591 -(void)setup; |
589 -(void)selectionChanged:(id)sender; | 592 -(void)selectionChanged:(id)sender; |
590 -(NSMenu *)menuForEvent:(NSEvent *)event; | 593 -(NSMenu *)menuForEvent:(NSEvent *)event; |
591 @end | 594 @end |
652 -(void *)userdata { return userdata; } | 655 -(void *)userdata { return userdata; } |
653 -(void)setUserdata:(void *)input { userdata = input; } | 656 -(void)setUserdata:(void *)input { userdata = input; } |
654 -(NSScrollView *)scrollview { return scrollview; } | 657 -(NSScrollView *)scrollview { return scrollview; } |
655 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } | 658 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } |
656 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } | 659 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } |
660 -(NSTableColumn *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; } | |
657 -(int)addRow:(NSArray *)input { if(data) { lastAddPoint = (int)[titles count]; [data addObjectsFromArray:input]; [titles addPointer:NULL]; return (int)[titles count]; } return 0; } | 661 -(int)addRow:(NSArray *)input { if(data) { lastAddPoint = (int)[titles count]; [data addObjectsFromArray:input]; [titles addPointer:NULL]; return (int)[titles count]; } return 0; } |
658 -(int)addRows:(int)number | 662 -(int)addRows:(int)number |
659 { | 663 { |
660 if(tvcols) | 664 if(tvcols) |
661 { | 665 { |
662 int count = (int)number * [tvcols count]; | 666 int count = (int)(number * [tvcols count]); |
663 int z; | 667 int z; |
664 | 668 |
665 lastAddPoint = (int)[titles count]; | 669 lastAddPoint = (int)[titles count]; |
666 | 670 |
667 for(z=0;z<count;z++) | 671 for(z=0;z<count;z++) |
708 -(void)setRow:(int)row title:(void *)input { if(titles && input) { [titles replacePointerAtIndex:row withPointer:input]; } } | 712 -(void)setRow:(int)row title:(void *)input { if(titles && input) { [titles replacePointerAtIndex:row withPointer:input]; } } |
709 -(void *)getRowTitle:(int)row { if(titles) { return [titles pointerAtIndex:row]; } return NULL; } | 713 -(void *)getRowTitle:(int)row { if(titles) { return [titles pointerAtIndex:row]; } return NULL; } |
710 -(id)getRow:(int)row and:(int)col { if(data) { int index = (int)(row * [tvcols count]) + col; return [data objectAtIndex:index]; } return nil; } | 714 -(id)getRow:(int)row and:(int)col { if(data) { int index = (int)(row * [tvcols count]) + col; return [data objectAtIndex:index]; } return nil; } |
711 -(int)cellType:(int)col { return [[types objectAtIndex:col] intValue]; } | 715 -(int)cellType:(int)col { return [[types objectAtIndex:col] intValue]; } |
712 -(int)lastAddPoint { return lastAddPoint; } | 716 -(int)lastAddPoint { return lastAddPoint; } |
717 -(int)lastQueryPoint { return lastQueryPoint; } | |
718 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; } | |
713 -(void)clear { if(data) { [data removeAllObjects]; while([titles count]) { [titles removePointerAtIndex:0]; } } lastAddPoint = 0; } | 719 -(void)clear { if(data) { [data removeAllObjects]; while([titles count]) { [titles removePointerAtIndex:0]; } } lastAddPoint = 0; } |
714 -(void)setup | 720 -(void)setup |
715 { | 721 { |
716 tvcols = [[NSMutableArray alloc] init]; | 722 tvcols = [[NSMutableArray alloc] init]; |
717 data = [[NSMutableArray alloc] init]; | 723 data = [[NSMutableArray alloc] init]; |
2571 * startpoint: Point to start entering text. | 2577 * startpoint: Point to start entering text. |
2572 */ | 2578 */ |
2573 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) | 2579 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) |
2574 { | 2580 { |
2575 DWMLE *mle = handle; | 2581 DWMLE *mle = handle; |
2576 [mle insertText:[ NSString stringWithUTF8String:buffer ]]; | 2582 NSTextStorage *ts = [mle textStorage]; |
2583 NSString *nstr = [NSString stringWithUTF8String:buffer]; | |
2584 NSMutableString *ms = [ts mutableString]; | |
2585 [ms insertString:nstr atIndex:(startpoint+1)]; | |
2577 return (unsigned int)strlen(buffer) + startpoint; | 2586 return (unsigned int)strlen(buffer) + startpoint; |
2578 } | 2587 } |
2579 | 2588 |
2580 /* | 2589 /* |
2581 * Grabs text from an MLE box. | 2590 * Grabs text from an MLE box. |
2585 * startpoint: Point to start grabbing text. | 2594 * startpoint: Point to start grabbing text. |
2586 * length: Amount of text to be grabbed. | 2595 * length: Amount of text to be grabbed. |
2587 */ | 2596 */ |
2588 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | 2597 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) |
2589 { | 2598 { |
2590 NSLog(@"dw_mle_export() unimplemented\n"); | 2599 DWMLE *mle = handle; |
2600 NSTextStorage *ts = [mle textStorage]; | |
2601 NSMutableString *ms = [ts mutableString]; | |
2602 strncpy(buffer, [ms UTF8String], length); | |
2591 } | 2603 } |
2592 | 2604 |
2593 /* | 2605 /* |
2594 * Obtains information about an MLE box. | 2606 * Obtains information about an MLE box. |
2595 * Parameters: | 2607 * Parameters: |
2597 * bytes: A pointer to a variable to return the total bytes. | 2609 * bytes: A pointer to a variable to return the total bytes. |
2598 * lines: A pointer to a variable to return the number of lines. | 2610 * lines: A pointer to a variable to return the number of lines. |
2599 */ | 2611 */ |
2600 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines) | 2612 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines) |
2601 { | 2613 { |
2602 NSLog(@"dw_mle_get_size() unimplemented\n"); | 2614 DWMLE *mle = handle; |
2615 NSTextStorage *ts = [mle textStorage]; | |
2616 NSMutableString *ms = [ts mutableString]; | |
2617 | |
2618 *bytes = [ms length]; | |
2619 *lines = 0; /* TODO: Line count */ | |
2603 } | 2620 } |
2604 | 2621 |
2605 /* | 2622 /* |
2606 * Deletes text from an MLE box. | 2623 * Deletes text from an MLE box. |
2607 * Parameters: | 2624 * Parameters: |
2609 * startpoint: Point to start deleting text. | 2626 * startpoint: Point to start deleting text. |
2610 * length: Amount of text to be deleted. | 2627 * length: Amount of text to be deleted. |
2611 */ | 2628 */ |
2612 void API dw_mle_delete(HWND handle, int startpoint, int length) | 2629 void API dw_mle_delete(HWND handle, int startpoint, int length) |
2613 { | 2630 { |
2614 NSLog(@"dw_mle_delete() unimplemented\n"); | 2631 DWMLE *mle = handle; |
2632 NSTextStorage *ts = [mle textStorage]; | |
2633 NSMutableString *ms = [ts mutableString]; | |
2634 [ms deleteCharactersInRange:NSMakeRange(startpoint+1, length)]; | |
2615 } | 2635 } |
2616 | 2636 |
2617 /* | 2637 /* |
2618 * Clears all text from an MLE box. | 2638 * Clears all text from an MLE box. |
2619 * Parameters: | 2639 * Parameters: |
2620 * handle: Handle to the MLE to be cleared. | 2640 * handle: Handle to the MLE to be cleared. |
2621 */ | 2641 */ |
2622 void API dw_mle_clear(HWND handle) | 2642 void API dw_mle_clear(HWND handle) |
2623 { | 2643 { |
2624 NSLog(@"dw_mle_clear() unimplemented\n"); | 2644 DWMLE *mle = handle; |
2645 NSTextStorage *ts = [mle textStorage]; | |
2646 NSMutableString *ms = [ts mutableString]; | |
2647 NSUInteger length = [ms length]; | |
2648 [ms deleteCharactersInRange:NSMakeRange(0, length)]; | |
2625 } | 2649 } |
2626 | 2650 |
2627 /* | 2651 /* |
2628 * Sets the visible line of an MLE box. | 2652 * Sets the visible line of an MLE box. |
2629 * Parameters: | 2653 * Parameters: |
2630 * handle: Handle to the MLE to be positioned. | 2654 * handle: Handle to the MLE to be positioned. |
2631 * line: Line to be visible. | 2655 * line: Line to be visible. |
2632 */ | 2656 */ |
2633 void API dw_mle_set_visible(HWND handle, int line) | 2657 void API dw_mle_set_visible(HWND handle, int line) |
2634 { | 2658 { |
2635 NSLog(@"dw_mle_clear() unimplemented\n"); | 2659 NSLog(@"dw_mle_set_visible() unimplemented\n"); |
2636 } | 2660 } |
2637 | 2661 |
2638 /* | 2662 /* |
2639 * Sets the editablity of an MLE box. | 2663 * Sets the editablity of an MLE box. |
2640 * Parameters: | 2664 * Parameters: |
2660 * handle: Handle to the MLE. | 2684 * handle: Handle to the MLE. |
2661 * state: TRUE if it wraps, FALSE if it doesn't. | 2685 * state: TRUE if it wraps, FALSE if it doesn't. |
2662 */ | 2686 */ |
2663 void API dw_mle_set_word_wrap(HWND handle, int state) | 2687 void API dw_mle_set_word_wrap(HWND handle, int state) |
2664 { | 2688 { |
2665 NSLog(@"dw_mle_set_word_wrap() unimplemented\n"); | 2689 DWMLE *mle = handle; |
2690 if(state) | |
2691 { | |
2692 [mle setHorizontallyResizable:NO]; | |
2693 } | |
2694 else | |
2695 { | |
2696 [mle setHorizontallyResizable:YES]; | |
2697 } | |
2666 } | 2698 } |
2667 | 2699 |
2668 /* | 2700 /* |
2669 * Sets the current cursor position of an MLE box. | 2701 * Sets the current cursor position of an MLE box. |
2670 * Parameters: | 2702 * Parameters: |
2695 * Parameters: | 2727 * Parameters: |
2696 * handle: Handle to the MLE to freeze. | 2728 * handle: Handle to the MLE to freeze. |
2697 */ | 2729 */ |
2698 void API dw_mle_freeze(HWND handle) | 2730 void API dw_mle_freeze(HWND handle) |
2699 { | 2731 { |
2700 NSLog(@"dw_mle_freeze() unimplemented\n"); | 2732 /* Don't think this is necessary */ |
2701 } | 2733 } |
2702 | 2734 |
2703 /* | 2735 /* |
2704 * Resumes redrawing of an MLE box. | 2736 * Resumes redrawing of an MLE box. |
2705 * Parameters: | 2737 * Parameters: |
2706 * handle: Handle to the MLE to thaw. | 2738 * handle: Handle to the MLE to thaw. |
2707 */ | 2739 */ |
2708 void API dw_mle_thaw(HWND handle) | 2740 void API dw_mle_thaw(HWND handle) |
2709 { | 2741 { |
2710 NSLog(@"dw_mle_thaw() unimplemented\n"); | 2742 /* Don't think this is necessary */ |
2711 } | 2743 } |
2712 | 2744 |
2713 /* | 2745 /* |
2714 * Create a new status text window (widget) to be packed. | 2746 * Create a new status text window (widget) to be packed. |
2715 * Parameters: | 2747 * Parameters: |
3233 [[column headerCell] setStringValue:[ NSString stringWithUTF8String:titles[z] ]]; | 3265 [[column headerCell] setStringValue:[ NSString stringWithUTF8String:titles[z] ]]; |
3234 if(flags[z] & DW_CFA_BITMAPORICON) | 3266 if(flags[z] & DW_CFA_BITMAPORICON) |
3235 { | 3267 { |
3236 NSImageCell *imagecell = [[[NSImageCell alloc] init] autorelease]; | 3268 NSImageCell *imagecell = [[[NSImageCell alloc] init] autorelease]; |
3237 [column setDataCell:imagecell]; | 3269 [column setDataCell:imagecell]; |
3270 if(z == 0 && titles[z] && strcmp(titles[z], "Icon") == 0) | |
3271 { | |
3272 [column setResizingMask:NSTableColumnNoResizing]; | |
3273 [column setWidth:20]; | |
3274 } | |
3238 } | 3275 } |
3239 [cont addTableColumn:column]; | 3276 [cont addTableColumn:column]; |
3240 [cont addColumn:column andType:(int)flags[z]]; | 3277 [cont addColumn:column andType:(int)flags[z]]; |
3241 } | 3278 } |
3242 | 3279 |
3458 * column: Zero based column of width being set. | 3495 * column: Zero based column of width being set. |
3459 * width: Width of column in pixels. | 3496 * width: Width of column in pixels. |
3460 */ | 3497 */ |
3461 void API dw_container_set_column_width(HWND handle, int column, int width) | 3498 void API dw_container_set_column_width(HWND handle, int column, int width) |
3462 { | 3499 { |
3463 NSLog(@"dw_container_set_column_width() unimplemented\n"); | 3500 DWContainer *cont = handle; |
3501 NSTableColumn *col = [cont getColumn:column]; | |
3502 | |
3503 [col setWidth:width]; | |
3464 } | 3504 } |
3465 | 3505 |
3466 /* | 3506 /* |
3467 * Sets the title of a row in the container. | 3507 * Sets the title of a row in the container. |
3468 * Parameters: | 3508 * Parameters: |
3511 * handle: Handle to the window (widget) to be deleted from. | 3551 * handle: Handle to the window (widget) to be deleted from. |
3512 * rowcount: The number of rows to be deleted. | 3552 * rowcount: The number of rows to be deleted. |
3513 */ | 3553 */ |
3514 void API dw_container_delete(HWND handle, int rowcount) | 3554 void API dw_container_delete(HWND handle, int rowcount) |
3515 { | 3555 { |
3516 NSLog(@"dw_container_delete() unimplemented\n"); | 3556 DWContainer *cont = handle; |
3557 int x; | |
3558 | |
3559 for(x=0;x<rowcount;x++) | |
3560 { | |
3561 [cont removeRow:0]; | |
3562 } | |
3517 } | 3563 } |
3518 | 3564 |
3519 /* | 3565 /* |
3520 * Scrolls container up or down. | 3566 * Scrolls container up or down. |
3521 * Parameters: | 3567 * Parameters: |
3537 * return items that are currently selected. Otherwise | 3583 * return items that are currently selected. Otherwise |
3538 * it will return all records in the container. | 3584 * it will return all records in the container. |
3539 */ | 3585 */ |
3540 char * API dw_container_query_start(HWND handle, unsigned long flags) | 3586 char * API dw_container_query_start(HWND handle, unsigned long flags) |
3541 { | 3587 { |
3542 NSLog(@"dw_container_query_start() unimplemented\n"); | 3588 DWContainer *cont = handle; |
3543 return NULL; | 3589 NSIndexSet *selected = [cont selectedRowIndexes]; |
3590 NSUInteger result = [selected indexGreaterThanOrEqualToIndex:0]; | |
3591 char *retval = NULL; | |
3592 | |
3593 if(result != NSNotFound) | |
3594 { | |
3595 retval = [cont getRowTitle:(int)result]; | |
3596 [cont setLastQueryPoint:(int)result]; | |
3597 } | |
3598 [selected release]; | |
3599 return retval; | |
3544 } | 3600 } |
3545 | 3601 |
3546 /* | 3602 /* |
3547 * Continues an existing query of a container. | 3603 * Continues an existing query of a container. |
3548 * Parameters: | 3604 * Parameters: |
3551 * return items that are currently selected. Otherwise | 3607 * return items that are currently selected. Otherwise |
3552 * it will return all records in the container. | 3608 * it will return all records in the container. |
3553 */ | 3609 */ |
3554 char * API dw_container_query_next(HWND handle, unsigned long flags) | 3610 char * API dw_container_query_next(HWND handle, unsigned long flags) |
3555 { | 3611 { |
3556 NSLog(@"dw_container_query_next() unimplemented\n"); | 3612 DWContainer *cont = handle; |
3557 return NULL; | 3613 int lastQueryPoint = [cont lastQueryPoint]; |
3614 NSIndexSet *selected = [cont selectedRowIndexes]; | |
3615 NSUInteger result = [selected indexGreaterThanIndex:lastQueryPoint]; | |
3616 char *retval = NULL; | |
3617 | |
3618 if(result != NSNotFound) | |
3619 { | |
3620 retval = [cont getRowTitle:(int)result]; | |
3621 [cont setLastQueryPoint:(int)result]; | |
3622 } | |
3623 [selected release]; | |
3624 return retval; | |
3558 } | 3625 } |
3559 | 3626 |
3560 /* | 3627 /* |
3561 * Cursors the item with the text speficied, and scrolls to that item. | 3628 * Cursors the item with the text speficied, and scrolls to that item. |
3562 * Parameters: | 3629 * Parameters: |
3563 * handle: Handle to the window (widget) to be queried. | 3630 * handle: Handle to the window (widget) to be queried. |
3564 * text: Text usually returned by dw_container_query(). | 3631 * text: Text usually returned by dw_container_query(). |
3565 */ | 3632 */ |
3566 void API dw_container_cursor(HWND handle, char *text) | 3633 void API dw_container_cursor(HWND handle, char *text) |
3567 { | 3634 { |
3568 NSLog(@"dw_container_cursor() unimplemented\n"); | 3635 DWContainer *cont = handle; |
3636 char *thistext; | |
3637 int x, count = (int)[cont numberOfRowsInTableView:cont]; | |
3638 | |
3639 for(x=0;x<count;x++) | |
3640 { | |
3641 thistext = [cont getRowTitle:x]; | |
3642 | |
3643 if(thistext == text) | |
3644 { | |
3645 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x]; | |
3646 | |
3647 [cont selectRowIndexes:selected byExtendingSelection:YES]; | |
3648 [selected release]; | |
3649 } | |
3650 } | |
3569 } | 3651 } |
3570 | 3652 |
3571 /* | 3653 /* |
3572 * Deletes the item with the text speficied. | 3654 * Deletes the item with the text speficied. |
3573 * Parameters: | 3655 * Parameters: |
3574 * handle: Handle to the window (widget). | 3656 * handle: Handle to the window (widget). |
3575 * text: Text usually returned by dw_container_query(). | 3657 * text: Text usually returned by dw_container_query(). |
3576 */ | 3658 */ |
3577 void API dw_container_delete_row(HWND handle, char *text) | 3659 void API dw_container_delete_row(HWND handle, char *text) |
3578 { | 3660 { |
3579 NSLog(@"dw_container_delete_row() unimplemented\n"); | 3661 DWContainer *cont = handle; |
3662 char *thistext; | |
3663 int x, count = (int)[cont numberOfRowsInTableView:cont]; | |
3664 | |
3665 for(x=0;x<count;x++) | |
3666 { | |
3667 thistext = [cont getRowTitle:x]; | |
3668 | |
3669 if(thistext == text) | |
3670 { | |
3671 [cont removeRow:x]; | |
3672 return; | |
3673 } | |
3674 } | |
3580 } | 3675 } |
3581 | 3676 |
3582 /* | 3677 /* |
3583 * Optimizes the column widths so that all data is visible. | 3678 * Optimizes the column widths so that all data is visible. |
3584 * Parameters: | 3679 * Parameters: |
4596 tmp ^= mask; | 4691 tmp ^= mask; |
4597 tmp |= style; | 4692 tmp |= style; |
4598 | 4693 |
4599 [window setStyleMask:tmp]; | 4694 [window setStyleMask:tmp]; |
4600 } | 4695 } |
4696 else if([object isMemberOfClass:[NSTextView class]]) | |
4697 { | |
4698 NSTextView *tv = handle; | |
4699 [tv setAlignment:(style & mask)]; | |
4700 } | |
4601 } | 4701 } |
4602 | 4702 |
4603 /* | 4703 /* |
4604 * Sets the default focus item for a window/dialog. | 4704 * Sets the default focus item for a window/dialog. |
4605 * Parameters: | 4705 * Parameters: |
4811 { | 4911 { |
4812 NSImageView *iv = handle; | 4912 NSImageView *iv = handle; |
4813 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; | 4913 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
4814 NSImage *pixmap = [[NSImage alloc] initWithData:thisdata]; | 4914 NSImage *pixmap = [[NSImage alloc] initWithData:thisdata]; |
4815 | 4915 |
4816 [iv setImage:pixmap]; | 4916 if(pixmap) |
4917 { | |
4918 [iv setImage:pixmap]; | |
4919 } | |
4817 } | 4920 } |
4818 } | 4921 } |
4819 | 4922 |
4820 /* | 4923 /* |
4821 * Sets the bitmap used for a given static window. | 4924 * Sets the bitmap used for a given static window. |
4825 * (pass 0 if you use the filename param) | 4928 * (pass 0 if you use the filename param) |
4826 * filename: a path to a file (Bitmap on OS/2 or | 4929 * filename: a path to a file (Bitmap on OS/2 or |
4827 * Windows and a pixmap on Unix, pass | 4930 * Windows and a pixmap on Unix, pass |
4828 * NULL if you use the id param) | 4931 * NULL if you use the id param) |
4829 */ | 4932 */ |
4830 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename) | 4933 void API dw_window_set_bitmap(HWND handle, unsigned long resid, char *filename) |
4831 { | 4934 { |
4832 NSObject *object = handle; | 4935 NSObject *object = handle; |
4833 if([ object isKindOfClass:[ NSImageView class ] ]) | 4936 if([ object isKindOfClass:[ NSImageView class ] ]) |
4834 { | 4937 { |
4835 NSImageView *iv = handle; | 4938 NSImageView *iv = handle; |
4836 NSImage *pixmap = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; | 4939 NSImage *bitmap = NULL; |
4940 | |
4941 if(filename) | |
4942 { | |
4943 bitmap = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; | |
4944 } | |
4945 else if(resid > 0 && resid < 65536) | |
4946 { | |
4947 bitmap = dw_icon_load(0, resid); | |
4948 } | |
4837 | 4949 |
4838 [iv setImage:pixmap]; | 4950 if(bitmap) |
4951 { | |
4952 [iv setImage:bitmap]; | |
4953 } | |
4839 } | 4954 } |
4840 } | 4955 } |
4841 | 4956 |
4842 /* | 4957 /* |
4843 * Sets the icon used for a given window. | 4958 * Sets the icon used for a given window. |