/************************************************************************/
/* Copyright 1998 MBARI							*/
/************************************************************************/
#ifndef _VALVECONTROL_H
#define _VALVECONTROL_H

#include "DmGuiObject.h"

/*
CLASS 
ValveControl

DESCRIPTION
GUI to open and close momentary valve

AUTHOR
Tom O'Reilly
*/
class ValveControl : public DmGuiObject
{
  public:
  ValveControl(const char *name, Widget parent, 
	       const char *dmPrefix ,  // Prefix for valve Dm items
	       int id                  // unique id 
	       );

  ~ValveControl();
  
  virtual const char *className()
  {
    return "ValveControl";
  }
  
  virtual void updateGui(DM_Item handle = 0);

  ///////////////////////////////////////////////////////////////////
  // Callback BEFORE valve is started. Callback data is pointer to this
  // ValveControl.
  static const char *const startingValveCallback;

  ///////////////////////////////////////////////////////////////////
  // Callback AFTER valve is stopped. Callback data is pointer to this 
  // ValveControl.
  static const char *const stoppedValveCallback;  

  DmBooleanObject *dmOpen();
  DmBooleanObject *dmClose();
  
  protected:
  Boolean _armed;
  int _id;
  Widget _label;
  Widget _openButton;
  Widget _closeButton;
  Pixel _lightEdgeColor, _darkEdgeColor, _armColor, _background;
  
  DmBooleanObject *_dmOpen;
  DmBooleanObject *_dmClose;
  
  ///////////////////////////////////////////////////////////////////
  // Start valve opening or closing
  int startMotion(Widget w);

  ///////////////////////////////////////////////////////////////////
  // Stop valve opening or closing
  int stopMotion(Widget w);

  ///////////////////////////////////////////////////////////////////
  // Draw button as armed or unarmed
  void drawButton(Widget button, MBool armed);
  
  private:
  static void buttonCallback(Widget w, 
			     XtPointer clientData, XtPointer callData);
};


#endif


