Esempio n. 1
0
void
pushed(Widget pb, XtPointer foo, XtPointer bar)
{
  static Widget dialog;
  XmString t = XmStringCreateSimple("Enter New Button Name:");
  extern void read_name(Widget, XtPointer, XtPointer);
  extern void toggle_callback(Widget, XtPointer, XtPointer);
  Arg args[3];

  XtSetArg(args[0], XmNselectionLabelString, t);
  XtSetArg(args[1], XmNautoUnmanage, False);
  XtSetArg(args[2], XmNuserData, 0);
  dialog = XmCreatePromptDialog(XtParent(pb), "notice", args, 3);
  XmStringFree(t);

  XtAddCallback(dialog, XmNokCallback, read_name, NULL);
  XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)XtDestroyWidget,
		NULL);

  XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));

  {
    XmString btn1 = XmStringCreateSimple("Change Name");
    XmString btn2 = XmStringCreateSimple("Change Color");
    Widget toggle_box =
      XmVaCreateSimpleRadioBox(dialog, "radio_box", 0, toggle_callback,
			       XmVaRADIOBUTTON, btn1, 0, NULL, NULL,
			       XmVaRADIOBUTTON, btn2, 0, NULL, NULL,
			       NULL);
    XtManageChild(toggle_box);
  }

  XtManageChild(dialog);
  XtPopup(XtParent(dialog), XtGrabNone);
}
Esempio n. 2
0
Widget dslw_create ( Widget w )
/************************************************************************
 * dslw_create                                                          *
 *                                                                      *
 * This function creates the data selection popup window.               *
 *                                                                      *
 * Widget dslw_create ( w )		                                *
 *                                                                      *
 * Input parameters:                                                    *
 *      w		Widget	The parent widget                    	*
 *                                                                      *
 * Output parameters:                                                   *
 *                                                                      *
 * Return parameters:                                                   *
 *      dslw_create	Widget	The data selection popup  widget        *
 *                                                                      *
 **                                                                     *
 * Log:                                                                 *
 * L. Williams/EAI       7/95   for nwx2.1                		*
 * C. Lin/EAI            8/95                   			*
 * D.W.Plummer/NCEP	 9/96	Commented out "Select by ..."; changed	*
 *				time selection to hours instead of days	*
 * D.W.Plummer/NCEP	11/96	removed commented section from 9/96	*
 *                              changed time selection from hours only	*
 *				to either hours or days depending on	*
 *				product type (eg., W or O, etc.)	*
 * G. Krueger/EAI	11/97	Renamed NxmHelp functions		*
 * I. Durham/GSC 	 5/98	changed call for underscore		*
 * T. Piper/GSC		 6/01	Freed xmstr				*
 * T. Piper/SAIC	 7/02	Reinstated the select by state option	*	
 * T. Piper/SAIC	10/05	declared ii & nn long			*
 * E. Safford/SAIC	12/07	renamed guidInit to idata_init()	*
 ***********************************************************************/
{
struct guid_grp *grp_ptr;
Widget		paned_w, topform; 
Widget		groups_frame, products_frame;
Widget		rc, form, form2, form3, form4, frame3;
Widget		radio_box1, close_button, help_button;
Widget   	label1, label2, label3, label4;
Widget		data_group_list;

XmString	station, state, *xmstr, msg;
Arg 		wargs[10];
Pixel		fg, bg;
int		jj, ier;
long		ii, nn;

/*---------------------------------------------------------------------*/

	nn = 0;
	XtSetArg(wargs[nn], XmNtitle, "Data Selection"); nn++;
        dataSelectW = XmCreateBulletinBoardDialog(w, "data_selection",
						   wargs, nn);

	paned_w = XtVaCreateManagedWidget("paned_w",
			xmPanedWindowWidgetClass, dataSelectW,
			XmNsashWidth,             1,
			XmNsashHeight,            1,
			NULL);

	XtVaGetValues(paned_w, 
		      XmNforeground, &fg, 
		      XmNbackground, &bg, 
		      NULL);

	topform = XtVaCreateManagedWidget("topform",
			xmFormWidgetClass, paned_w,
			NULL);
	
/*
 *	Create Group List
 */
	msg = XmStringCreateLocalized("Select Data Type Group");
	label1 = XtVaCreateManagedWidget("Group label",
			xmLabelWidgetClass, topform,
			XmNlabelString,     msg,
			XmNtopAttachment,   XmATTACH_FORM,
			XmNrightAttachment, XmATTACH_FORM,
			XmNleftAttachment,  XmATTACH_FORM,
			NULL);
	XmStringFree(msg);

	groups_frame = XtVaCreateWidget("groups_frame",
			xmFrameWidgetClass, topform,
			XmNshadowType,      XmSHADOW_IN,
			XmNtopAttachment,   XmATTACH_WIDGET,
			XmNtopWidget,       label1, 
			XmNrightAttachment, XmATTACH_FORM,
			XmNleftAttachment,  XmATTACH_FORM,
			NULL);

	form = XtVaCreateWidget("form", xmFormWidgetClass, groups_frame, NULL);

	guid_ngrp = idata_init( &ier );
	if ( ier != G_NORMAL ) {
	    printf("NWX:  ERROR reading guidata.tbl.  See system administrator.\n");
	    exit(guid_ngrp);
	}

	grp_ptr=guid_grp_head;

	xmstr = (XmString *) XtMalloc(sizeof (XmString) * (size_t)guid_ngrp);
	for (ii = 0; ii < guid_ngrp; ii++) {
      		xmstr[ii] = XmStringCreateLocalized(grp_ptr->grpname);
      		grp_ptr = grp_ptr->nextgrp;
	}

	nn = 0;
	XtSetArg(wargs[nn], XmNitems,            xmstr);            nn++;
	XtSetArg(wargs[nn], XmNitemCount,        guid_ngrp);        nn++;
	XtSetArg(wargs[nn], XmNvisibleItemCount, 7);                nn++;
	XtSetArg(wargs[nn], XmNselectionPolicy,  XmSINGLE_SELECT);  nn++;
	XtSetArg(wargs[nn], XmNscrollingPolicy,  XmAUTOMATIC);      nn++;
	XtSetArg(wargs[nn], XmNtopAttachment,    XmATTACH_FORM);    nn++;
	XtSetArg(wargs[nn], XmNleftAttachment,   XmATTACH_FORM);    nn++;
	XtSetArg(wargs[nn], XmNrightAttachment,  XmATTACH_FORM);    nn++;
	XtSetArg(wargs[nn], XmNbottomAttachment, XmATTACH_FORM);    nn++;
	data_group_list = XmCreateScrolledList(form, "data_group", wargs, nn);

	XtManageChild(data_group_list);

	XtAddCallback(data_group_list, XmNsingleSelectionCallback,
			dslw_groupCb, _prodlistW);

	XtManageChild(form);
	XtManageChild(groups_frame);

	for (jj = 0; jj < guid_ngrp; jj++)
      		XmStringFree(xmstr[jj]);
	XtFree((XtPointer)xmstr);
	
/*
 *	Create Product List
 */
	msg = XmStringCreateLocalized("Select Data Type Product");
	label2 = XtVaCreateManagedWidget("product label1",
			xmLabelWidgetClass, topform,
			XmNlabelString,     msg,
			XmNtopAttachment,   XmATTACH_WIDGET,
			XmNtopWidget,       groups_frame,
			XmNrightAttachment, XmATTACH_FORM,
			XmNleftAttachment,  XmATTACH_FORM,
			NULL);
	XmStringFree(msg);

	msg = XmStringCreateLocalized("  * Product Unavailable  ");
	label3 = XtVaCreateManagedWidget("product label2",
			xmLabelWidgetClass, topform,
			XmNlabelString,     msg,
			XmNtopAttachment,   XmATTACH_WIDGET,
			XmNtopWidget,       label2,
			XmNrightAttachment, XmATTACH_FORM,
			XmNleftAttachment,  XmATTACH_FORM,
			NULL);
	XmStringFree(msg);

	products_frame = XtVaCreateWidget("products_frame", 
			xmFrameWidgetClass, topform,
			XmNshadowType,      XmSHADOW_IN,
			XmNtopAttachment,   XmATTACH_WIDGET,
			XmNtopWidget,       label3,
			XmNrightAttachment, XmATTACH_FORM,
			XmNleftAttachment,  XmATTACH_FORM,
			NULL);

	form = XtVaCreateWidget ("form", xmFormWidgetClass, 
				  products_frame, NULL);

	 nn = 0;
	XtSetArg(wargs[nn], XmNvisibleItemCount, 7);                nn++;
	XtSetArg(wargs[nn], XmNwordWrap,         True);             nn++;
	XtSetArg(wargs[nn], XmNselectionPolicy,  XmSINGLE_SELECT);  nn++;
	XtSetArg(wargs[nn], XmNscrollingPolicy,  XmAUTOMATIC);      nn++;
	XtSetArg(wargs[nn], XmNtopAttachment,    XmATTACH_FORM);    nn++;
	XtSetArg(wargs[nn], XmNleftAttachment,   XmATTACH_FORM);    nn++;
	XtSetArg(wargs[nn], XmNrightAttachment,  XmATTACH_FORM);    nn++;
	XtSetArg(wargs[nn], XmNbottomAttachment, XmATTACH_FORM);    nn++;
	_prodlistW = XmCreateScrolledList(form, "data_type", wargs, nn);

	XtManageChild(_prodlistW);

	XtAddCallback(_prodlistW, XmNsingleSelectionCallback,
			 dslw_prodCb, NULL);

	XtManageChild(form);
	XtManageChild(products_frame);

/*
 *  Bottom Pane
 */
	form = XtVaCreateManagedWidget("form",
			xmFormWidgetClass, paned_w,
			XmNfractionBase, 1,
			NULL);

/*
 *  "Time Covered"
 */
	_dttmFrameW = XtVaCreateManagedWidget("_dttmFrameW",
			xmFrameWidgetClass,  form,
			XmNshadowType,       XmSHADOW_IN,
			XmNtopAttachment,    XmATTACH_FORM,
			XmNbottomAttachment, XmATTACH_FORM,
			XmNleftAttachment,   XmATTACH_POSITION,
			XmNleftPosition,     0,
			XmNrightAttachment,  XmATTACH_POSITION,
			XmNrightPosition,    1,
			NULL);

	form2 = XtVaCreateManagedWidget("form2", xmFormWidgetClass, 
						_dttmFrameW, NULL);

        pdata_setTimeCovered( EVENT, &ier );
/*	timeCoveredType = EVENT; */
	msg = XmStringCreateLocalized("Time Covered (Hours)");
	_timeLabel = XtVaCreateManagedWidget("Time",
			xmLabelWidgetClass, form2,
			XmNlabelString,     msg,
			XmNtopAttachment,   XmATTACH_FORM,
			XmNleftAttachment,  XmATTACH_FORM,
			NULL);
	XmStringFree(msg);

	rc = XtVaCreateWidget("rc",
                        xmRowColumnWidgetClass, form2,
                        XmNorientation,         XmHORIZONTAL,
                        XmNradioBehavior,       True,
                        XmNtraversalOn,         False,
                        XmNtopAttachment,       XmATTACH_WIDGET,
                        XmNtopWidget,           _timeLabel,
                        XmNleftAttachment,      XmATTACH_FORM,
                        XmNbottomAttachment,    XmATTACH_FORM,
                        NULL);

	nn = (long)XtNumber ( HourVals );
	_timeButtons = (WidgetList)XtMalloc(nn * sizeof(Widget));

	for ( ii = 0 ; ii < nn ; ii++ ) {
                _timeButtons[ii] =
                        XtVaCreateManagedWidget( HourVals[ii],
                            xmToggleButtonWidgetClass, rc,
                            NULL );
                XtAddCallback(_timeButtons[ii], XmNarmCallback,
                        (XtCallbackProc)dslw_dttmCb,
                        (XtPointer)ii);
        }

	XmToggleButtonSetState( _timeButtons[0], True, False );
	XtManageChild(rc);
	dslw_dttmSensitive ( False );

/*
 *  Select By
 */
	form = XtVaCreateManagedWidget("form",
                        xmFormWidgetClass, paned_w,
                        XmNfractionBase, 1,
                        NULL);

	frame3 = XtVaCreateManagedWidget("frame3",
                        xmFrameWidgetClass,  form,
                        XmNshadowType,       XmSHADOW_IN,
                        XmNtopAttachment,    XmATTACH_FORM,
                        XmNbottomAttachment, XmATTACH_FORM,
                        XmNleftAttachment,   XmATTACH_POSITION,
                        XmNleftPosition,     0,
                        XmNrightAttachment,  XmATTACH_POSITION,
                        XmNrightPosition,    1,
                        NULL);


	form4 = XtVaCreateManagedWidget("form", xmFormWidgetClass, frame3, NULL);

	msg = XmStringCreateLocalized("Select By");
        label4 = XtVaCreateManagedWidget("select_by",
                        xmLabelWidgetClass, form4,
                        XmNlabelString,     msg,
                        XmNtopAttachment,   XmATTACH_FORM,
                        XmNleftAttachment,  XmATTACH_FORM,
                        NULL);
        XmStringFree(msg);

        station = XmStringCreateLocalized("station");
        state = XmStringCreateLocalized("state");
        radio_box1 = XmVaCreateSimpleRadioBox(form4,
                        "radio_box1", 0, (XtCallbackProc)dslw_slctCb,
                        XmVaRADIOBUTTON,     station, NULL, NULL, NULL,
                        XmVaRADIOBUTTON,     state, NULL, NULL, NULL,
			XmNnumColumns,	     2,
			XmNspacing,	     55,
                        XmNradioBehavior,    TRUE,
                        XmNtopAttachment,    XmATTACH_WIDGET,
                        XmNtopWidget,        label4,
                        XmNleftAttachment,   XmATTACH_FORM,
                        XmNbottomAttachment, XmATTACH_FORM,
                        NULL);
        XtManageChild(radio_box1);

        XmStringFree(station);
        XmStringFree(state);

/*
 *  CLOSE, and HELP
 */
	form3 = XtVaCreateManagedWidget("form3", 
			xmFormWidgetClass, paned_w,
			XmNfractionBase, 2,
			NULL);

	close_button = XtVaCreateManagedWidget("CLOSE",
			xmPushButtonGadgetClass, form3,
			XmNshadowType,           XmSHADOW_IN,
			XmNtopAttachment,        XmATTACH_FORM,
			XmNbottomAttachment,     XmATTACH_FORM,
			XmNleftAttachment,       XmATTACH_POSITION,
			XmNleftPosition,         0,
			XmNrightAttachment,      XmATTACH_POSITION,
			XmNrightPosition,        1,
			NULL);

	XtAddCallback ( close_button, XmNactivateCallback, 
		        (XtCallbackProc)dslw_closeCb, NULL);

	help_button = XtVaCreateManagedWidget("HELP",
			xmPushButtonGadgetClass, form3,
			XmNshadowType,           XmSHADOW_IN,
			XmNtopAttachment,        XmATTACH_FORM,
			XmNbottomAttachment,     XmATTACH_FORM,
			XmNleftAttachment,       XmATTACH_POSITION,
			XmNleftPosition,         1,
			XmNrightAttachment,      XmATTACH_POSITION,
			XmNrightPosition,        2,
			NULL);

	XtAddCallback ( help_button, XmNactivateCallback, 
			(XtCallbackProc)NxmHelp_helpBtnCb,
			(XtPointer)2);

	return(dataSelectW);

}
Esempio n. 3
0
//
// Create the guts of the dialog
//
Widget
FindDialog::createWorkArea(Widget dialog)
{
  // TODO - CHECK ERROR!!!
  Widget *label = new Widget[_num_text_fields]; 


  register unsigned int		offset;

  _name = GETMSG(DT_catd, 1, 192, "Mailer - Find");

  title(_name);

	// make this a modal dialog
	/*
	XtVaSetValues (dialog,
			XmNdialogStyle,	XmDIALOG_FULL_APPLICATION_MODAL,
			NULL);
	*/

  	printHelpId("dialog", dialog);

  /* add help callback */
  // XtAddCallback(dialog, XmNhelpCallback, HelpCB, helpId);

	Widget fd_pane = XtVaCreateWidget ("fd_pane",
				xmPanedWindowWidgetClass,
				dialog,
				XmNsashWidth,	1,
				XmNsashHeight,	1,
				NULL);

	printHelpId ("fd_pane", fd_pane);
	// add help callback
	// XtAddCallback (fd_pane, XmNhelpCallback, HelpCB, helpId);

	Widget	fd_form = XtVaCreateWidget ("fd_form",
				xmFormWidgetClass,
				fd_pane,
				XmNfractionBase,	100,
				NULL);

	printHelpId ("fd_form", fd_form);
	// add help callback
	// XtAddCallback (fd_form, XmNhelpCallback, HelpCB, helpId);


	Widget _fd_labelbox = XtVaCreateManagedWidget ("_fd_labelbox",
				xmRowColumnWidgetClass,
				fd_form,
				XmNtopAttachment,	XmATTACH_FORM,
				XmNleftAttachment,	XmATTACH_POSITION,
				XmNrightAttachment,	XmATTACH_POSITION,
				XmNleftPosition,	5,
				XmNrightPosition,	95,
				XmNpacking,		XmPACK_COLUMN,
				XmNnumColumns,		2,
				XmNorientation,		XmVERTICAL,
				XmNisAligned,		True,
				XmNentryAlignment,	XmALIGNMENT_END,
				XmNentryVerticalAlignment,	XmALIGNMENT_CENTER,
				NULL); 
	printHelpId ("_fd_labelbox", _fd_labelbox);
	// add help callback
	// XtAddCallback (_fd_labelbox, XmNhelpCallback, HelpCB, helpId);


	Widget	*_fd_labels = new Widget [_num_text_fields];

	int	_fd_i = 0;
	for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++)
	{
		_fd_labels [_fd_i] = XtVaCreateManagedWidget (
					_text_labels [_fd_i],
					xmLabelGadgetClass,
					_fd_labelbox,
					NULL);

		printHelpId ("_fd_labels [%s]", _fd_labels [_fd_i]);
		// naturally, this is bogus --must be fixed to return proper label
		// add help callback
		// XtAddCallback(_fd_labels [_fd_i], XmNhelpCallback, HelpCB, helpId);
	}

	for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++)
	{
		_text_fields [_fd_i] = XtVaCreateManagedWidget (
					_text_names [_fd_i],
					xmTextFieldWidgetClass,
					_fd_labelbox,
					NULL);
		printHelpId ("_text_fields [%s]", _text_fields [_fd_i]);
		// naturally, this is bogus --must be fixed to return proper label
		// add help callback
		// XtAddCallback(_text_fields [_fd_i], XmNhelpCallback, HelpCB, helpId);

		XtAddCallback(_text_fields [_fd_i], XmNactivateCallback,
			(XtCallbackProc)textFieldCallback, (XtPointer)this);
	}


  XmString	strForward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 193, "Forward"));
  XmString	strBackward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 194, "Backward"));

  Widget fd_direction
	= XmVaCreateSimpleRadioBox(fd_form,
				"Direction",
			       0,		// Initial selection
			       directionCallback,
				//NULL,
			       XmVaRADIOBUTTON, strForward, NULL, NULL, NULL,
			       XmVaRADIOBUTTON, strBackward, NULL, NULL, NULL,
			       XmNuserData,	this,
				XmNsensitive,	True,
				XmNtopAttachment,	XmATTACH_WIDGET,
				XmNtopWidget,		_fd_labelbox,
				XmNorientation,	XmHORIZONTAL,
				XmNleftAttachment,	XmATTACH_POSITION,
				XmNleftPosition,	33,
			       NULL);
	 printHelpId ("fd_direction", fd_direction);
	// add help callback
	//XtAddCallback (fd_direction, XmNhelpCallback, HelpCB, helpId);

  XmStringFree(strForward);
  XmStringFree(strBackward);

  //
  // Now create the Action Area.
  //
