[Prev][Next][Index][Thread]

Re: Using DUIM's <viewport>



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.
-- 
http://www.double.co.nz/dylan






Follow-Ups: References: