comparison mac/dw.m @ 1906:fac81560eb09

Fix a number of warning generated by the new clang in XCode 6.3, assigning "id" to "Box *" now generates a warning and requires a cast. Also minor fix for yosemite Combobox sizes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 21 Apr 2015 17:12:09 +0000
parents 0d67f00866b7
children 54f9ec5bb793
comparison
equal deleted inserted replaced
1905:0d67f00866b7 1906:fac81560eb09
1 /* 1 /*
2 * Dynamic Windows: 2 * Dynamic Windows:
3 * A GTK like implementation of the MacOS GUI using Cocoa 3 * A GTK like implementation of the MacOS GUI using Cocoa
4 * 4 *
5 * (C) 2011-2013 Brian Smith <brian@dbsoft.org> 5 * (C) 2011-2015 Brian Smith <brian@dbsoft.org>
6 * (C) 2011 Mark Hessling <mark@rexx.org> 6 * (C) 2011 Mark Hessling <mark@rexx.org>
7 * 7 *
8 * Requires 10.5 or later. 8 * Requires 10.5 or later.
9 * clang -std=c99 -g -o dwtest -D__MAC__ -I. dwtest.c mac/dw.m -framework Cocoa -framework WebKit 9 * clang -std=c99 -g -o dwtest -D__MAC__ -I. dwtest.c mac/dw.m -framework Cocoa -framework WebKit
10 */ 10 */
2760 { 2760 {
2761 id handle = thisbox->items[z].hwnd; 2761 id handle = thisbox->items[z].hwnd;
2762 2762
2763 if(thisbox->items[z].type == TYPEBOX) 2763 if(thisbox->items[z].type == TYPEBOX)
2764 { 2764 {
2765 Box *tmp = [handle box]; 2765 Box *tmp = (Box *)[handle box];
2766 2766
2767 if(tmp) 2767 if(tmp)
2768 { 2768 {
2769 _handle_resize_events(tmp); 2769 _handle_resize_events(tmp);
2770 } 2770 }
2800 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; 2800 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem];
2801 id view = [notepage view]; 2801 id view = [notepage view];
2802 2802
2803 if([view isMemberOfClass:[DWBox class]]) 2803 if([view isMemberOfClass:[DWBox class]])
2804 { 2804 {
2805 Box *box = [view box]; 2805 Box *box = (Box *)[view box];
2806 _handle_resize_events(box); 2806 _handle_resize_events(box);
2807 } 2807 }
2808 } 2808 }
2809 /* Handle laying out scrollviews... if required space is less 2809 /* Handle laying out scrollviews... if required space is less
2810 * than available space, then expand. Otherwise use required space. 2810 * than available space, then expand. Otherwise use required space.
2874 int itempad, itemwidth, itemheight; 2874 int itempad, itemwidth, itemheight;
2875 2875
2876 if(thisbox->items[z].type == TYPEBOX) 2876 if(thisbox->items[z].type == TYPEBOX)
2877 { 2877 {
2878 id box = thisbox->items[z].hwnd; 2878 id box = thisbox->items[z].hwnd;
2879 Box *tmp = [box box]; 2879 Box *tmp = (Box *)[box box];
2880 2880
2881 if(tmp) 2881 if(tmp)
2882 { 2882 {
2883 /* On the first pass calculate the box contents */ 2883 /* On the first pass calculate the box contents */
2884 if(pass == 1) 2884 if(pass == 1)
3013 3013
3014 /* After placing a box... place its components */ 3014 /* After placing a box... place its components */
3015 if(thisbox->items[z].type == TYPEBOX) 3015 if(thisbox->items[z].type == TYPEBOX)
3016 { 3016 {
3017 id box = thisbox->items[z].hwnd; 3017 id box = thisbox->items[z].hwnd;
3018 Box *tmp = [box box]; 3018 Box *tmp = (Box *)[box box];
3019 3019
3020 if(tmp) 3020 if(tmp)
3021 { 3021 {
3022 (*depth)++; 3022 (*depth)++;
3023 _resize_box(tmp, depth, width, height, pass); 3023 _resize_box(tmp, depth, width, height, pass);
3032 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; 3032 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem];
3033 id view = [notepage view]; 3033 id view = [notepage view];
3034 3034
3035 if([view isMemberOfClass:[DWBox class]]) 3035 if([view isMemberOfClass:[DWBox class]])
3036 { 3036 {
3037 Box *box = [view box]; 3037 Box *box = (Box *)[view box];
3038 NSSize size = [view frame].size; 3038 NSSize size = [view frame].size;
3039 _do_resize(box, size.width, size.height); 3039 _do_resize(box, size.width, size.height);
3040 _handle_resize_events(box); 3040 _handle_resize_events(box);
3041 } 3041 }
3042 } 3042 }
3927 /* Spinbuttons don't need to be as wide */ 3927 /* Spinbuttons don't need to be as wide */
3928 if([object isMemberOfClass:[ DWSpinButton class]]) 3928 if([object isMemberOfClass:[ DWSpinButton class]])
3929 thiswidth = 50; 3929 thiswidth = 50;
3930 else 3930 else
3931 thiswidth = 150; 3931 thiswidth = 150;
3932 /* Spinbuttons don't need to be as wide */ 3932 /* Comboboxes need some extra height for the border...
3933 * and even more with the new look in Yosemite.
3934 */
3933 if([object isMemberOfClass:[ DWComboBox class]]) 3935 if([object isMemberOfClass:[ DWComboBox class]])
3934 extraheight = 4; 3936 extraheight = DWOSMinor < 10 ? 4 : 8;
3935 } 3937 }
3936 else 3938 else
3937 nsstr = [object stringValue]; 3939 nsstr = [object stringValue];
3938 3940
3939 if(font) 3941 if(font)
9574 9576
9575 /* 9577 /*
9576 * The following is an attempt to dynamically size a window based on the size of its 9578 * The following is an attempt to dynamically size a window based on the size of its
9577 * children before realization. Only applicable when width or height is less than one. 9579 * children before realization. Only applicable when width or height is less than one.
9578 */ 9580 */
9579 if((width < 1 || height < 1) && (thisbox = [[window contentView] box])) 9581 if((width < 1 || height < 1) && (thisbox = (Box *)[[window contentView] box]))
9580 { 9582 {
9581 int depth = 0; 9583 int depth = 0;
9582 9584
9583 /* Calculate space requirements */ 9585 /* Calculate space requirements */
9584 _resize_box(thisbox, &depth, (int)width, (int)height, 1); 9586 _resize_box(thisbox, &depth, (int)width, (int)height, 1);
9607 9609
9608 if([object isMemberOfClass:[DWWindow class]]) 9610 if([object isMemberOfClass:[DWWindow class]])
9609 { 9611 {
9610 Box *thisbox; 9612 Box *thisbox;
9611 9613
9612 if((thisbox = [[object contentView] box])) 9614 if((thisbox = (Box *)[[object contentView] box]))
9613 { 9615 {
9614 int depth = 0; 9616 int depth = 0;
9615 NSRect frame; 9617 NSRect frame;
9616 9618
9617 /* Calculate space requirements */ 9619 /* Calculate space requirements */
9627 } 9629 }
9628 else if([object isMemberOfClass:[DWBox class]]) 9630 else if([object isMemberOfClass:[DWBox class]])
9629 { 9631 {
9630 Box *thisbox; 9632 Box *thisbox;
9631 9633
9632 if((thisbox = [object box])) 9634 if((thisbox = (Box *)[object box]))
9633 { 9635 {
9634 int depth = 0; 9636 int depth = 0;
9635 9637
9636 /* Calculate space requirements */ 9638 /* Calculate space requirements */
9637 _resize_box(thisbox, &depth, 0, 0, 1); 9639 _resize_box(thisbox, &depth, 0, 0, 1);