Today we're going to add resizing splitters between each of our panes, which will allow us to resize each pane independently. To do this, first we have to give all of our panes IDs. That is because the ResizingSplitter takes an array of pane IDs as arguments to tell it which panes it is going to be in charge of manipulating. The following are our changes (Note, this still uses my ClassHierarchyBrowser work, not Vassili's) :
The above is published as version 1.10 in the Package named "PollockBlog" on the Cincom public repository.
As you see, our code really doesn't change except for using actual named panes, instead of the default names.
To add the resizers, we'll add a method to create and add them, name it #addResizingSplitters, and call it from the bottom of our #createInterface method:
The above is published as version 1.11 in the Package named "PollockBlog" on the Cincom public repository.
In the above, we basically repeat the same code three times over, with variations for each individual resizer. The first thing we see is the first resizer being told to #beVertical. By default, ResizingSplitters are horizontal. No special reason for that, the default had to be either vertical or horizontal, and I chose vertical. Because Pollock is dynamic, it also has a #beHorizontal method, so you can change a ResizingSplitter from one to the other and back.
Next we see we send the resizer the #raisedBorder: message, passing in false. By default, a resizer will have a platform faithful raised border on all of it's edges. However, in our case, the panes themselves create a raised look, because we set them 2 pixels apart. Telling the resizer not to have the raised border makes it blend into the background.
Next we set the frame. Notice, we still use the fractional frame... it's very handy. For the two vertical resizers, we make the left and right fraction the same within each frame. This makes sure they are between where we laid out our panes. We give them a bit of width, by telling them that their left and right offsets (from the fraction position) is one away from the center.
Next, we have two methods #aboveLeftWidgets: and #belowRightWidgets:. Each of these methods take a collection of symbols that are IDs of widgets the resizer is supposed to manipulate. When the resizer is vertical, you pay attention to the "Left" and "Right" part of the method names. When the resizer is horizontal, you pay attention to the "above" and "below" part of the method names. To be complete, we added IDs to all the resizers... which is important for the final resizer.
The reason this is important for the final, horizontal resizer, is because we not only want to manage the Tree and two ListBoxes above the TextEdit, we also want to manage the resizers which are between them. This way, when we resize up or down, the resizer stays within the area between the upper panes.
Go ahead and try it out....
ClassHierarchyBrowser open
Except for the flicker (a whole other battle that Pollock will tackle in the following months before it is released as Production 1), it just plain works! By now, you should be getting into the rhythm of Pollock panes. Instantiate one, give it a meaningful frame, send it some configuration messages, and finally add it to the window.
Well, I'm sure eventually Vassili will show us a better way to write the above code on his blog. Next time, we'll add dynamic scrollbars to the two ListBoxes, so that they only show when they're needed... another nice feature of Pollock.