Re: How to open a TextView with a fixed width

Dominik Gruntz (gruntz@oberon.ch)
Fri, 9 Oct 1998 21:04:10 +0100

>This might be a trivial question, but I was not able to figure it out.
>
>How can a open a new view in a window with a fixed width ?
I just realized that you were asking how to open a *Text*View
with a fixed width. That is different. Every root view is contained
in a document. A document is a simple container with only one
view. The size of the document is equal to the preferred size
of the view. If you want to open a view with another size, then
you have to generate a document yourself with the preferred
width and height. This is done with Documents.dir.New. Since
a document is also a view, it can be opened with the command
Views.Open.

For text views, the width of the widow is equal to the page width.
To overrule this, you must set the options of the text view's
controller to "fit to window". The following example demonstrates
this and opens an empty text view of 3 by 6 cm.

Have a nice weekend,
- D. Gruntz, Oberon microsystems AG

MODULE Test;

IMPORT Ports, TextViews, TextModels, Views, Documents, Containers;

PROCEDURE Do*;
VAR d: Documents.Document; c: Containers.Controller;
BEGIN
d :=3D =
Documents.dir.New(TextViews.dir.New(TextModels.dir.New()),=20
30*Ports.mm, 60*Ports.mm);
c :=3D d.ThisController();
c.SetOpts(c.opts + {Documents.winWidth} - =
{Documents.pageWidth});
Views.OpenView(d);
END Do;

END Test.Do .