/*
 *    SCCS ID: %Z%%M% %I% %E% SST
 *
 *    Copyright (c) 1992 Mark Soloway.  All rights reserved.
 *    See SST_LEGAL_NOTICE file for terms of the license.
 */

#include <values.h>

#include "BaseWindow.h"
#include "ComponentDisplay.h"
#include "Slider.h"
#include "NumericInput.h"
#include "Notifier.h"
#include "TTC.h"

extern void send_target_handler (UIObject *, UIObject *);

void main (int argc, char **argv)
{
  BaseWindow window;
  window.initUI (argc, argv);
  window.setWidth (326);
  window.setHeight (80);
  window.setLabel ("Request Example");
  window.show (TRUE);
  window.setDisplayFooter (TRUE);
  window.setResizable (TRUE);

  ComponentDisplay controls (TRUE);
  controls.setX (0);
  controls.setY (0);
  controls.setExtendToEdge (WIDTH);
  controls.setExtendToEdge (HEIGHT);
  controls.setDisplayBorders (FALSE);
  window.addDisplay (controls);

  Slider send;
  send.setX (81);
  send.setY (20);
  send.setSliderWidth (100);
  send.setTicks (0);
  send.setLabel ("Send:");
  send.setLabelPosition (LEFT);
  send.setOrientation (HORIZONTAL);
  send.setDisplayEndBoxes (FALSE);
  send.setDisplayRange (TRUE);
  send.setDisplayValue (TRUE);
  send.setMinValue (0);
  send.setMaxValue (100);
  send.setValue (0);
  controls.addComponent (send);

  NumericInput accumulation;
  accumulation.setX (10);
  accumulation.setY (50);
  accumulation.setInputDisplayLength (10);
  accumulation.setMaxInputLength (80);
  accumulation.setLabel ("Accumulation:");
  accumulation.setLabelPosition (LEFT);
  accumulation.setMaxValue (MAXINT);
  accumulation.setMinValue (0);
  accumulation.setValue (0);
  accumulation.setReadOnly (FALSE);
  controls.addComponent (accumulation);

  int       mark = tt_mark ();
  Tt_status status;
  TTSession session (TT_X_SESSION, NULL, status);

  if (status == TT_OK) {
    send.addNotifyTarget (accumulation, send_target_handler);
    send.setObjectData ("TT_SESSION", (Generic *)&session);

    Notifier notifier;
    notifier.start ();
  }
  else {
    printf ("Error initializing ToolTalk: TT error %d\n", status);
  }

  tt_release (mark);
  exit (0);
}
