Mercurial > dwindows
comparison mac/dw.m @ 748:f39745844175
Added tooltips to bitmap buttons... and made a change to the look when the image is present...
Not sure what look is best... the borderless buttons look best on the toolbar for my application.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 16 Mar 2011 15:31:01 +0000 |
parents | a4f99795ff26 |
children | 9e147366147b |
comparison
equal
deleted
inserted
replaced
747:a4f99795ff26 | 748:f39745844175 |
---|---|
2643 NSBundle *bundle = [NSBundle mainBundle]; | 2643 NSBundle *bundle = [NSBundle mainBundle]; |
2644 NSString *respath = [bundle resourcePath]; | 2644 NSString *respath = [bundle resourcePath]; |
2645 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; | 2645 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
2646 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; | 2646 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
2647 DWButton *button = _button_new("", resid); | 2647 DWButton *button = _button_new("", resid); |
2648 [button setImage:image]; | 2648 if(image) |
2649 [button setButtonType:NSMomentaryLight]; | 2649 { |
2650 [button setBordered:NO]; | 2650 [button setImage:image]; |
2651 [button setButtonType:NSMomentaryLight]; | |
2652 [ button setBordered:NO]; | |
2653 } | |
2654 [button setToolTip:[NSString stringWithUTF8String:text]]; | |
2651 [image release]; | 2655 [image release]; |
2652 return button; | 2656 return button; |
2653 } | 2657 } |
2654 | 2658 |
2655 /* | 2659 /* |
2669 { | 2673 { |
2670 nstr = [nstr stringByAppendingString:@".png"]; | 2674 nstr = [nstr stringByAppendingString:@".png"]; |
2671 image = [[NSImage alloc] initWithContentsOfFile:nstr]; | 2675 image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
2672 } | 2676 } |
2673 DWButton *button = _button_new("", cid); | 2677 DWButton *button = _button_new("", cid); |
2674 [button setImage:image]; | 2678 if(image) |
2679 { | |
2680 [button setImage:image]; | |
2681 [button setButtonType:NSMomentaryLight]; | |
2682 [button setBordered:NO]; | |
2683 } | |
2684 [button setToolTip:[NSString stringWithUTF8String:text]]; | |
2675 [image release]; | 2685 [image release]; |
2676 return button; | 2686 return button; |
2677 } | 2687 } |
2678 | 2688 |
2679 /* | 2689 /* |
2688 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long cid, char *data, int len) | 2698 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long cid, char *data, int len) |
2689 { | 2699 { |
2690 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; | 2700 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
2691 NSImage *image = [[NSImage alloc] initWithData:thisdata]; | 2701 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
2692 DWButton *button = _button_new("", cid); | 2702 DWButton *button = _button_new("", cid); |
2693 [button setImage:image]; | 2703 if(image) |
2704 { | |
2705 [button setImage:image]; | |
2706 [button setButtonType:NSMomentaryLight]; | |
2707 [button setBordered:NO]; | |
2708 } | |
2709 [button setToolTip:[NSString stringWithUTF8String:text]]; | |
2694 [image release]; | 2710 [image release]; |
2695 return button; | 2711 return button; |
2696 } | 2712 } |
2697 | 2713 |
2698 /* | 2714 /* |