/* $XConsortium: Viewport.c,v 1.71 94/04/17 20:13:26 kaleb Exp $ */
/***********************************************************
Copyright (c) 1987, 1988, 1994 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
static void ScrollUpDownProc(), ThumbProc();
static Boolean GetGeometry();
static void ComputeWithForceBars();
};
static void Initialize(), ConstraintInitialize(),
{ /* core_class fields */
/* class_name */ "Viewport",
/* widget_size */ sizeof(ViewportRec),
/* class_initialize */ XawInitializeWidgetSet,
/* class_part_init */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ Realize,
/* actions */ NULL,
/* num_actions */ 0,
/* resources */ resources,
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ TRUE,
/* compress_enterleave*/ TRUE,
/* visible_interest */ FALSE,
/* destroy */ NULL,
/* resize */ Resize,
/* expose */ XtInheritExpose,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ NULL,
/* query_geometry */ PreferredGeometry,
/* display_accelerator*/ XtInheritDisplayAccelerator,
/* extension */ NULL
},
{ /* composite_class fields */
/* geometry_manager */ GeometryManager,
/* change_managed */ ChangeManaged,
/* insert_child */ XtInheritInsertChild,
/* delete_child */ XtInheritDeleteChild,
/* extension */ NULL
},
{ /* constraint_class fields */
/* subresourses */ NULL,
/* subresource_count */ 0,
/* constraint_size */ sizeof(ViewportConstraintsRec),
/* initialize */ ConstraintInitialize,
/* destroy */ NULL,
/* set_values */ NULL,
/* extension */ NULL
},
{ /* form_class fields */
/* layout */ Layout
},
{ /* viewport_class fields */
/* empty */ 0
}
};
{
{XtNorientation, (XtArgVal) 0},
};
if (horizontal) {
}
else {
}
XtManageChild( bar );
return bar;
}
/* ARGSUSED */
{
/*
* Initialize all widget pointers to NULL.
*/
/*
* Create Clip Widget.
*/
arg_cnt = 0;
return; /* If we are not forcing the bars then we are done. */
if (w->viewport.allowhoriz)
(void) CreateScrollbar(w, True);
(void) CreateScrollbar(w, False);
/*
* Set the clip widget to the correct height.
*/
arg_cnt = 0;
}
/* ARGSUSED */
{
}
{
*value_mask |= CWBitGravity;
XtRealizeWidget( clip );
XtRealizeWidget( child );
XtMapWidget( child );
}
}
/* ARGSUSED */
{
{
}
return False;
}
{
int i;
if (XtIsManaged(*childP)
{
break;
}
}
if (XtIsRealized(widget)) {
if (!XtIsRealized(child)) {
#ifdef notdef
/* this is dirty, but it saves the following code: */
XtRealizeWidget( child );
XtMapWidget( child );
#else
XtRealizeWidget( child );
#endif /* notdef */
}
XtMapWidget( child );
}
}
/* %%% do we need to hide this child from Form? */
}
}
#ifdef notdef
#endif
}
Widget w;
{
}
static void RedrawThumbs(w)
{
}
unsigned int changed;
{
if (w->viewport.report_callbacks) {
}
}
static void MoveChild(w, x, y)
Position x, y;
{
if (x >= 0) x = 0;
if (y >= 0) y = 0;
XtMoveWidget(child, x, y);
RedrawThumbs(w);
}
{
intended.border_width = 0;
&clip_width, &clip_height);
}
else {
/*
* intended.{width,height} caches the eventual child dimensions,
* but we don't set the mode bits until after we decide that the
* child's preferences are not acceptable.
*/
if (!w->viewport.allowhoriz)
else
else
if (!query) {
}
do { /* while intended != prev */
if (query) {
}
/*
* note that having once decided to turn on either bar
* we'll not change our mind until we're next resized,
* thus avoiding potential oscillations.
*/
#define CheckHoriz() \
if ( w->viewport.allowhoriz && \
if (!needshoriz) { \
needshoriz = True; \
} \
}
/*enddef*/
CheckHoriz();
if (!needsvert) {
CheckHoriz();
}
}
if ( !w->viewport.allowhoriz ||
}
}
}
if (XtIsRealized(clip))
if (!needshoriz) {
if (destroy_scrollbars) {
XtDestroyWidget( bar );
}
}
else {
: -bw),
: -bw) );
}
}
if (!needsvert) {
if (destroy_scrollbars) {
XtDestroyWidget( bar );
}
}
else {
: -bw),
: -bw) );
}
}
MoveChild(w,
}
SendReport (w, XawPRAll);
}
/* Function Name: ComputeWithForceBars
* Description: Computes the layout give forcebars is set.
* Arguments: widget - the viewport widget.
* query - whether or not to query the child.
* intended - the cache of the childs height is
* stored here ( USED AND RETURNED ).
* clip_width, clip_height - size of clip window.
* (USED AND RETURNED ).
* Returns: none.
*/
static void
int *clip_width, *clip_height;
{
/*
* If forcebars then needs = allows = has.
* Thus if needsvert is set it MUST have a scrollbar.
*/
}
if (w->viewport.allowhoriz) {
}
}
if (!w->viewport.allowhoriz) {
}
if ( query ) {
else
else
}
}
else {
if (w->viewport.allowhoriz)
}
}
{
}
/* ARGSUSED */
FormWidget w;
{
return False;
}
{
Position x, y;
MoveChild(w, x, y);
}
/* ARGSUSED */
{
Position x, y;
#else /* else not macII */
#endif /* macII */
else
#else /* else not macII */
#endif /* macII */
else
MoveChild(w, x, y);
}
static XtGeometryResult
{
else
return XtGeometryYes;
}
static XtGeometryResult
{
}
static XtGeometryResult
{
if (WidthChange() && !HeightChange())
else if (!WidthChange() && HeightChange())
else /* !WidthChange() && !HeightChange() */
return XtGeometryYes;
}
if (!WidthChange() && HeightChange())
else if (WidthChange() && !HeightChange())
else /* !WidthChange() && !HeightChange() */
return XtGeometryYes;
}
else /* (!w->viewport.allowhoriz && !w->viewport.allowvert) */
}
{
&& request->border_width > 0))
return XtGeometryNo;
);
/* horizontal scrollbar will be needed so possibly reduce height */
reconfigured = True;
}
else {
}
}
/* vertical scrollbar will be needed, so possibly reduce width */
if (!rWidth) {
}
else
reconfigured = True;
}
}
else {
}
}
}
else {
}
if (reconfigured || child_changed_size)
ComputeLayout( (Widget)w,
/*query=*/ False,
return result;
}
Widget w;
{
return False;
if (XtIsRealized(w)) {
} else {
/* This is the Realize call; we'll inherit a w&h iff none currently */
}
}
if (result == XtGeometryAlmost)
return (result == XtGeometryYes);
}
Widget w;
{
constraints, reply );
else
return XtGeometryYes;
}
void
#else
#endif
#else
#endif
{
Position x, y;
else
if (yoff > 1.0)
else if (yoff < 0.0)
else
MoveChild (w, -x, -y);
}
void
int x, int y)
#else
#endif
#else
XawViewportSetCoordinates (gw, x, y)
Position x, y;
#endif
{
else if (x < 0)
else if (y < 0)
MoveChild (w, -x, -y);
}