Hi all,
Has anybody tried to control how far you can move the splitter bar? I've got two containers, one containing a list and a couple of buttons and fields next to the list, and one containing a multi-line text box. Now I'm trying to prevent the 1st container to become too small to make sure that the controls always stay visible. Anybody any ideas? Cheers, Ted www.tedbracht.co.uk |
Ted,
> Has anybody tried to control how far you can move the splitter bar? > > I've got two containers, one containing a list and a couple of buttons and > fields next to the list, and one containing a multi-line text box. Now I'm > trying to prevent the 1st container to become too small to make sure that > the controls always stay visible. > > Anybody any ideas? A bad one :( Worst case, you could wait for the resize and adjust the arrangements if needed (perhaps in a deferred action) and invalidate the layout. Hopefully there's a way to constrain it on the fly though. Some browsing starting with #constrainPoint: might turn up something useful. Have a good one, Bill -- Wilhelm K. Schwab, Ph.D. [hidden email] |
In reply to this post by Ted Bracht-2
Ted,
> Anybody any ideas? This appears to work - caveats apply. I created a subclass of Splitter called RestrictedSplitter and overrode one method (just changing the point's x value from 0 to 150) constrainPosition: aPoint "Private - An attempt may be made to change the position of the receiver to aPoint. Answers the actual position that may be achieved." | position | position := aPoint max: 150 @ 0. self isVertical ifTrue: [position x: self x] ifFalse: [position y: self y]. ^position This stops the Splitter being dragged within 150 pixels of the left/top border. It gets a bit confused if the shell is max/minimised or resized though so it's not a complete solution. NB: The easiest way to use it is to add a normal Splitter and then mutate it into a RestrictedSplitter. Regards Ian |
>
> This stops the Splitter being dragged within 150 pixels of the left/top > border. It gets a bit confused if the shell is max/minimised or resized > though so it's not a complete solution. > Cheers Ian (and Bill), got it working ok except like you said when changing window size. I'll have a look into how to control that as well. Thanks Ted |
Ted,
> Cheers Ian (and Bill), got it working ok except like you said when > changing window size. I'll have a look into how to control that as > well. If you have only two subviews with a splitter between them then this might be an alternative. If you edit ProportionalLayout>>layoutContainer: to read as below (there's only one change about 2/3 of the way through which I've marked - sorry about the formatting) then the first subview is always laid out with to a minimum width of 150 pixels - irrespective of how the resize is done. Creating a subclass to override this one method and using that as the layout manager in your application would obviously be better than modifying the existing class though :-) If the layout manager looks after more than two sub views then it doesn't quite work correctly, the right hand view is resized when the left splitter is moved, but I think that could be overcome with a more extensive change. Ian layoutContainer: aContainerView "Performs a layout operation on the contents in aContainerView" | subviews extent majorExtent minorExtent point freeSize totalProportion fixedSize viewMajorExtent viewExtent insets | subviews := aContainerView managedSubViews . insets := aContainerView actualInsets. extent := (aContainerView clientWidth - (insets left + insets right)) @ (aContainerView clientHeight - (insets top + insets bottom)). majorExtent := self majorDimensionOf: extent. minorExtent := self minorDimensionOf: extent. fixedSize := 0. (subviews select: [:aView | self hasFixedSize: aView]) do: [:aView | fixedSize := fixedSize + (self majorDimensionOf: aView layoutExtent)]. freeSize := majorExtent - fixedSize max: 0. totalProportion := self totalProportionsOf: subviews. point := insets origin. subviews keysAndValuesDo: [:index :aView | viewMajorExtent := (self hasFixedSize: aView) ifTrue: [self majorDimensionOf: aView layoutExtent] ifFalse: [index = subviews size ifTrue: [majorExtent + (self majorDimensionOf: insets origin) - (self majorDimensionOf: point)] ifFalse: ["Change this block to read" | temp | temp := ((self arrangementOf: aView) / totalProportion * freeSize) truncated. index = 1 & (temp < 150) ifTrue: [temp := 150]. temp]]. viewExtent := self pointWithMajor: viewMajorExtent minor: minorExtent. aView basicInvalidateLayout. aView rectangle: (point extent: viewExtent). point := point + (self pointWithMajor: viewMajorExtent minor: 0)]. aContainerView validateLayout. |
Hi Ian,
> If you have only two subviews with a splitter between them then this might > be an alternative. If you edit ProportionalLayout>>layoutContainer: to read > as below (there's only one change about 2/3 of the way through which I've > marked - sorry about the formatting) then the first subview is always laid > out with to a minimum width of 150 pixels - irrespective of how the resize > is done. > Nice ;-) It would be nice if we had some aspect in the ProportionalLayout manager to control this. I guess the most logical place would actually be the proportional containers having a minimum size. I'll see if I can do something with these suggestions to wrap it all up in a nice little tool. Ted |
Free forum by Nabble | Edit this page |