# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1298986360 0 # Node ID 99002595f549d1e2f6f541f46acfa12268bda368 # Parent 9861d264925dc5f25e0c2cdb0fa5a6604f5cb9ea Fixes for dw_splitbar_set() not working on an unsized window. diff -r 9861d264925d -r 99002595f549 mac/dw.m --- a/mac/dw.m Tue Mar 01 04:37:11 2011 +0000 +++ b/mac/dw.m Tue Mar 01 13:32:40 2011 +0000 @@ -459,12 +459,20 @@ @end /* Subclass for a splitbar type */ -@interface DWSplitBar : NSSplitView { } -- (void)splitViewDidResizeSubviews:(NSNotification *)aNotification; +@interface DWSplitBar : NSSplitView +{ + void *userdata; + float percent; +} +-(void)splitViewDidResizeSubviews:(NSNotification *)aNotification; +-(void *)userdata; +-(void)setUserdata:(void *)input; +-(float)percent; +-(void)setPercent:(float)input; @end @implementation DWSplitBar -- (void)splitViewDidResizeSubviews:(NSNotification *)aNotification +-(void)splitViewDidResizeSubviews:(NSNotification *)aNotification { NSArray *views = [self subviews]; id object; @@ -480,6 +488,10 @@ } } } +-(void *)userdata { return userdata; } +-(void)setUserdata:(void *)input { userdata = input; } +-(float)percent { return percent; } +-(void)setPercent:(float)input { percent = input; } @end /* Subclass for a slider type */ @@ -1186,6 +1198,17 @@ { _event_handler(handle, nil, 1); } + else if([handle isMemberOfClass:[DWSplitBar class]] && size.width > 20 && size.height > 20) + { + DWSplitBar *split = (DWSplitBar *)handle; + float percent = [split percent]; + + if(percent > 0) + { + dw_splitbar_set(handle, percent); + [split setPercent:0]; + } + } if(thisbox->type == DW_HORZ) currentx += width + vectorx + (pad * 2); @@ -3842,15 +3865,27 @@ DWSplitBar *split = handle; NSRect rect = [split frame]; float pos; + /* Calculate the position based on the size */ if([split isVertical]) { + pos = rect.size.width * (percent / 100.0); + } + else + { pos = rect.size.height * (percent / 100.0); } + if(pos > 0) + { + [split setPosition:pos ofDividerAtIndex:0]; + } else { - pos = rect.size.width * (percent / 100.0); + /* If we have no size.. wait until the resize + * event when we get an actual size to try + * to set the splitbar again. + */ + [split setPercent:percent]; } - [split setPosition:pos ofDividerAtIndex:0]; } /* @@ -3868,13 +3903,13 @@ float pos, total, retval = 0.0; if([split isVertical]) { - total = rect1.size.height; - pos = rect2.size.height; + total = rect1.size.width; + pos = rect2.size.width; } else { - total = rect1.size.width; - pos = rect2.size.width; + total = rect1.size.height; + pos = rect2.size.height; } if(total > 0) {