#if ( !defined(lint) && !defined(SABER))
  static char rcsid_module_c[] = "$Header: handler.c,v 1.1 88/08/26 12:46:23 kit Exp $";
  static char rcs_version[] = "$Athena: handler.c,v 1.1 88/08/26 12:46:23 kit Exp $";
#endif

/*
 *  This is the file handler.c for xvdp.  It created all the buttons
 *  for player display.
 *
 *  Created:    8/25/88
 *  By:         Chris D. Peterson 
 *
 *      $Source: /u1/Video/tools/Xvdp/RCS/handler.c,v $
 *      $Author: kit $
 *      $Header: handler.c,v 1.1 88/08/26 12:46:23 kit Exp $
 *	
 *  	Copyright 1988 by the Massachusetts Institute of Technology.
 *
 *	For further information on copyright and distribution 
 *	see the file mit-copyright.h
 */

#include "mit-copyright.h"

#include <stdio.h>
#include <X11/Xos.h>
#include <X11/Intrinsic.h>
#include <X11/IntrinsicP.h>

#include "xvdp.h"

int VideoFrameCurrent();
Boolean VideoForward(), VideoReverse(), ToggleIndex();
Boolean VideoReset(), VideoStop();
void ShutdownDriver(), ChangeLabel(), DoSearch();

/*    Function Name: ForwardCallback
 *    Description:   this is the callack function for all forward video ops.
 *    Arguments: w - the widget we are calling back from. 
 *               pointer- (closure data) contains the name of the widget.
 *               junk - (call data) not used.
 *    Returns: none.
 */

/* ARGSUSED */

void
ForwardCallback(w, pointer, junk)
Widget w;
caddr_t pointer, junk;
{
  char * name = (char *) pointer;
  char temp[BUFSIZ];
  Boolean result;

  if ( streq(name, "frame"))
    result = VideoForward(FRAME);
  if ( streq(name, "slow"))
    result = VideoForward(SLOW);
  if ( streq(name, "normal"))
    result = VideoForward(NORMAL);
  if ( streq(name, "fast"))
    result = VideoForward(FAST);

  if (result) {
    sprintf(temp, "Video forward %s", name);
    ChangeLabel(temp);
  }
}

/*    Function Name: ReverseCallback
 *    Description:   this is the callack function for all forward video ops.
 *    Arguments: w - the widget we are calling back from. 
 *               pointer- (closure data) contains the name of the widget.
 *               junk - (call data) not used.
 *    Returns: none.
 */

/* ARGSUSED */

void
ReverseCallback(w, pointer, junk)
Widget w;
caddr_t pointer, junk;
{
  char * name = (char *) pointer;
  char temp[BUFSIZ];
  Boolean result;

  if ( streq(name, "frame"))
    result = VideoReverse(FRAME);
  if ( streq(name, "slow"))
    result = VideoReverse(SLOW);
  if ( streq(name, "normal"))
    result = VideoReverse(NORMAL);
  if ( streq(name, "fast"))
    result = VideoReverse(FAST);

  if (result) {
    sprintf(temp, "Video reverse %s", name);
    ChangeLabel(temp);
  }
}

/*    Function Name: CommandCallback
 *    Description:   this is the callack function for all forward video ops.
 *    Arguments: w - the widget we are calling back from. 
 *               pointer- (closure data) contains the name of the widget.
 *               junk - (call data) not used.
 *    Returns: none.
 */

/* ARGSUSED */

void
CommandCallback(w, pointer, junk)
Widget w;
caddr_t pointer, junk;
{
  int frame;
  char temp[BUFSIZ];
  char * name = (char *) pointer;
  Boolean result;

  if ( streq(name, "quit")) {
    (void) ShutdownDriver();
    exit(0);
  }
  if ( streq(name, "reset")) {
    VideoReset();
    ChangeLabel("Video Reset");
  }
  if ( streq(name, "still")) {
    VideoStop();
    ChangeLabel("Video Stopped.");
  }
  if ( streq(name, "goto"))
    DoSearch();
  if ( streq(name, "index"))
    ToggleIndex();
  if ( streq(name, "where")) {
    frame = VideoCurrentFrame();
    sprintf(temp, "Current frame is: %d", frame);
    ChangeLabel(temp);
  }
}

