widgetry scrollbars

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

widgetry scrollbars

Tudor Girba-3
Hello,

I am giving Widgetry 0.10 a try. My target is to build a browser with  
an interface like Finder on Mac, that is with panes that are  
dynamically added/removed and with scroll bars that are updated as  
panes are added/removed.

I am using a Form with a horizontal scroll bar as container:
        form := Form new.
        form frame: (FractionalFrame fractionLeft: 0 right: 1 top: 0 bottom:  
0.9).
        form horizontalScrollbar: true.

And I am adding list boxes like:
        listBox := ListBox new.
        listBox frame: (InsetExtentFrame inset: leftMostX@0 extent:200@200).
        form addComponent: listBox.

Now, my question is how do I tell the form to update the scroll bar  
to take into account the newly added pane inside the form?

I tried form resetScrollbars, but it does not seem to work. Perhaps I  
still need to do something so that the form recomputes the new bounds?

Cheers,
Tudor

--
www.iam.unibe.ch/~girba
www.iam.unibe.ch/~girba/blog/

"Every thing has its own flow."


Reply | Threaded
Open this post in threaded view
|

Re: widgetry scrollbars

Samuel S. Shuster <sames@interaccess.com>
Tudor:

> I tried form resetScrollbars, but it does not seem to work. Perhaps  
> I still need to do something so that the form recomputes the new  
> bounds?

You need to tell the Form the contentsExtent: .

                                 And So It Goes
                                      Sames
______________________________________________________________________

Samuel S. Shuster [|]
VisualWorks Engineering, GUI Project
Smalltalk Enables Success -- What Are YOU Using?



Reply | Threaded
Open this post in threaded view
|

Re: widgetry scrollbars

Tudor Girba-3
Thanks for the tip.

I added now a line saying "form contentsExtent: form  
preferredExtent", and that seems to work when the dynamically added  
list boxes have a InsetExtentFrame.

However, when I try to use a FractionalFrame to tell the list boxes  
to fill the space vertically, the scroll bar update does not work  
anymore. Actually, the list boxes do not even fill the space vertically.

For more details, I attached here the parcel and inlined the printout  
of my simple Finder class.

I guess I again miss something, because when I use the  
FractionalFrame in createInterface the panes look like they should.  
So, what am I missing? :)

Cheers,
Tudor



Smalltalk defineClass: #Finder
        superclass: #{Widgetry.UserInterface}
        indexedType: #none
        private: false
        instanceVariableNames: 'panes form '
        classInstanceVariableNames: ''
        imports: '
                        Widgetry.*
                        '
        category: 'none'


Finder methodsFor: building support

addPaneFor: anEntity at: anInteger

        | pane |

        (panes copyFrom: anInteger + 1 to: panes size) do: [:each | form  
removeComponent: each].
        panes := panes copyFrom: 1 to: anInteger.

        pane := ListBox new.
        pane frame: (FractionalFrame
                        leftFraction: 0 offset: (panes size * 300)
                        rightFraction: 0 offset: (panes size * 300 + 300)
                        topFraction: 0 offset: 0
                        bottomFraction: 1 offset: 0).
        pane list: (OrderedCollection with: anEntity*10 with: anEntity * 20  
with: anEntity * 30).
        pane when: SelectionChanged do:[
                self addPaneFor: pane selection at: anInteger + 1.
        ].
        panes addLast: pane.
        form addComponent: pane.
        form contentsExtent: form preferredExtent.
        form scrollHorizontally: 300.

createInterface
       
        panes := OrderedCollection new.
       
        form := Form new.
        form frame: (FractionalFrame fractionLeft: 0 right: 1 top: 0 bottom:  
1).
        form horizontalScrollbar: true.
        self addComponent: form.

        self addPaneFor: 1 at: 0.










On Jun 10, 2007, at 4:23 AM, Samuel S. Shuster wrote:

> Tudor:
>
>> I tried form resetScrollbars, but it does not seem to work.  
>> Perhaps I still need to do something so that the form recomputes  
>> the new bounds?
>
> You need to tell the Form the contentsExtent: .
>
>                                 And So It Goes
>                                      Sames
> ______________________________________________________________________
>
> Samuel S. Shuster [|]
> VisualWorks Engineering, GUI Project
> Smalltalk Enables Success -- What Are YOU Using?
>
>
>
--
www.iam.unibe.ch/~girba
www.iam.unibe.ch/~girba/blog/

"We cannot reach the flow of things unless we let go."



WidgetryFinder.pcl (2K) Download Attachment
WidgetryFinder.pst (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: widgetry scrollbars

Samuel S. Shuster <sames@interaccess.com>
Tudor

>I added now a line saying "form contentsExtent: form  
>preferredExtent", and that seems to work when the dynamically added  
>list boxes have a InsetExtentFrame.
>
>However, when I try to use a FractionalFrame to tell the list boxes  
>to fill the space vertically, the scroll bar update does not work  
>anymore. Actually, the list boxes do not even fill the space vertically.
>
>For more details, I attached here the parcel and inlined the printout  
>of my simple Finder class.
>
>I guess I again miss something, because when I use the  
>FractionalFrame in createInterface the panes look like they should.  
>So, what am I missing? :)

Preferred Extent for a Form can only know the sizes of its embedded frames that
have explicit size. For those that are Fractional, it can't possibly know.

This is because a FractionalFrame lays itself out relative to its enclosing
pane. For a Form, that is either an explicit extent of the frame, or its
contentsExtent, which ever is larger.

In your case, you don't really want to give it form preferredExtent, for the
exact reason you see.

What you want to do is give it something bigger, manually. Possibly, you'll want
to add and subtract from the contentsExtent as you add more panes. What you'll
then want to do is add/subtract some optimal size you would like to have these
added panes have to lay themselves out into.

                                And So It Goes
                                     Sames
______________________________________________________________________

Samuel S. Shuster [|]
VisualWorks Engineering, GUI Project
Smalltalk Enables Success -- What Are YOU Using?