static char AlarmPopup_id[] = "$Header: /usr/tiburon/unix/gui/tmacs/RCS/AlarmPopup.cc,v 1.4 1997/05/30 15:46:02 oreilly Exp $";


/*
$Log: AlarmPopup.cc,v $
Revision 1.4  1997/05/30 15:46:02  oreilly
*** empty log message ***

Revision 1.3  97/04/30  19:26:19  19:26:19  oreilly (Thomas C. O'Reilly)
Resize AlarmList properly when AlarmPopup is resized

Revision 1.2  96/10/28  09:11:39  09:11:39  oreilly (Thomas C. O'Reilly)
*** empty log message ***

Revision 1.1  96/07/22  10:41:31  10:41:31  oreilly (Thomas C. O'Reilly)
First external release

*/
#include <Xm/PanedW.h>
#include <Xm/RowColumn.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>
#include <Xm/Label.h>
#include <Xm/Separator.h>
#include "AlarmPopup.h"
#include "TiburonApp.h"

AlarmPopup::AlarmPopup(const char *name, Priority priority) 
  : VkSimpleWindow(name)
{
  Widget mgr = XtVaCreateWidget("mgr", xmFormWidgetClass,
				mainWindowWidget(), 
				XmNfractionBase, 5,
				NULL);

  Pixel foreground, background;
  TiburonApp *app = (TiburonApp *)theApplication;

  app->priorityColors(priority, &foreground, &background);

    
  char wname[100];
  sprintf(wname, "priority%dListLabel", priority);
    
  Widget label = 
    XtVaCreateManagedWidget(wname, xmLabelWidgetClass, mgr,
			    XmNleftAttachment, XmATTACH_FORM,
			    XmNrightAttachment, XmATTACH_FORM,
			    XmNforeground, foreground,
			    XmNbackground, background,
			    NULL);
  
  Widget clear = 
    XtVaCreateManagedWidget("clear", xmPushButtonWidgetClass, mgr, 
			    XmNbottomAttachment, XmATTACH_FORM,
			    XmNleftAttachment, XmATTACH_POSITION,
			    XmNleftPosition, 1,
			    XmNrightAttachment, XmATTACH_POSITION,
			    XmNrightPosition, 2,
			    NULL);

  XtAddCallback(clear, XmNactivateCallback, &AlarmPopup::clearCallback,
		(XtPointer )this);
  
  _ok = XtVaCreateManagedWidget("ok", xmPushButtonWidgetClass, mgr,
				XmNbottomAttachment, XmATTACH_FORM,
				XmNleftAttachment, XmATTACH_POSITION,
				XmNleftPosition, 3,
				XmNrightAttachment, XmATTACH_POSITION,
				XmNrightPosition, 4,
				XmNshowAsDefault, True,
				NULL);

  XtAddCallback(_ok, XmNactivateCallback, &AlarmPopup::okCallback,
		(XtPointer )this);

  Widget separator = 
    XtVaCreateManagedWidget("separator", xmSeparatorWidgetClass, mgr, 
			    XmNbottomAttachment, XmATTACH_WIDGET,
			    XmNbottomWidget, _ok,
			    XmNleftAttachment, XmATTACH_FORM,
			    XmNrightAttachment, XmATTACH_FORM,
			    NULL);

  list = new AlarmList("alarmList", mgr, priority);
  XtVaSetValues(list->baseWidget(),
		XmNtopAttachment, XmATTACH_WIDGET,
		XmNtopWidget, label,
		XmNleftAttachment, XmATTACH_FORM,
		XmNrightAttachment, XmATTACH_FORM,
		XmNbottomAttachment, XmATTACH_WIDGET,
		XmNbottomWidget, separator,
		NULL);
  
  list->show();
  
  XtManageChild(mgr);
  addView(mgr);
  
  _priority = priority;
}


void AlarmPopup::handleWmDeleteMessage()
{
  hide();
}


void AlarmPopup::clearCallback(Widget w, XtPointer clientData, 
			       XtPointer callData)
{
  AlarmPopup *obj = (AlarmPopup *)clientData;
  obj->list->clear();
}


void AlarmPopup::okCallback(Widget w, XtPointer clientData, 
			    XtPointer callData)
{
  AlarmPopup *obj = (AlarmPopup *)clientData;
  obj->hide();
}
