beautypg.com

Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 96

background image

C H A P T E R 3

Views

3-12

About Views

View Size Relative to Parent Size

3

A view is normally entirely enclosed by its parent view. You shouldn’t create a
view whose bounds extend outside its parent’s bounds. If you do create such a view,
for example containing a picture that you want to show just part of, you need to set
the

vClipping

flag in the

viewFlags

slot of the parent view.

If you do not set the

vClipping

flag for the parent view, the behavior is

unpredictable. The portions of the view outside the parent’s bounds may or may
not draw properly. All pen input is clipped to the parent’s bounds.

Note that the base views of all applications (all root view children, in fact) are
automatically clipped, whether or not the

vClipping

flag is set.

If your application base view is very small and you need to create a larger floating
child view, for example, a slip, you should use the

BuildContext

function. This

function creates a special view that is a child of the root view. To open the view,
you send the

Open

message to it.

Using Screen-Relative Bounds

3

Newton is a family of products with varying screen sizes. If you want your
application to be compatible with a variety of individual Newton products, you
should design your application so that it sizes itself dynamically (that is, at run
time), accounting for the size of the screen on which it is running, which could be
smaller or larger than the original Newton MessagePad screen.

You may want to dynamically size the base view of your application so that it
changes for different screen sizes, or you may want it to remain a fixed size on all
platforms. In the latter case, you should still check the actual screen size at run
time to make sure there is enough room for your application.

You can use the global function

GetAppParams

to check the size of the screen at

run time. This function returns a frame containing the coordinates of the drawable
area of the screen, as well as other information (see “Utility Functions Reference”
(page 23-1) in the Newton Programmer’s Reference for a description). The frame
returned looks like this:

{appAreaLeft: 0,

appAreaTop: 0,

appAreaWidth: 240,

appAreaHeight: 320,

...}

The following example shows how to use the

ViewSetupFormScript

method in

your application base view to make the application a fixed size, but no larger than
the size of the screen: