/************************************************************************/
/* Copyright 1998 MBARI							*/
/************************************************************************/
#ifndef _ALARMLIGHT_H
#define _ALARMLIGHT_H
static char AlarmLight_h_id[] = "$Header: /u/oreilly/rov/tmacs/RCS/AlarmLight.h,v 1.3 1998/12/18 21:07:21 oreilly Exp $";

/*
$Log: AlarmLight.h,v $
Revision 1.3  1998/12/18 21:07:21  oreilly
Added documentation

Revision 1.2  1997/05/30 15:43:35  oreilly
*** empty log message ***

 * Revision 1.1  96/10/28  09:13:12  09:13:12  oreilly (Thomas C. O'Reilly)
 * Initial revision
 * 
*/

#include "DmGuiObject.h"
#include "Alarm.h"
#include "SystemAlarms.h"

/*
CLASS 
AlarmLight

DESCRIPTION
AlarmLight uses colored button to indicate current state and 
priority of active alarms

AUTHOR
Tom O'Reilly
*/
class AlarmLight : public VkComponent
{
  public:
  AlarmLight(const char *name, Widget parent);
  ~AlarmLight();

  virtual const char *className() 
  {
    return "AlarmLight";
  }

  ///////////////////////////////////////////////////////////////////
  // Set button colors appropriate to current priority
  void shine();

  ///////////////////////////////////////////////////////////////////
  // Alternately flash button colors between current priority colors 
  // and "normal" colors
  void flash();

  ///////////////////////////////////////////////////////////////////
  // Set button colors to "normal" background and foreground
  void darken();

  ///////////////////////////////////////////////////////////////////
  // Return current priority
  Priority priority()
  {
    return _priority;
  }
  
  ///////////////////////////////////////////////////////////////////
  // Set current priority
  void setPriority(Priority priority)
  {
    _priority = priority;
  }
  
  void setButtonCallback(XtCallbackProc, XtPointer clientData);

  ///////////////////////////////////////////////////////////////////
  // Set button label
  void setLabel(char *label);
  
  protected:
  enum 
  {
    InitState, Dark, Shining, Flashing
  };

  int _state;
  
  Priority _priority;   // Highest current unacknowledged or active priority

  Widget _alarmButton;
  XtIntervalId _flashTimer;
  int _flashPeriod;
  int _phase;
  Pixel _inactiveForeground, _inactiveBackground;
  
  Pixel buttonBackground();
  Pixel buttonForeground();
  Pixel _priority1Foreground, _priority2Foreground, _priority3Foreground;  
  Pixel _priority1Background, _priority2Background, _priority3Background;
  Pixel _noPriorityForeground, _noPriorityBackground;
  
  private:
  
  static void timerCallback(XtPointer clientData, XtIntervalId *id);
  static void alarmButtonCallback(Widget w, XtPointer clientData, 
				  XtPointer callData);
};



#endif
