/ Published in: Objective C
This provides a nice split view resizing method with a minimum size restraint. You HAVE to specify MIN_LEFT_PANE_W for this to work.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// http://www.wodeveloper.com/omniLists/macosx-dev/2003/May/msg00261.html // grab the splitviews float dividerThickness = [sender dividerThickness]; // get the different frames NSRect newFrame = [sender frame]; NSRect leftFrame = [left frame]; NSRect rightFrame = [right frame]; // change in width for this redraw int dWidth = newFrame.size.width - oldSize.width; // ratio of the left frame width to the right used for resize speed when both panes are being resized float rLeftRight = (leftFrame.size.width - MIN_LEFT_PANEL_W) / rightFrame.size.width; // resize the height of the left leftFrame.size.height = newFrame.size.height; leftFrame.origin = NSMakePoint(0,0); // resize the left & right pane equally if we are shrinking the frame // resize the right pane only if we are increasing the frame // when resizing lock at minimum width for the left panel if(leftFrame.size.width <= MIN_LEFT_PANEL_W && dWidth < 0) { rightFrame.size.width += dWidth; } else if(dWidth > 0) { rightFrame.size.width += dWidth; } else { leftFrame.size.width += dWidth * rLeftRight; rightFrame.size.width += dWidth * (1 - rLeftRight); } rightFrame.size.width = newFrame.size.width - leftFrame.size.width - dividerThickness; rightFrame.size.height = newFrame.size.height; rightFrame.origin.x = leftFrame.size.width + dividerThickness; [left setFrame:leftFrame]; [right setFrame:rightFrame]; }