Calculating rectangles relative to a SubCanvas for dynamic scroll bars

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Calculating rectangles relative to a SubCanvas for dynamic scroll bars

Stew MacLean

Hi,

 

I’m trying to implement the dynamic showing/hiding of scroll bars within a sub canvas depending on whether any widgets on it are “out of bounds”.

 

The idea is that I merge the rectangles of each widget (relative to the sub canvas) and then test the result.

 

However, I’m struggling with how to derive the rectangle relative to the sub canvas.

 

Any help greatly appreciated.

 

Thanks,

 

Stewart

 

Reply | Threaded
Open this post in threaded view
|

Re: Calculating rectangles relative to a SubCanvas for dynamic scroll bars

Andre Schnoor
Stewart,

ususally, a WindowSpec that a subcanvas is populated with should already know its bounds (check out: WindowSpec>>min and max). Ensure that the WindowSpec knows its minimum size by setting the canavs size with UIBuilder.

HTH

Andre


Stewart MacLean wrote:

Hi,

 

I’m trying to implement the dynamic showing/hiding of scroll bars within a sub canvas depending on whether any widgets on it are “out of bounds”.

 

The idea is that I merge the rectangles of each widget (relative to the sub canvas) and then test the result.

 

However, I’m struggling with how to derive the rectangle relative to the sub canvas.

 

Any help greatly appreciated.

 

Thanks,

 

Stewart

 







	
	
	
	
Reply | Threaded
Open this post in threaded view
|

RE: Calculating rectangles relative to a SubCanvas for dynamic scroll bars

Stew MacLean

Thanks Andre,

 

After some visual representation of the algorithm (see the comments), I managed to figure this out.

 

Thanks for your reply.

 

Cheers,

 

Stewart

 

checkEventPanelScrollBars

 

            | requiredArea decorator available widget localBounds |

 

            [requiredArea := ((eventPanel builder namedComponents associations select:

                        [: each | each value widget isVisible & each value widget isComposite not]) collect:

                                    [: each |

                                    localBounds := (widget := (eventPanel builder namedComponents at: each key) widget) bounds.

                                    Rectangle

                                                origin: (widget localPointToGlobal: localBounds origin)

                                                extent: localBounds extent])

                                                            inject: (Rectangle origin: ((self widgetAt: #eventPanel) localPointToGlobal: 0@0) corner: 0@0) into:

                                                                        [: result : each |

                                                                        "self mainWindow graphicsContext displayRectangle: each.

                                                                        (Delay forMilliseconds: 500) wait.

                                                                        self mainWindow graphicsContext

                                                                                    paint: SymbolicPaint buttonHilite;

                                                                                    displayRectangle: (result merge: each).

                                                                        (Delay forMilliseconds: 500) wait."

                                                                        result merge: each].

 

            "self mainWindow graphicsContext displayRectangle: requiredArea.

            (Delay forMilliseconds: 1500) wait."

 

            decorator := (self widgetAt: #eventPanel) container container container container.

            available := ((self widgetAt: #eventPanel) container container container bounds) translatedBy: ((self widgetAt: #eventPanel) localPointToGlobal: 0@0).

            available

                        corner x < requiredArea corner x

                                    ifTrue: [decorator useHorizontalScrollBar]

                                    ifFalse: [decorator noHorizontalScrollBar].

 

            "self mainWindow graphicsContext

                        paint: SymbolicPaint traversalHilite;

                        displayRectangle: available.

            (Delay forMilliseconds: 1500) wait."

 

            available corner y < requiredArea corner y

                        ifTrue: [decorator useVerticalScrollBar]

                        ifFalse: [decorator noVerticalScrollBar]] on: Error do: [: ex | ex return]

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: 12 August 2007 7:13 p.m.
To: Stewart MacLean
Cc: [hidden email]
Subject: Re: Calculating rectangles relative to a SubCanvas for dynamic scroll bars

 

Stewart,

ususally, a WindowSpec that a subcanvas is populated with should already know its bounds (check out: WindowSpec>>min and max). Ensure that the WindowSpec knows its minimum size by setting the canavs size with UIBuilder.

HTH

Andre


Stewart MacLean wrote:

Hi,

 

I’m trying to implement the dynamic showing/hiding of scroll bars within a sub canvas depending on whether any widgets on it are “out of bounds”.

 

The idea is that I merge the rectangles of each widget (relative to the sub canvas) and then test the result.

 

However, I’m struggling with how to derive the rectangle relative to the sub canvas.

 

Any help greatly appreciated.

 

Thanks,

 

Stewart