[Prev][Next][Index][Thread]
Re: Using DUIM's <viewport>
In article <wkwvmvfrv9.fsf@double.co.nz>, Chris Double
<chris@double.co.nz> wrote:
> Dustin Voss <agent_@mindspring.com> writes:
>
> > It's entirely possible that I am misusing that class. It's not
> > well-documented. Has anyone used this? Any sample code?
>
> If I understand what you want correctly, and based on Scott's reply to
> look at the Scroller macro, the following may do something like what
> you want:
>
> --------------------8<----------------
> define frame <scroll-test-frame> (<simple-frame>)
> pane lists-pane (frame)
> horizontally( spacing: 5)
> make(<list-box>, items: #[1, 2, 3, 4, 5]);
> end;
>
> pane scrolling-pane (frame)
> scrolling(scroll-bars: #"horizontal")
> frame.lists-pane;
> end;
>
> pane add-button (frame)
> make(<push-button>,
> label: "Add",
> activate-callback: do-add-list);
>
> layout (frame)
> vertically()
> frame.scrolling-pane;
> frame.add-button;
> end;
> end frame;
>
> define method do-add-list(g)
> let list-pane = g.sheet-frame.lists-pane;
> let new-child = make(<list-box>,
> items: #[2, 4, 6, 8, 10],
> parent: list-pane);
> relayout-parent(list-pane);
> new-child.sheet-mapped? := #t;
> end method do-add-list;
> --------------------8<----------------
>
> Pressing the Add button will add a new list box and you can use the
> scroller to scroll across the pane holding the list boxes.
>
> On the downside, the above code has some repaint issues with FD 2.0
> beta 3 when scrolling if there is more than one list box. Forcing a
> repaint (minimizing then maximizing for example) causes the artifacts
> to go away and the application draws correctly. Try it and you'll see
> what I mean.
>
> The code from do-add-list is basically copied from the example
> duim-gui-test-suite in dynamic-layouts.dylan. That example just about
> uses everything in Dylan and is a good one to look through to find out
> how to do things.
>
> Chris.
This code is what I'm looking for -- thanks! -- except for that repaint
problem. It looks like the border and selection of each list box is
getting repainted, but not the rest of the content.
Can you (or anyone) think of a way to automatically repaint this? Maybe
hook into some event somewhere?
I tried overriding handle-event, but that didn't work...
define method handle-event (f :: <lists-pane>, e :: <event>) => ()
next-method();
queue-repaint (f, $everywhere);
end method;
Thanks in advance!
Follow-Ups:
References: