## viewport.api
#
# "A viewport provides a classical window on the virtual
# graphical space of an underlying widget. In effect,
# the underlying widget can be arbitrarily large, but
# only the part of it that is projected through the
# viewport's window is visible. The amount of the underlying
# window that can be seen depends on the size of the viewport
# window. In addition, the viewport's position relative to the
# underlying widget can be changed, providing panning.
# A viewport is usually tied to other widgets such as
# scrollbars to give the user control over the panning."
#
# -- p19, Gansner+Reppy's 1993 eXene widget manual,
# http://mythryl.org/pub/exene/1993-widgets.ps
#
# A Viewport has the same ideal size as its child,
# but may be arbitrarily shrunk or grown. If the
# child widget is large it is usually a good idea
# to wrap the viewport in another widget which
# limits its size, such as a Size_Preference_Wrapper:
#
src/lib/x-kit/widget/old/wrapper/size-preference-wrapper.api#
# At realization time the child's window is made a subwindow
# of the viewport's window. The child's subwindow is always
# precisely the size requested by the child.
#
# Any change in the viewport's size or position relative
# to the child widget are reported via the mailop returned by
#
# get_viewport_configuration_change_mailop
#
# This makes it easy for other widgets such as associated
# scrollbars to monitor viewport # changes and update
# themselves appropriately.
#
#
# Two ways of providing a Viewport with scrollbars:
# widget_with_scrollbars:
#
src/lib/x-kit/widget/old/layout/widget-with-scrollbars.api# scrolled_widget:
#
src/lib/x-kit/widget/old/layout/scrolled-widget.api# Compiled by:
#
src/lib/x-kit/widget/xkit-widget.sublib### "No one knows what to do with
### seven windows at one time."
###
### -- PC Week Magazine, 1983
stipulate
include package threadkit; # threadkit is from
src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg #
package wg = widget; # widget is from
src/lib/x-kit/widget/old/basic/widget.pkg package g2d= geometry2d; # geometry2d is from
src/lib/std/2d/geometry2d.pkgherein
api Viewport {
Viewport;
viewport
:
(wg::Root_Window, wg::View, List(wg::Arg))
->
wg::Widget
->
Viewport;
make_viewport: wg::Widget -> Viewport;
#
# Create a viewport (a classical window) on the virtual graphical
# space provides by the widget. In the current model, the viewport
# cannot extend beyond the underlying widget boundaries. In
# particular, it can be no larger than the widget. The viewport
# determines a rectangle in the underlying widgets coordinate system.
get_geometry: Viewport -> { box: g2d::Box, child_size: g2d::Size };
#
# Return the underlying widget's current size, and the position
# of the viewport rectangle in the widget's coordinates.
as_widget: Viewport -> wg::Widget;
#
# Convert a viewport into a widget
set_origin: Viewport -> g2d::Point -> Void;
#
# Set the position of the viewport by specifying the viewport's origin
# in the child's coordinate system.
# This raises LibBase::BadArg, if the new rectangle is illegal.
set_horizontal_position: Viewport -> Int -> Void;
#
# Set the horizontal position of the view (the x-coord of the origin)
# This raises LibBase::BadArg, if the new rectangle is illegal.
set_vertical_position: Viewport -> Int -> Void;
#
# Set the vertical position of the view (the y-coord of the origin)
# This raises LibBase::BadArg, if the new rectangle is illegal.
get_viewport_configuration_change_mailop: Viewport -> threadkit::Mailop { box: g2d::Box, child_size: g2d::Size };
#
# Return a mailop that fires whenever the viewport
# configuration changes.
};
end;
## COPYRIGHT (c) 1994 by AT&T Bell Laboratories See SMLNJ-COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.