// This may look like C code, but it is really -*- C++ -*-

/***********************************************************
Copyright 1991 by the Massachusetts Institute of Technology

Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, 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 M.I.T. not be used in advertising or
publicity pertaining to distribution of the software without specific,
written prior permission.  M.I.T. makes no representations about the
suitability of this software for any purpose.  It is provided "as is"
without express or implied warranty.


Author: Roman J. Budzianowski - Project Athena MIT

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

#include "EurekaObject.h"

#ifndef Widgets_h
#define Widgets_h

typedef void (*XtCallbackProc)(Widget, XtPointer, XtPointer);

class LayoutSpace;

class VisualObject : public BaseObject {
 protected:
   Widget widget;
   IO*    map;			/* input */

 protected:
   Boolean AcceptInput(IO*,Data* data);
   void SetupIO(ObjectView*);

   LayoutSpace* PromptForWidget();

   VisualObject(String class_name,String name, Cardinal input_count, Cardinal output_count);
};

class TrueButton : public VisualObject {
 protected:
   static BooleanData* true_value;	
   static BooleanData* false_value;	

   IO* output;			/* output */
   XtCallbackProc callback;	/* widget callback that triggers output */

   TrueButton(String name, String class_name, XtCallbackProc);

 public:
   void SetupIO(ObjectView*);
   void CreateWidget();
   void SendTrue() { output->Send(true_value); }

   TrueButton(String name);
};

// should BooleanButton be base class for TrueButton ?
class BooleanButton : public TrueButton {
 private:
   BooleanData* state;

 public:
//   void CreateWidget();		// should use toggle widget
   void SendBool();
   BooleanButton(String name);
};

class NumberText : public VisualObject {
 protected:
   IO* number;
 public:
   void SetupIO(ObjectView*);
   void CreateWidget();
   Boolean AcceptInput(IO*,Data* data);

   NumberText(String name);
};

class NumberLever : public VisualObject {
 protected:
   IO* output;
   IO* input;

   XtCallbackProc callback;	/* widget callback that triggers output */
 public:
   void SetupIO(ObjectView*);
   void CreateWidget();
   Boolean AcceptInput(IO*,Data* data);
   void SendValue(int);

   NumberLever(String name);
};
   
#endif

