david@UUNET.UU.NET (05/06/91)
This is an InterViews 2.6 question.
O.K. I give up. What I want to be able to do is to insert an arbitrary
Interactor into something that will allow me to view a specified (smaller)
portion of said interactor. I would also like to be ablt to attach ScrollBars
to this thing. I would expect the ScrollBars to configure themselves so that
I can view all of the interactor. I had thought I was going to be able get this
behaviour out of a Viewport, but on futher inspection realized that there wasn't
a way to specify the "initial size" of the viewport; it defaults to the size of
the inserted interactor. Then I stumbled onto Trays and thought aha! this will
do it, only to find out that the scrollbar refused to behave. Below is an
example of the Tray/Viewport version. The only problem with this is that the
ScrollBar thinks (reasonably) that there's no more resizing to be done.
Actually I can move around a bit by using the Up/Down Movers. This doesn't work
well, nor in a particularlly inteligent way, so I gotta believe I'm just not
doing the right thing.
Any help would be apreciated.
.
.
.
// Something to scroll around.
VBox *listBox = new VBox;
listBox->Insert( Message( "The first one"));
listBox->Insert( Message( "The second one"));
.
.
.
listBox->Insert( Message( "The n'th one"));
// Use a viewport here to give something for the scrollbar to talk to.
Viewport *theViewer = new Viewport( listBox, TopLeft);
// Make a tray with a background the "right size" and
// stick theViewer into it.
VBox *theSize = new VBox(
new VGlue( (Coord)round( .5*inches), 0, 0),
new HBox( new HGlue( (Coord)round( 2.5*inches, 0, 0)
);
Tray *aTray = new Tray( theSize);
aTray->Aligh( TopLeft, theViewer);
// Build a Frame suitable for putting into the world
// with the above and include a scrollbar for theViewer.
MarginFrame *whatWeSee = new MarginFrame(
new HBox(
aTray,
new VScrollBar( theViewer)
),
(Coord) round( .5*inches)
);
.
.
.
Thanks alot,
David
Daivd Rivas david@lolita.ntlp.com
Northfield Trading L. P. (303) 985-3366linton@marktwain.rad.sgi.com (Mark Linton) (05/08/91)
In article <9105061618.AA04456@ntlp.com>, lolita!david@UUNET.UU.NET writes: |> |> |> This is an InterViews 2.6 question. |> |> O.K. I give up. What I want to be able to do is to insert an arbitrary |> Interactor into something that will allow me to view a specified (smaller) |> portion of said interactor. I would also like to be ablt to attach ScrollBars |> to this thing. I would expect the ScrollBars to configure themselves so that |> I can view all of the interactor. I had thought I was going to be able get this |> behaviour out of a Viewport, but on futher inspection realized that there wasn't |> a way to specify the "initial size" of the viewport; it defaults to the size of |> the inserted interactor. Then I stumbled onto Trays and thought aha! this will |> do it, only to find out that the scrollbar refused to behave. Below is an |> example of the Tray/Viewport version. The only problem with this is that the |> ScrollBar thinks (reasonably) that there's no more resizing to be done. |> Actually I can move around a bit by using the Up/Down Movers. This doesn't work |> well, nor in a particularlly inteligent way, so I gotta believe I'm just not |> doing the right thing. Trays don't constrain the size of their components, so putting the box in the tray doesn't help. What you want is a Viewport or MonoScene subclass with a specific shape. 3.0 provides FixedSpan for glyphs; you want the analogous interactor. Below is your test case with a Shaper class that does what you want (I think). #include <InterViews/box.h> #include <InterViews/frame.h> #include <InterViews/glue.h> #include <InterViews/message.h> #include <InterViews/scrollbar.h> #include <InterViews/viewport.h> #include <InterViews/world.h> class Shaper : public MonoScene { public: Shaper(Interactor*, Shape&); protected: virtual void Reconfig(); }; Shaper::Shaper(Interactor* i, Shape& s) { *shape = s; Insert(i); } void Shaper::Reconfig() { /* don't copy child's shape */ } int main(int argc, char** argv) { World w("Test", argc, argv); VBox* listBox = new VBox; listBox->Insert(new Message("The first one")); listBox->Insert(new Message("The second one")); listBox->Insert(new Message("The third one")); listBox->Insert(new Message("The fourth one")); listBox->Insert(new Message("The fifth one")); listBox->Insert(new Message("The sixth one")); listBox->Insert(new Message("The seventh one")); listBox->Insert(new Message("The eighth one")); listBox->Insert(new Message("The last one")); Viewport* theViewer = new Viewport(listBox, TopLeft); Shape s; s.Rect(round(2.5*inches), round(.5*inches)); w.Insert( new HBox( new Shaper(theViewer, s), new VScrollBar(theViewer) ) ); w.run(); }