comparison mac/dw.m @ 921:4c9bef883b14

Fixes for groupbox padding calculation on Mac. There are two pieces of code in this commit... added missing calculations to the groupbox padding... and also disabled code to calculate the border size... I am using the calculated values hardcoded. The reason for this is at the time we need to calculate these values we can't because it is prior to layout. I need to go back and see if I can calculate and cache these values instead of hardcoding.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 22 Apr 2011 09:42:41 +0000
parents f47d5fa72f84
children 07f9a73c6847
comparison
equal deleted inserted replaced
920:f47d5fa72f84 921:4c9bef883b14
1982 } 1982 }
1983 } 1983 }
1984 } 1984 }
1985 } 1985 }
1986 1986
1987 /* Default border is 5.0 according to the documentation */
1988 #define _DW_GROUPBOX_BORDER 5
1989
1990 /* This function calculates how much space the widgets and boxes require 1987 /* This function calculates how much space the widgets and boxes require
1991 * and does expansion as necessary. 1988 * and does expansion as necessary.
1992 */ 1989 */
1993 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, 1990 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy,
1994 int pass, int *usedpadx, int *usedpady) 1991 int pass, int *usedpadx, int *usedpady)
2008 DWGroupBox *groupbox = thisbox->grouphwnd; 2005 DWGroupBox *groupbox = thisbox->grouphwnd;
2009 NSRect titleRect; 2006 NSRect titleRect;
2010 2007
2011 /* Get the title size for a more accurate groupbox padding size */ 2008 /* Get the title size for a more accurate groupbox padding size */
2012 titleRect = [groupbox titleRect]; 2009 titleRect = [groupbox titleRect];
2013 thisbox->grouppadx = _DW_GROUPBOX_BORDER * 2; 2010 thisbox->grouppadx = 16;
2014 thisbox->grouppady = (_DW_GROUPBOX_BORDER * 2) + titleRect.size.height; 2011 thisbox->grouppady = 9 + titleRect.size.height;
2015 2012
2016 (*usedx) += thisbox->grouppadx; 2013 (*usedx) += thisbox->grouppadx;
2017 (*usedpadx) += thisbox->grouppadx; 2014 (*usedpadx) += thisbox->grouppadx;
2018 (*usedy) += thisbox->grouppady; 2015 (*usedy) += thisbox->grouppady;
2019 (*usedpady) += thisbox->grouppady; 2016 (*usedpady) += thisbox->grouppady;
2071 tmp->xratio = thisbox->xratio; 2068 tmp->xratio = thisbox->xratio;
2072 tmp->yratio = thisbox->yratio; 2069 tmp->yratio = thisbox->yratio;
2073 2070
2074 if(thisbox->type == DW_VERT) 2071 if(thisbox->type == DW_VERT)
2075 { 2072 {
2076 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) 2073 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppady;
2077 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))); 2074
2075 if((thisbox->items[z].width - tmppad)!=0)
2076 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmppad))/((float)(thisbox->items[z].width-tmppad));
2078 } 2077 }
2079 else 2078 else
2080 { 2079 {
2081 if((thisbox->items[z].width-tmp->upx)!=0) 2080 if((thisbox->items[z].width-tmp->upx)!=0)
2082 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); 2081 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx));
2083 } 2082 }
2084 if(thisbox->type == DW_HORZ) 2083 if(thisbox->type == DW_HORZ)
2085 { 2084 {
2086 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) 2085 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppadx;
2087 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))); 2086
2087 if((thisbox->items[z].height-tmppad)!=0)
2088 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmppad))/((float)(thisbox->items[z].height-tmppad));
2088 } 2089 }
2089 else 2090 else
2090 { 2091 {
2091 if((thisbox->items[z].height-tmp->upy)!=0) 2092 if((thisbox->items[z].height-tmp->upy)!=0)
2092 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); 2093 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy));
2112 2113
2113 if(pass > 1 && *depth > 0) 2114 if(pass > 1 && *depth > 0)
2114 { 2115 {
2115 if(thisbox->type == DW_VERT) 2116 if(thisbox->type == DW_VERT)
2116 { 2117 {
2117 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) 2118 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppadx;
2118 thisbox->items[z].xratio = 1.0; 2119
2119 else 2120 if((thisbox->minwidth-tmppad) == 0)
2120 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); 2121 thisbox->items[z].xratio = 1.0;
2122 else
2123 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-tmppad))/((float)(thisbox->minwidth-tmppad));
2121 } 2124 }
2122 else 2125 else
2123 { 2126 {
2124 if(thisbox->minwidth-thisbox->upx == 0) 2127 if(thisbox->minwidth-thisbox->upx == 0)
2125 thisbox->items[z].xratio = 1.0; 2128 thisbox->items[z].xratio = 1.0;
2127 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); 2130 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
2128 } 2131 }
2129 2132
2130 if(thisbox->type == DW_HORZ) 2133 if(thisbox->type == DW_HORZ)
2131 { 2134 {
2132 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) 2135 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppady;
2133 thisbox->items[z].yratio = 1.0; 2136
2134 else 2137 if((thisbox->minheight-tmppad) == 0)
2135 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); 2138 thisbox->items[z].yratio = 1.0;
2139 else
2140 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-tmppad))/((float)(thisbox->minheight-tmppad));
2136 } 2141 }
2137 else 2142 else
2138 { 2143 {
2139 if(thisbox->minheight-thisbox->upy == 0) 2144 if(thisbox->minheight-thisbox->upy == 0)
2140 thisbox->items[z].yratio = 1.0; 2145 thisbox->items[z].yratio = 1.0;
2382 { 2387 {
2383 dw_splitbar_set(handle, percent); 2388 dw_splitbar_set(handle, percent);
2384 [split setPercent:0]; 2389 [split setPercent:0];
2385 } 2390 }
2386 } 2391 }
2387 2392 #if 0
2393 /* Used this to figure out the groupbox border size...
2394 * Groupbox size 520x607 content 504x584 title 280x14 border 520x600 diff 16x9
2395 */
2396 else if([handle isMemberOfClass:[DWGroupBox class]])
2397 {
2398 DWGroupBox *groupbox = thisbox->items[z].hwnd;
2399 NSSize contentSize = [[groupbox contentView] frame].size;
2400 NSSize titleSize = [groupbox titleRect].size;
2401 NSSize borderSize = [groupbox borderRect].size;
2402
2403 NSLog(@"Groupbox size %dx%d content %dx%d title %dx%d border %dx%d diff %dx%d",
2404 (int)size.width, (int)size.height,
2405 (int)contentSize.width, (int)contentSize.height,
2406 (int)titleSize.width, (int)titleSize.height,
2407 (int)borderSize.width, (int)borderSize.height,
2408 (int)(size.width-contentSize.width), (int)((size.height-contentSize.height)-titleSize.height));
2409 }
2410 #endif
2388 if(thisbox->type == DW_HORZ) 2411 if(thisbox->type == DW_HORZ)
2389 currentx += width + vectorx + (pad * 2); 2412 currentx += width + vectorx + (pad * 2);
2390 if(thisbox->type == DW_VERT) 2413 if(thisbox->type == DW_VERT)
2391 currenty += height + vectory + (pad * 2); 2414 currenty += height + vectory + (pad * 2);
2392 } 2415 }