#define TIGHTNESS	20

  register Widget		widget;

  Widget fd_action = XtVaCreateWidget("actionArea",
				 xmFormWidgetClass,
				 fd_pane,
				 XmNleftAttachment,	XmATTACH_FORM,
				 XmNrightAttachment,	XmATTACH_FORM,
				 XmNfractionBase, TIGHTNESS * _num_buttons-1,
				 NULL);
	 printHelpId ("actionArea", fd_action);
	// add help callback
	//XtAddCallback (fd_action, XmNhelpCallback, HelpCB, helpId);

  for (offset = 0; offset < _num_buttons; offset++) 
  {  widget = XtVaCreateManagedWidget(_buttonData[offset].label,
				     xmPushButtonWidgetClass,	fd_action,

				     XmNleftAttachment,
				     offset ? XmATTACH_POSITION:XmATTACH_FORM,

				     XmNleftPosition,	TIGHTNESS * offset,
				     XmNtopAttachment,	XmATTACH_FORM,

				     XmNrightAttachment,
				     offset != _num_buttons - 1 ? XmATTACH_POSITION : XmATTACH_FORM,

				     XmNrightPosition,
				     TIGHTNESS * offset + (TIGHTNESS - 1),

				     XmNshowAsDefault,	offset == 0,
				     NULL);

	// again, bogus -- doesn't each one need a unique tag?
	 printHelpId ("widget", widget);
	// add help callback
	//XtAddCallback (widget, XmNhelpCallback, HelpCB, helpId);

    if (_buttonData[offset].callback != NULL) {
      XtAddCallback(widget, XmNactivateCallback,
		    _buttonData[offset].callback,
		    _buttonData[offset].data);
    }


    if (offset == 0) {
      Dimension		height;
      Dimension		margin;

      XtVaGetValues(fd_action, XmNmarginHeight, &margin, NULL);
      XtVaGetValues(widget, XmNheight, &height, NULL);
      height +=2 * margin;
      XtVaSetValues(fd_action,
		    XmNdefaultButton,	widget,
		    XmNpaneMaximum,	height,
		    XmNpaneMinimum,	height,
		    NULL);

    }
  }

  _status_text = XtVaCreateManagedWidget("StatusLabel",
					   xmLabelWidgetClass, fd_pane,
                                           XmNrightAttachment, XmATTACH_FORM,
                                           XmNleftAttachment, XmATTACH_FORM,
                                           XmNalignment, XmALIGNMENT_BEGINNING,
                                           NULL);
	    
  Dimension height;
  XtWidgetGeometry size;

  size.request_mode = CWHeight;
  XtQueryGeometry(_status_text, NULL, &size);
  XtVaSetValues(_status_text,
		XmNpaneMaximum, size.height,
		XmNpaneMinimum, size.height,
		NULL);
 
  clearStatus();

  XtManageChild (fd_form);
  XtManageChild (fd_direction);
  XtManageChild(fd_action);
  XtManageChild(fd_pane);

  XtManageChild(dialog);

  // Make sure get the height of the dialog after it has been
  // managed.
  XtVaGetValues(dialog, XmNheight, &height, NULL);
  XtVaSetValues(dialog, 
		XmNmappedWhenManaged, True,
		XmNminHeight, height,
		NULL);
  XtRealizeWidget(dialog);

  return (fd_pane);
}