/*
* $XConsortium: Panner.c,v 1.49 94/04/17 20:12:31 kaleb Exp $
*
Copyright (c) 1989, 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.
*
* Author: Jim Fulton, MIT X Consortium
*/
#include <X11/IntrinsicP.h>
#include <ctype.h> /* for isascii() etc. */
#include <math.h> /* for atof() */
extern double atof(char *);
#endif
static char defaultTranslations[] =
"<Btn1Down>: start() \n\
<Btn1Motion>: move() \n\
<Btn1Up>: notify() stop() \n\
<Btn2Down>: abort() \n\
:<Key>KP_Enter: set(rubberband,toggle) \n\
<Key>space: page(+1p,+1p) \n\
<Key>Delete: page(-1p,-1p) \n\
:<Key>KP_Delete: page(-1p,-1p) \n\
<Key>BackSpace: page(-1p,-1p) \n\
<Key>Left: page(-.5p,+0) \n\
:<Key>KP_Left: page(-.5p,+0) \n\
<Key>Right: page(+.5p,+0) \n\
:<Key>KP_Right: page(+.5p,+0) \n\
<Key>Up: page(+0,-.5p) \n\
:<Key>KP_Up: page(+0,-.5p) \n\
<Key>Down: page(+0,+.5p) \n\
:<Key>KP_Down: page(+0,+.5p) \n\
<Key>Home: page(0,0) \n\
:<Key>KP_Home: page(0,0)";
};
/*
* resources for the panner
*/
};
/*
* widget class methods used below
*/
static void Initialize(); /* create gc's */
static void Realize(); /* create window */
static void Destroy(); /* clean up widget */
static void Resize(); /* need to rescale ourselves */
static void Redisplay(); /* draw ourselves */
static void SetValuesAlmost(); /* deal with failed setval geom req */
{ /* core fields */
/* class_name */ "Panner",
/* widget_size */ sizeof(PannerRec),
/* class_initialize */ XawInitializeWidgetSet,
/* class_part_initialize */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ Realize,
/* actions */ actions,
/* resources */ resources,
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ TRUE,
/* compress_enterleave */ TRUE,
/* visible_interest */ FALSE,
/* destroy */ Destroy,
/* resize */ Resize,
/* expose */ Redisplay,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ SetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ defaultTranslations,
/* query_geometry */ QueryGeometry,
/* display_accelerator */ XtInheritDisplayAccelerator,
/* extension */ NULL
},
{ /* simple fields */
/* change_sensitive */ XtInheritChangeSensitive
},
{ /* panner fields */
/* ignore */ 0
}
};
/*****************************************************************************
* *
* panner utility routines *
* *
*****************************************************************************/
{
pixels, 3) &&
pixels, 2))
{
}
else
{
pixels, 2))
}
valuemask |= GCLineWidth;
}
}
{
}
{
valuemask |= GCLineWidth;
}
} else {
}
}
{
/*
* note that positions are already normalized (i.e. internal_border
* has been subtracted out)
*/
if (*x < 0) *x = 0;
if (*y < 0) *y = 0;
if (knob) {
}
}
{
r++;
return;
}
}
}
{
if (location) {
}
if (size) {
}
}
}
move_shadow (pw);
}
{
}
{
}
int *x, *y;
{
case ButtonPress:
case ButtonRelease:
return TRUE;
case KeyPress:
case KeyRelease:
return TRUE;
case EnterNotify:
case LeaveNotify:
return TRUE;
case MotionNotify:
return TRUE;
}
return FALSE;
}
char *s;
int pagesize, canvassize;
{
char *cp;
/*
* syntax: spaces [+-] number spaces [pc\0] spaces
*/
if (*s == '+' || *s == '-') { /* deal with signs */
s++;
}
if (!*s) { /* if null then return nothing */
return 0;
}
/* skip over numbers */
/* skip blanks */
if (*s) { /* if units */
switch (s[0]) {
case 'p': case 'P':
break;
case 'c': case 'C':
val *= (double) canvassize;
break;
}
}
return ((int) val);
}
{ \
}
{ \
}
/*****************************************************************************
* *
* panner class methods *
* *
*****************************************************************************/
/*ARGSUSED*/
{
}
{
if (PIXMAP_OKAY(pm)) {
*valuemaskp |= CWBackPixmap;
*valuemaskp &= ~CWBackPixel;
}
}
}
{
}
{
}
/* ARGSUSED */
{
False);
if (lw)
{
}
}
}
/* ARGSUSED */
{
reset_xor_gc (new);
reset_xor_gc (new);
}
reset_xor_gc (new);
}
move_shadow (new);
}
reset_xor_gc (new);
}
XtIsRealized(gnew)) {
if (PIXMAP_OKAY(pm)) {
} else {
}
}
} else {
}
}
return redisplay;
}
{
}
}
{
return XtGeometryYes;
return XtGeometryNo;
else
return XtGeometryAlmost;
}
/*****************************************************************************
* *
* panner action procs *
* *
*****************************************************************************/
/* ARGSUSED */
{
int x, y;
return;
}
}
/* ARGSUSED */
{
int x, y;
}
}
/* ARGSUSED */
{
}
}
/* ARGSUSED */
{
int x, y;
return;
}
} else {
}
}
/* ARGSUSED */
{
int x, y;
if (*num_params != 2) {
return;
}
if (isin) { /* if in, then use move */
} else { /* else just do it */
}
}
/* ARGSUSED */
{
move_shadow (pw);
}
}
}
/* ARGSUSED */
{
if (*num_params < 2 ||
return;
}
} else {
return;
}
}
}