/*************************************************************************
Copyright 1990, the Massachusetts Institute of Technology,
Cambridge, 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 names of MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.

   WORKSPACE.C:  The WorkSpace widget

   This is just like the HP WorkSpace widget *except*
     - It has a callback for motion notify events
     - The names of the callbacks have been changed to
       protect the innocent.

   Mark Ackerman
   MIT/Center for Coordination Science
   July 7, 1990

   send bugs to:
    Mark Ackerman
    ackerman@athena.mit.edu
    ack@media-lab.media.mit.edu

**************************************************************************/

/*WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
  WARNING                                                         WARNING
  WARNING                                                         WARNING
  WARNING    THIS IS CODE IN PROGRESS, *NOT* FINISHED CODE        WARNING
  WARNING                                                         WARNING
  WARNING                                                         WARNING
  WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING*/

#include <X11/IntrinsicP.h>
#include <X11/Xresource.h>
#include <X11/StringDefs.h>
#include "WorkSpaceP.h"


/* Private definitions. */


static char defaultTranslations[] =
    "<BtnDown>:    WorkSpaceButtonDown() \n\
     <BtnUp>:      WorkSpaceButtonUp() \n\
     <KeyDown>:    WorkSpaceKeyDown() \n\
     <BtnMotion>:  WorkSpaceMotionNotify()";


#define Offset(field) XtOffset(WorkSpaceWidget, field)
static XtResource resources[] = {
    {XtNheight,XtCHeight,XtRDimension,sizeof(Dimension),
	 Offset(core.height), XtRImmediate, (XtPointer) 10},
    {XtNwidth,XtCWidth,XtRDimension,sizeof(Dimension),
	 Offset(core.width), XtRImmediate, (XtPointer) 10},
    {XtNexpose, XtCCallback, XtRCallback, sizeof(XtPointer),
       Offset(workSpace.expose_callbacks), XtRCallback, (XtPointer)NULL},
    {XtNresize, XtCCallback, XtRCallback, sizeof(XtPointer),
       Offset(workSpace.resize_callbacks), XtRCallback, (XtPointer)NULL},
    {XtNbuttonDown, XtCCallback, XtRCallback, sizeof(XtPointer),
       Offset(workSpace.buttonDown_callbacks), XtRCallback, (XtPointer)NULL},
    {XtNbuttonUp, XtCCallback, XtRCallback, sizeof(XtPointer),
       Offset(workSpace.buttonUp_callbacks), XtRCallback, (XtPointer)NULL},
    {XtNkeyDown, XtCCallback, XtRCallback, sizeof(XtPointer),
       Offset(workSpace.keyDown_callbacks), XtRCallback, (XtPointer)NULL},
    {XtNmotionNotify, XtCCallback, XtRCallback, sizeof(XtPointer),
	 Offset(workSpace.motionNotify_callbacks),XtRCallback,(XtPointer)NULL},
};



static void Resize();
static void Redisplay();

static void WorkSpaceButtonUp();
static void WorkSpaceButtonDown();
static void WorkSpaceKeyDown();
static void WorkSpaceMotionNotify();

static XtActionsRec actions[] = {
	{"WorkSpaceButtonUp",		WorkSpaceButtonUp},
	{"WorkSpaceButtonDown",		WorkSpaceButtonDown},
	{"WorkSpaceKeyDown",		WorkSpaceKeyDown},
	{"WorkSpaceMotionNotify",	WorkSpaceMotionNotify},
};

#define SuperClass ((WidgetClass)&simpleClassRec)
WorkSpaceClassRec workSpaceClassRec = {
  {
/* core fields */
    /* superclass       */      SuperClass,
    /* class_name       */      "WorkSpace",
    /* size             */      sizeof(WorkSpaceRec),
    /* class_initialize	*/	NULL,
    /* class_part_init  */	NULL,
    /* class_inited	*/	FALSE,
    /* initialize       */      NULL,
    /* initialize_hook  */	NULL,
    /* realize          */      XtInheritRealize,
    /* actions          */      actions,
    /* num_actions	*/	XtNumber(actions),
    /* resources        */      resources,
    /* num_resources    */      XtNumber(resources),
    /* xrm_class        */      NULLQUARK,
    /* compress_motion	*/	TRUE,
    /* compress_exposure*/	TRUE,
    /* compress_enterleave*/	TRUE,
    /* visible_interest */      FALSE,
    /* destroy          */      NULL,
    /* resize           */      Resize,
    /* expose           */      Redisplay,
    /* set_values       */      NULL,
    /* set_values_hook  */	NULL,
    /* set_values_almost */	XtInheritSetValuesAlmost,
    /* get_values_hook  */	NULL,
    /* accept_focus     */      NULL,
    /* version          */	XtVersion,
    /* callback_private */      NULL,
    /* tm_table         */      defaultTranslations,
    /* query_geometry	*/	XtInheritQueryGeometry,
    /* display_accelerator*/	XtInheritDisplayAccelerator,
    /* extension        */	NULL
    },
    {
	/* simple fields */
	/* change_sensitive         */      XtInheritChangeSensitive
    }
};

WidgetClass workSpaceWidgetClass = (WidgetClass)&workSpaceClassRec;


static void Redisplay( w, event, region )
   Widget w;
   XEvent *event;
   Region region;
{
    WorkSpaceWidget wsw = (WorkSpaceWidget) w;
    XtCallCallbackList(w,wsw->workSpace.expose_callbacks,event);
};

static void Resize( w )
   Widget w;
{
    WorkSpaceWidget wsw = (WorkSpaceWidget) w;
    XtCallCallbackList(w,wsw->workSpace.resize_callbacks,NULL);
};

static void WorkSpaceButtonUp(w,event)
     Widget w;
     XEvent *event;
{
    WorkSpaceWidget wsw = (WorkSpaceWidget) w;
    XtCallCallbackList(w,wsw->workSpace.buttonUp_callbacks,event);
};

static void WorkSpaceButtonDown(w,event)
     Widget w;
     XEvent *event;
{
    WorkSpaceWidget wsw = (WorkSpaceWidget) w;
    XtCallCallbackList(w,wsw->workSpace.buttonDown_callbacks,event);
};

static void WorkSpaceKeyDown(w,event)
     Widget w;
     XEvent *event;
{
    WorkSpaceWidget wsw = (WorkSpaceWidget) w;
    XtCallCallbackList(w,wsw->workSpace.keyDown_callbacks,event);
};

static void WorkSpaceMotionNotify(w,event)
     Widget w;
     XEvent *event;
{
    WorkSpaceWidget wsw = (WorkSpaceWidget) w;
    XtCallCallbackList(w,wsw->workSpace.motionNotify_callbacks,event);
};






