Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!sgi!shinobu!fido.wpd.sgi.com!marktwain.rad.sgi.com!linton From: linton@marktwain.rad.sgi.com (Mark Linton) Newsgroups: comp.windows.interviews Subject: Re: Viewports and scrolling ..... Message-ID: <1991May7.183844.22317@fido.wpd.sgi.com> Date: 7 May 91 18:38:44 GMT References: <9105061618.AA04456@ntlp.com> Sender: news@fido.wpd.sgi.com (Usenet News Admin) Reply-To: linton@marktwain.rad.sgi.com (Mark Linton) Organization: sgi Lines: 74 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 #include #include #include #include #include #include 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(); }