comparison mac/dw.m @ 749:9e147366147b

Code cleanup.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 16 Mar 2011 15:35:45 +0000
parents f39745844175
children eba6ab48c952
comparison
equal deleted inserted replaced
748:f39745844175 749:9e147366147b
2637 * text: Bubble help text to be displayed. 2637 * text: Bubble help text to be displayed.
2638 * id: An ID of a bitmap in the resource file. 2638 * id: An ID of a bitmap in the resource file.
2639 */ 2639 */
2640 HWND API dw_bitmapbutton_new(char *text, ULONG resid) 2640 HWND API dw_bitmapbutton_new(char *text, ULONG resid)
2641 { 2641 {
2642 /* TODO: Implement tooltips */
2643 NSBundle *bundle = [NSBundle mainBundle]; 2642 NSBundle *bundle = [NSBundle mainBundle];
2644 NSString *respath = [bundle resourcePath]; 2643 NSString *respath = [bundle resourcePath];
2645 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; 2644 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid];
2646 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; 2645 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
2647 DWButton *button = _button_new("", resid); 2646 DWButton *button = _button_new("", resid);
2648 if(image) 2647 if(image)
2649 { 2648 {
2650 [button setImage:image]; 2649 [button setImage:image];
2651 [button setButtonType:NSMomentaryLight]; 2650 [button setButtonType:NSMomentaryLight];
2652 [ button setBordered:NO]; 2651 [button setBordered:NO];
2653 } 2652 }
2654 [button setToolTip:[NSString stringWithUTF8String:text]]; 2653 [button setToolTip:[NSString stringWithUTF8String:text]];
2655 [image release]; 2654 [image release];
2656 return button; 2655 return button;
2657 } 2656 }
2658 2657
2659 /* 2658 /*
2660 * Create a new bitmap button window (widget) to be packed from a file. 2659 * Create a new bitmap button window (widget) to be packed from a file.
2661 * Parameters: 2660 * Parameters:
2672 if(!image) 2671 if(!image)
2673 { 2672 {
2674 nstr = [nstr stringByAppendingString:@".png"]; 2673 nstr = [nstr stringByAppendingString:@".png"];
2675 image = [[NSImage alloc] initWithContentsOfFile:nstr]; 2674 image = [[NSImage alloc] initWithContentsOfFile:nstr];
2676 } 2675 }
2677 DWButton *button = _button_new("", cid); 2676 DWButton *button = _button_new("", cid);
2678 if(image) 2677 if(image)
2679 { 2678 {
2680 [button setImage:image]; 2679 [button setImage:image];
2681 [button setButtonType:NSMomentaryLight]; 2680 [button setButtonType:NSMomentaryLight];
2682 [button setBordered:NO]; 2681 [button setBordered:NO];
2683 } 2682 }
2684 [button setToolTip:[NSString stringWithUTF8String:text]]; 2683 [button setToolTip:[NSString stringWithUTF8String:text]];
2685 [image release]; 2684 [image release];
2686 return button; 2685 return button;
2687 } 2686 }
2688 2687
2689 /* 2688 /*
2690 * Create a new bitmap button window (widget) to be packed from data. 2689 * Create a new bitmap button window (widget) to be packed from data.
2691 * Parameters: 2690 * Parameters:
2695 * (BMP or ICO on OS/2 or Windows, XPM on Unix) 2694 * (BMP or ICO on OS/2 or Windows, XPM on Unix)
2696 * len: length of str 2695 * len: length of str
2697 */ 2696 */
2698 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long cid, char *data, int len) 2697 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long cid, char *data, int len)
2699 { 2698 {
2700 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; 2699 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len];
2701 NSImage *image = [[NSImage alloc] initWithData:thisdata]; 2700 NSImage *image = [[NSImage alloc] initWithData:thisdata];
2702 DWButton *button = _button_new("", cid); 2701 DWButton *button = _button_new("", cid);
2703 if(image) 2702 if(image)
2704 { 2703 {
2705 [button setImage:image]; 2704 [button setImage:image];
2706 [button setButtonType:NSMomentaryLight]; 2705 [button setButtonType:NSMomentaryLight];
2707 [button setBordered:NO]; 2706 [button setBordered:NO];
2708 } 2707 }
2709 [button setToolTip:[NSString stringWithUTF8String:text]]; 2708 [button setToolTip:[NSString stringWithUTF8String:text]];
2710 [image release]; 2709 [image release];
2711 return button; 2710 return button;
2712 } 2711 }
2713 2712
2714 /* 2713 /*
2715 * Create a new spinbutton window (widget) to be packed. 2714 * Create a new spinbutton window (widget) to be packed.
2716 * Parameters: 2715 * Parameters: