background image
C H A P T E R 3
About Views
View Size Relative to Parent Size
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
flag in the
slot of the parent view.
If you do not set the
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
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
function. This
function creates a special view that is a child of the root view. To open the view,
you send the
message to it.
Using Screen-Relative Bounds
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
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
method in
your application base view to make the application a fixed size, but no larger than
the size of the screen:
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна