示例#1
0
int
XmLMessageBox(Widget w,
	      char *string,
	      Boolean okOnly)
	{
	int status = 0;
	Widget dialog, shell;
	Arg args[3];
	XtAppContext context;
	XmString str, titleStr;
	String shellTitle;
	Atom WM_DELETE_WINDOW;

	str = XmStringCreateLtoR(string, XmSTRING_DEFAULT_CHARSET);
	XtSetArg(args[0], XmNmessageString, str);
	XtSetArg(args[1], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL);
	shell = XmLShellOfWidget(w);
	if (shell)
		XtVaGetValues(shell, XmNtitle, &shellTitle, NULL);
	if (shell && shellTitle)
		titleStr = XmStringCreateLtoR(shellTitle,
			XmSTRING_DEFAULT_CHARSET);
	else
		titleStr = XmStringCreateSimple("Notice");
	XtSetArg(args[2], XmNdialogTitle, titleStr);
	if (okOnly == True)
		dialog = XmCreateMessageDialog(XtParent(w), "popup", args, 3);
	else
		dialog = XmCreateQuestionDialog(XtParent(w), "popup", args, 3);
	WM_DELETE_WINDOW = XmInternAtom(XtDisplay(w), "WM_DELETE_WINDOW",
		False);
	XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, XmLMessageBoxWMDelete,
		(caddr_t)&status);
	XmStringFree(str);
	XmStringFree(titleStr);
	XtAddCallback(dialog, XmNokCallback, XmLMessageBoxResponse,
		(XtPointer)&status);
	if (okOnly == True)
		{
		XtUnmanageChild(XmMessageBoxGetChild(dialog,
			XmDIALOG_CANCEL_BUTTON));
		XtUnmanageChild(XmMessageBoxGetChild(dialog,
			XmDIALOG_HELP_BUTTON));
		}
	else
		{
		XtAddCallback(dialog, XmNcancelCallback, XmLMessageBoxResponse,
			(XtPointer)&status);
		XtAddCallback(dialog, XmNhelpCallback, XmLMessageBoxResponse,
			(XtPointer)&status);
		}
	XtManageChild(dialog);

	context = XtWidgetToApplicationContext(w);
	while (!status ||  XtAppPending(context))
		XtAppProcessEvent(context, XtIMAll);
	XtDestroyWidget(dialog);
	return status;
	}
示例#2
0
void appIcon_SetupClose(Widget* w_TopLevel, XtCallbackProc xcp_CloseProc, XtPointer client_data)
{
	/* get window manager delete protocol atom */
	APPICON_DelWin_protocol = XmInternAtom(XtDisplay(*w_TopLevel), "WM_DELETE_WINDOW", True);
	
    /* turn off default delete response */
    XtVaSetValues( *w_TopLevel, XmNdeleteResponse, XmDO_NOTHING, NULL);
    
    /* add callback for window manager delete protocol */
    XmAddWMProtocolCallback(*w_TopLevel, APPICON_DelWin_protocol, xcp_CloseProc, client_data);
}
示例#3
0
void imagesc(void *data, int x, int y, const char* type,
             double (*transf)(double), const char **colormap, char *title)
{
  static XtAppContext context;
  Widget drawing_area;
  Widget toplevel;
  Atom wm_delete;
  XEvent event;
  XpmImage *xpmImage;
  Boolean exitFlag = False;
  static Display *display = NULL;
  Arg al[10];
  int ac;
  int argc = 0;

  xpmImage = CreateXpmImage(data, x, y, type, transf, colormap);

  /* create the toplevel shell */
  XtToolkitInitialize();
  if (display == NULL) {
    context = XtCreateApplicationContext();
    display = XtOpenDisplay(context, NULL, NULL, "", NULL, 0, &argc, NULL);
  }
  toplevel =XtAppCreateShell(title, "", applicationShellWidgetClass, display, NULL, 0);

  /* set window size. */
  ac=0;
  XtSetArg(al[ac],XmNmaxWidth,  x); ac++;
  XtSetArg(al[ac],XmNmaxHeight, y); ac++;
  XtSetArg(al[ac],XmNminWidth,  x); ac++;
  XtSetArg(al[ac],XmNminHeight, y); ac++;
  XtSetArg(al[ac],XmNdeleteResponse, XmDO_NOTHING); ac++;
  XtSetValues(toplevel,al,ac);

  ac=0;
  drawing_area=XmCreateDrawingArea(toplevel,"drawing_area",al,ac);
  XtManageChild(drawing_area);
  XtAddCallback(drawing_area,XmNexposeCallback,draw_pixmap,(XtPointer) xpmImage);
  XtAddEventHandler(drawing_area, KeyReleaseMask, false, KeyAction, (XtPointer) &exitFlag);
  XtRealizeWidget(toplevel);
  wm_delete = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False);
  XmAddWMProtocolCallback(toplevel, wm_delete, quitCB, (XtPointer) &exitFlag);
  XmActivateWMProtocol(toplevel, wm_delete);

  while (!exitFlag) {
    XtAppNextEvent(context, &event);
    XtDispatchEvent(&event);
  }

  XtDestroyWidget(drawing_area);
  XtDestroyWidget(toplevel);
  free(xpmImage);
}
示例#4
0
Window::Window(std::string name) : Container(name)
{
  Arg args[1];

  XtSetArg(args[0], XmNdeleteResponse, XmDO_NOTHING);
  widget = XtAppCreateShell(Application::getName().c_str(), Application::getName().c_str(), applicationShellWidgetClass, Application::getDisplay(), args, 1);

  deleteWindowAtom = XmInternAtom(XtDisplay(widget), (char*)"WM_DELETE_WINDOW", False);
  XmAddWMProtocolCallback(widget, deleteWindowAtom, closeCallback, (void*)this);
  XtAddEventHandler(widget, StructureNotifyMask, False, eventCallback, (void*)this);
  XtAddEventHandler(widget, FocusChangeMask, False, eventCallback, (void*)this);

  contentPanel.reset(new Panel(name, this));
}
示例#5
0
void
ui_add_window_close_callback(
    Widget	   shell,
    XtCallbackProc delete_callback,
    XtPointer	   client_data,
    unsigned char  delete_response
)
{
    Atom WM_DELETE_WINDOW;

    WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);

    XtVaSetValues(shell, XmNdeleteResponse, delete_response, NULL);
    XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, delete_callback, client_data);

}
/*********************************************************
    popdownProductDescriptionShell
*********************************************************/
static void popdownProductDescriptionShell(XtPointer xtPointer)
{
	Arg args[3];
	Widget widget;
	Atom WM_DELETE_WINDOW;

	widget = (Widget) xtPointer;
	XtPopdown(widget);

	XtSetArg(args[0],XmNmwmDecorations,MWM_DECOR_ALL);
	XtSetArg(args[1],XmNdeleteResponse,XmDO_NOTHING);
	XtSetValues(widget,args,2);

	WM_DELETE_WINDOW = XmInternAtom(XtDisplay(widget),
	    "WM_DELETE_WINDOW",False);
	XmAddWMProtocolCallback(widget,WM_DELETE_WINDOW,
	    (XtCallbackProc)closeProductDescriptionCallback,(XtPointer)widget);

	/* Next time up the OK button will show */
	XtManageChild(okButton);
}
示例#7
0
static void
InstallClose(
        ChangeDirRec *change_dir_rec,
        XtCallbackProc callback,
        XtPointer client_data )
{
   Widget close_widget;
   Atom delete_window_atom;

   close_widget =
      XmSelectionBoxGetChild (change_dir_rec->change_dir,
                                             XmDIALOG_CANCEL_BUTTON);

   XtAddCallback (close_widget, XmNactivateCallback, callback, client_data);

   delete_window_atom = XmInternAtom (XtDisplay(change_dir_rec->shell),
                                      "WM_DELETE_WINDOW", True);
   XmRemoveWMProtocols( change_dir_rec->shell, &delete_window_atom, 1 );
   XmAddWMProtocolCallback( change_dir_rec->shell, delete_window_atom, callback,
                            (XtPointer)client_data );
}
示例#8
0
void Dialog::post()
{
    theApplication->setBusyCursor(TRUE);
    if (this->getRootWidget() == NULL)
    {
	this->initialize();
	this->setRootWidget(this->createDialog(this->parent));

	Widget shell = XtParent(this->getRootWidget());
	XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL);
	Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell),
					    "WM_DELETE_WINDOW", False);
	XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW,
				    (XtCallbackProc)Dialog_CancelCB,
				    (void *)(this));


	if (this->ok != NULL)
	    XtAddCallback(this->ok,
			  XmNactivateCallback,
			  (XtCallbackProc)Dialog_OkCB,
			  (XtPointer)this);
	if (this->help != NULL)
	    XtAddCallback(this->help,
			  XmNactivateCallback,
			  (XtCallbackProc)Dialog_HelpCB,
			  (XtPointer)this);
	if (this->cancel != NULL)
	    XtAddCallback(this->cancel,
			  XmNactivateCallback,
			  (XtCallbackProc)Dialog_CancelCB,
			  (XtPointer)this);
    }

    this->manage();
    theApplication->setBusyCursor(FALSE);

    XmUpdateDisplay(this->getRootWidget());
}
示例#9
0
/***********************************************************************
 * Arrange to receive  (synthetic) ConfigureNotify events on the proper
 * windows of this instance and relay them to the embedded apps
 ***********************************************************************/
static void
SetupStructureNotify (PluginInstance* This)
{
    /* Get ConfigureNotify when the browser is moved */
    XtAddRawEventHandler (This->toplevel_widget,
			  StructureNotifyMask,
			  False,
			  StructureNotifyHandler,
			  (XtPointer) This);

    XtAddRawEventHandler (This->toplevel_widget,
			  NoEventMask,
			  True,
			  RxpWmDelWinHandler,
			  (XtPointer) This);
#if 0
    XmAddWMProtocolCallback (This->toplevel_widget,
			     RxGlobal.wm_delete_window,
			     RxpWmDelWinHandler,
			     (XtPointer) This);
#endif
}
示例#10
0
文件: DialogShell.C 项目: juddy/edcde
void
DialogShell::initialize()
{
    _w = XtVaCreatePopupShell(
             _name, _widgetClass, _parent->baseWidget(),
             XmNdefaultPosition, False,
             NULL, NULL );
#ifdef USE_EDITRES
    XtAddEventHandler(
        _w, (EventMask) 0, True,
        (XtEventHandler) _XEditResCheckMessages, NULL);
#endif

    installDestroyHandler();
    _workArea = createWorkArea ( _w );
    assert ( _workArea != NULL );

    XtVaSetValues( _w, XmNdefaultPosition, False, NULL );
    XtAddCallback( _w,
                   XmNpopupCallback,
                   ( XtCallbackProc ) &DialogShell::popupCallback,
                   XtPointer( this ) );
    XtAddCallback( _w,
                   XmNpopdownCallback,
                   ( XtCallbackProc ) &DialogShell::popdownCallback,
                   XtPointer( this ) );

    Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ),
                                        "WM_DELETE_WINDOW",
                                        False );

    XmAddWMProtocolCallback( _w,
                             WM_DELETE_WINDOW,
                             ( XtCallbackProc ) quitCallback,
                             this );

//  if (!XtIsManaged(_workArea)) XtManageChild(_workArea);
}
示例#11
0
/*----------------------------------------------------------------------*/
/* extern */ void
XfeShellAddCloseCallback(Widget			shell,
						 XtCallbackProc	callback,
						 XtPointer		data)
{
	static Atom wm_delete_window = None;

    assert( XtIsShell(shell) );

	if (!_XfeIsAlive(shell))
	{
		return;
	}

	if (wm_delete_window == None)
	{
		wm_delete_window = XmInternAtom(XtDisplay(shell),
										"WM_DELETE_WINDOW",
										False);
	}
		
	XmAddWMProtocolCallback(shell,wm_delete_window,callback,data);
}
示例#12
0
/******************************************************
  audioSetupCreateDialog
******************************************************/
static void audioSetupCreateDialog(Widget menuButton)
{
    Widget audioSetupDialogShell;
    Widget form,form1;
    Widget filename;
    Widget button;
    Widget toggleButton;
    Widget frame, rowcol;
    Widget label;
    Pixel textBackground;
    XmString string;
    static ActionAreaItem audioSetup_items[] = {
         { "Dismiss", audioSetupDismissCallback, NULL} };
    ALINK      *area;

    textBackground = bg_pixel[3];

    XtVaGetValues(menuButton, XmNuserData, &area, NULL);

    if (audioSetup.audioSetupDialog){
        if (XtIsManaged(audioSetup.audioSetupDialog)) return;
        else XtManageChild(audioSetup.audioSetupDialog);
    }

    audioSetupDialogShell = XtVaCreatePopupShell("ALH Audio Setup",
        transientShellWidgetClass, area->toplevel, NULL, 0);

    /* Modify the window manager menu "close" callback */
    {
        Atom         WM_DELETE_WINDOW;
        XtVaSetValues(audioSetupDialogShell,
            XmNdeleteResponse, XmDO_NOTHING, NULL);
        WM_DELETE_WINDOW = XmInternAtom(XtDisplay(audioSetupDialogShell),
            "WM_DELETE_WINDOW", False);
        XmAddWMProtocolCallback(audioSetupDialogShell,WM_DELETE_WINDOW,
            (XtCallbackProc)audioSetupDismissCallback, (XtPointer)menuButton);
    }

    form = XtVaCreateWidget("audioSetupDialog",
        xmFormWidgetClass, audioSetupDialogShell,
        NULL);
    audioSetup.audioSetupDialog = form;

    string = XmStringCreateSimple("Audio Beep Output");
    label = XtVaCreateManagedWidget("audioOutputLabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_FORM,
        XmNtopWidget,              form,
        NULL);
    XmStringFree(string);

    frame = XtVaCreateWidget("frame",
        xmFrameWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    rowcol = XtVaCreateWidget("rowcol",
        xmRowColumnWidgetClass, frame,
        XmNspacing,         0,
        XmNmarginWidth,     10,
        XmNmarginHeight,    10,
        XmNradioBehavior,    TRUE,
        XmNbackground,      textBackground,
        NULL);

    toggleButton = XtVaCreateManagedWidget("Internal speaker",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        (Boolean)((audioSetup.port==AUDIO_INTERNAL_SPEAKER)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_INTERNAL_SPEAKER);

    toggleButton = XtVaCreateManagedWidget("Default digital audio output",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        (Boolean)((audioSetup.port==AUDIO_DEFAULT_OUTPUT)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_DEFAULT_OUTPUT);

    XtManageChild(rowcol);
    XtManageChild(frame);

    string = XmStringCreateSimple("Audio Beep Source");
    label = XtVaCreateManagedWidget("audioBeepSourceLabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        NULL);
    XmStringFree(string);

    frame = XtVaCreateWidget("frame",
        xmFrameWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    audioSetup.beepSourceFrameWidget = frame;
    if (audioSetup.port==AUDIO_INTERNAL_SPEAKER) XtSetSensitive(frame, FALSE);
    else XtSetSensitive(frame, TRUE);

    rowcol = XtVaCreateWidget("rowcol",
        xmRowColumnWidgetClass, frame,
        XmNspacing,          0,
        XmNmarginWidth,      10,
        XmNmarginHeight,     10,
        XmNradioBehavior,    TRUE,
        XmNbackground,     textBackground,
        NULL);

    toggleButton = XtVaCreateManagedWidget("alh internal beep",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        /*1XmNalignment,XmALIGNMENT_CENTER*/
        NULL);
    XmToggleButtonSetState(toggleButton,
        (Boolean)((audioSetup.beepSource==BEEP_AUDIO_SOURCE_INTERNAL)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupBeepSourceChangeCallback,
        (XtPointer)BEEP_AUDIO_SOURCE_INTERNAL);

    if ( audioSetup.beep==0 ) {
        audioSetup.beep = beep;
        audioSetup.beepLength = beepLength;
    }

    toggleButton = XtVaCreateManagedWidget("WAV (.wav) file",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        (Boolean)((audioSetup.beepSource==BEEP_AUDIO_SOURCE_FILE)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupBeepSourceChangeCallback, (XtPointer)BEEP_AUDIO_SOURCE_FILE);

    XtManageChild(rowcol);
    XtManageChild(frame);

    string = XmStringCreateSimple("WAVE (.wav) filename");
    label = XtVaCreateManagedWidget("audioFilenamelabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        NULL);
    XmStringFree(string);

    button = XtVaCreateManagedWidget("Browse",
        xmPushButtonWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        XmNleftAttachment,         XmATTACH_WIDGET,
        XmNleftWidget,             label,
        XmNrightAttachment,        XmATTACH_FORM,
        XmNshadowThickness,        1,
        NULL);

    filename = XtVaCreateManagedWidget("filename",
        xmTextFieldWidgetClass, form,
        XmNbackground,      textBackground,
        XmNtopAttachment,   XmATTACH_WIDGET,
        XmNtopWidget,       button,
        XmNleftAttachment,  XmATTACH_FORM,
        XmNrightAttachment, XmATTACH_FORM,
        NULL);

    XtAddCallback(button, XmNactivateCallback,
        audioSetupFilenameBrowseCallback, filename);

    XmTextFieldSetString(filename,audioSetup.beepFileName);

    XtAddCallback(filename, XmNactivateCallback,
        audioSetupFilenameChangeCallback, NULL);

    string = XmStringCreateSimple("Test Beep");
    label = XtVaCreateManagedWidget("audioTestlabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              filename,
        XmNleftAttachment,         XmATTACH_FORM,
        NULL);
    XmStringFree(string);

    button = XtVaCreateManagedWidget("Beep",
        xmPushButtonWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        XmNshadowThickness,        2,
        NULL);
    XtAddCallback(button, XmNactivateCallback,
        audioSetupTestBeepCallback, NULL);

    /* Set the client data "Dismiss" button's callbacks. */
    audioSetup_items[0].data = (XtPointer)menuButton;

    form1 = createActionButtons(form, audioSetup_items,
        XtNumber(audioSetup_items));
    if (form1) XtVaSetValues(form1,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              button,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    XtManageChild(form);
    XtRealizeWidget(audioSetupDialogShell);
}
示例#13
0
static Widget
create_dialogs(popupMessageSizeHintT size,
	       Widget parent,
	       int cnt,
	       const char *helptext,
	       pre_message_cbT pre_cb, XtPointer arg,
	       const char *yes_button, message_cbT yes_cb, XtPointer yes_arg,
	       const char *no_button, message_cbT no_cb, XtPointer no_arg,
	       const char *cancel_button, message_cbT cancel_cb, XtPointer cancel_arg)
{
    Widget new_popup_window;
    char *translations_str = NULL;
#ifdef MOTIF
    Widget new_dialog;
    UNUSED(size);
#else
    char *key_translations_str = NULL;
    int msg_w = 400, msg_h = 100;
    Widget new_message_paned, new_message_text, new_message_box, new_message_ok,
	new_message_help = 0, new_message_not_ok;
    XtTranslations wm_translations, key_translations;
#endif

    /* save callbacks to global arrays */
    pre_callbacks[cnt].callback = pre_cb;
    pre_callbacks[cnt].arg = arg;
    
    yes_callbacks[cnt].callback = yes_cb;
    yes_callbacks[cnt].arg = yes_arg;

    no_callbacks[cnt].callback = no_cb;
    no_callbacks[cnt].arg = no_arg;

    cancel_callbacks[cnt].callback = cancel_cb;
    cancel_callbacks[cnt].arg = cancel_arg;

    XtAddActions(popdown_actions, XtNumber(popdown_actions));

#ifndef MOTIF
    /* get index into WM_popdown arg */
    translations_str = get_string_va("<Message>WM_PROTOCOLS: WM_popdown(%d)", cnt);
    wm_translations = XtParseTranslationTable(translations_str);
    free(translations_str);
#endif

    if (!XtIsRealized(globals.widgets.top_level)) {
	/* If toplevel window hasn't been realized yet, create a new toplevel shell
	   (otherwise, setting visual/color map wouldn't work); use same application names
	   so that resource settings will also apply to this window.
	*/
	new_popup_window = XtVaAppCreateShell("xdvi", "Xdvi",
					      transientShellWidgetClass, DISP,
					      NULL);
    }
    else {
	new_popup_window = XtVaCreatePopupShell(Xdvi_MESSAGE_SHELL_NAME,
#ifdef MOTIF
						xmDialogShellWidgetClass, parent,
						XmNdeleteResponse, XmDO_NOTHING, /* we'll take care of that ourselves */
#else
						transientShellWidgetClass, parent,
						XtNx, 60,
						XtNy, 80,
						XtNtranslations, wm_translations,
						XtNaccelerators, G_accels_cr,
#endif
						XtNtransientFor, parent,
						XtNmappedWhenManaged, False,
						NULL);
    }
    
#ifdef MOTIF

    WM_DELETE_WINDOW = XmInternAtom(XtDisplay(new_popup_window), "WM_DELETE_WINDOW", False);
    XmAddWMProtocolCallback(new_popup_window, WM_DELETE_WINDOW, cancel_action, NULL);
    
    /* We also need to override the default ESC binding to use our internal
       housekeeping functions */
    translations_str = get_string_va("#override\n<Key>osfCancel:close-popup-cancel(%d)", cnt);
    /*      { */
    /*  	XtTranslations xlats; */
    /*  	char *translation_str = get_string_va("<Key>osfCancel:close-popup-cancel(%d)", cnt); */
    /*  	xlats = XtParseTranslationTable(translation_str); */
    /*  	free(translation_str); */
    /*  	XtOverrideTranslations(new_dialog, xlats); */
    /*      } */

    new_dialog = XtVaCreateWidget(Xdvi_MESSAGE_DIALOG_NAME, xmMessageBoxWidgetClass, new_popup_window,
				  XmNdialogType, XmDIALOG_WARNING, /* default */
				  XmNtraversalOn, True,
				  XmNhighlightOnEnter, True,
				  XmNuserData, cast_int_to_XtPointer(cnt),
				  XmNtranslations, XtParseTranslationTable(translations_str),
				  NULL);
    free(translations_str);
    XtAddCallback(new_dialog, XmNokCallback, ok_action, NULL);

    if (no_button != NULL) {
	Arg args[4];
	Widget b;
	XmString b_str = XmStringCreateLocalized((char *)no_button);
	XtSetArg(args[0], XmNlabelString, b_str);
	b = XmCreatePushButton(new_dialog, "no_button", args, 1);
	XtAddCallback(b, XmNactivateCallback, not_ok_action, NULL);
	XtManageChild(b);
    }
    
    if (cancel_button != NULL) {
	XmString cancel_label = XmStringCreateLtoR((char *)cancel_button, G_charset);
	XtVaSetValues(XmMessageBoxGetChild(new_dialog, XmDIALOG_CANCEL_BUTTON),
		      XmNlabelString, cancel_label, NULL);
	XmStringFree(cancel_label);
	XtAddCallback(new_dialog, XmNcancelCallback, cancel_action, NULL);
    }
    else {
	XtUnmanageChild(XmMessageBoxGetChild(new_dialog, XmDIALOG_CANCEL_BUTTON));
    }
    XtInstallAllAccelerators(new_dialog,
			     XmMessageBoxGetChild(new_dialog, XmDIALOG_OK_BUTTON));

    if (helptext != NULL) {
	XtAddCallback(new_dialog, XmNhelpCallback, help_action, (XtPointer)helptext);
    }
    else {
	XtUnmanageChild(XmMessageBoxGetChild(new_dialog, XmDIALOG_HELP_BUTTON));
    }

    if (yes_button != NULL) { /* change `OK' button label */
	XmString yes_label;
	yes_label = XmStringCreateLtoR((char *)yes_button, G_charset);
	XtVaSetValues(XmMessageBoxGetChild(new_dialog, XmDIALOG_OK_BUTTON),
		      XmNlabelString, yes_label, NULL);
	XmStringFree(yes_label);
    }
    
    /* insert the new widgets into the global arrays */
    dialog[cnt] = new_dialog;

#else /* MOTIF */
    switch (size) {
    case SIZE_SMALL:
	msg_w = 300;
	msg_h = 100;
	break;
    case SIZE_MEDIUM:
	msg_w = 430;
	msg_h = 160;
	break;
    case SIZE_LARGE:
	msg_w = 450;
	msg_h = 180;
	break;
    }
    WM_DELETE_WINDOW = XInternAtom(XtDisplay(new_popup_window), "WM_DELETE_WINDOW", False);
    
    new_message_paned = XtVaCreateManagedWidget("message_paned", panedWidgetClass, new_popup_window,
						XtNaccelerators, G_accels_cr,
						NULL);

    new_message_text = XtVaCreateManagedWidget("message_text", asciiTextWidgetClass, new_message_paned,
					       /* 					       XtNheight, 100, */
					       /* 					       XtNwidth, 400, */
					       XtNwidth, msg_w,
					       XtNheight, msg_h,
					       /* wrap horizontally instead of scrolling
						* TODO: this won't work for the first widget instance?
						*/
					       XtNwrap, XawtextWrapWord,
					       XtNscrollVertical, XAW_SCROLL_ALWAYS,
					       XtNeditType, XawtextRead,
					       XtNinput, True,
					       XtNdisplayCaret, False,
					       XtNleftMargin, 5,
					       XtNaccelerators, G_accels_cr,
					       NULL);

    /* box for the OK/Cancel button */
    new_message_box = XtVaCreateManagedWidget("message_box", formWidgetClass, new_message_paned,
					      /* resizing by user isn't needed */
					      XtNshowGrip, False,
					      XtNdefaultDistance, 6, /* some padding */
					      /* resizing the window shouldn't influence this box,
					       * but only the text widget
					       */
					      XtNskipAdjust, True,
					      XtNaccelerators, G_accels_cr,
					      NULL);

    new_message_ok = XtVaCreateManagedWidget(yes_button == NULL ? "OK" : yes_button,
					     commandWidgetClass, new_message_box,
					     XtNtop, XtChainTop,
 					     XtNbottom, XtChainBottom,
 					     XtNleft, XtChainLeft,
 					     XtNright, XtChainLeft,
					     XtNaccelerators, G_accels_cr,
					     NULL);
    /* add quit_action callback for the "OK" button */
    /* FIXME: how to make accelerators be accepted by new_popup_window as well? */
    key_translations_str = get_string_va("<Key>q:close-popup-cancel(%d)\n"
					 "<Key>Return:close-popup-cancel(%d)\n"
					 "<Key>Escape:close-popup-cancel(%d)\n",
					 cnt, cnt, cnt);
    key_translations = XtParseTranslationTable(key_translations_str);
    free(key_translations_str);
    XtOverrideTranslations(new_popup_window, key_translations);
    XtOverrideTranslations(new_message_paned, key_translations);
    XtOverrideTranslations(new_message_text, key_translations);
    
    XtInstallAllAccelerators(new_message_box, new_message_ok);
    XtAddCallback(new_message_ok, XtNcallback, ok_action, cast_int_to_XtPointer(cnt));

    /* we create additional buttons in any case,
       to make the sizing more consistent */
    new_message_help = XtVaCreateManagedWidget("Help", commandWidgetClass, new_message_box,
					       XtNtop, XtChainTop,
					       XtNfromHoriz, new_message_ok,
					       XtNbottom, XtChainBottom,
					       XtNleft, XtChainRight,
					       XtNright, XtChainRight,
					       XtNaccelerators, G_accels_cr,
					       NULL);
    message_help[cnt] = new_message_help;
    
    /* add cancel button */
    new_message_not_ok = XtVaCreateManagedWidget(cancel_button == NULL ? "Cancel" : cancel_button,
						 commandWidgetClass, new_message_box,
						 XtNtop, XtChainTop,
						 XtNfromHoriz, new_message_ok,
						 XtNbottom, XtChainBottom,
						 XtNleft, helptext == NULL ? XtChainRight : XtChainLeft,
						 XtNright, helptext == NULL ? XtChainRight : XtChainLeft,
						 XtNaccelerators, G_accels_cr,
						 NULL);
    message_not_ok[cnt] = new_message_not_ok;

    if (no_button != NULL) {
	ASSERT(0, "third button not yet implemented in Xaw!!!");
    }

    adjust_width_to_max(new_message_ok, new_message_help, new_message_not_ok, NULL);
    
    /* if helptext argument is not-NULL, add help_action callback,
       else unmanage help button */
    if (helptext != NULL) {
	XtAddCallback(new_message_help, XtNcallback, help_action, (XtPointer)helptext);
    }
    else {
	XtUnmanageChild(new_message_help);
    }

    if (cancel_button != NULL) {
	XtAddCallback(new_message_not_ok, XtNcallback, cancel_action, cast_int_to_XtPointer(cnt));
    }
    else {
	XtUnmanageChild(new_message_not_ok);
    }
    /* insert the new widgets into the global arrays */
    message_box[cnt] = new_message_box;
    message_paned[cnt] = new_message_paned;
    message_text[cnt] = new_message_text;
    message_ok[cnt] = new_message_ok;

#endif /* MOTIF */
    popup_window[cnt] = new_popup_window;

    return new_popup_window;
}
示例#14
0
static int motDialogMapMethod(Ihandle* ih)
{
  Widget dialog_manager;
  InativeHandle* parent;
  int mwm_decor = 0;
  int num_args = 0;
  Arg args[20];

  if (iupAttribGetInt(ih, "DIALOGFRAME")) 
  {
    iupAttribSetStr(ih, "RESIZE", "NO");
    iupAttribSetStr(ih, "MAXBOX", "NO");
    iupAttribSetStr(ih, "MINBOX", "NO");
  }

  /****************************/
  /* Create the dialog shell  */
  /****************************/

  if (iupAttribGet(ih, "TITLE"))
      mwm_decor |= MWM_DECOR_TITLE;
  if (iupAttribGetInt(ih, "MENUBOX"))
      mwm_decor |= MWM_DECOR_MENU;
  if (iupAttribGetInt(ih, "MINBOX"))
      mwm_decor |= MWM_DECOR_MINIMIZE;
  if (iupAttribGetInt(ih, "MAXBOX"))
      mwm_decor |= MWM_DECOR_MAXIMIZE;
  if (iupAttribGetInt(ih, "RESIZE"))
      mwm_decor |= MWM_DECOR_RESIZEH;
  if (iupAttribGetInt(ih, "BORDER"))
      mwm_decor |= MWM_DECOR_BORDER;

  iupmotSetArg(args, num_args, XmNmappedWhenManaged, False);  /* so XtRealizeWidget will not show the dialog */
  iupmotSetArg(args, num_args, XmNdeleteResponse, XmDO_NOTHING);
  iupmotSetArg(args, num_args, XmNallowShellResize, True); /* Used so the BulletinBoard can control the shell size */
  iupmotSetArg(args, num_args, XmNtitle, "");
  iupmotSetArg(args, num_args, XmNvisual, iupmot_visual);
  
  if (iupmotColorMap()) 
    iupmotSetArg(args, num_args, XmNcolormap, iupmotColorMap());

  if (mwm_decor != 0x7E) 
    iupmotSetArg(args, num_args, XmNmwmDecorations, mwm_decor);

  if (iupAttribGetInt(ih, "SAVEUNDER"))
    iupmotSetArg(args, num_args, XmNsaveUnder, True);

  parent = iupDialogGetNativeParent(ih);
  if (parent)
    ih->handle = XtCreatePopupShell(NULL, topLevelShellWidgetClass, (Widget)parent, args, num_args);
  else
    ih->handle = XtAppCreateShell(NULL, "dialog", topLevelShellWidgetClass, iupmot_display, args, num_args);

  if (!ih->handle)
    return IUP_ERROR;

  XmAddWMProtocolCallback(ih->handle, iupmot_wm_deletewindow, motDialogCBclose, (XtPointer)ih);

  XtAddEventHandler(ih->handle, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent,      (XtPointer)ih);
  XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
  XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
  XtAddEventHandler(ih->handle, StructureNotifyMask, False, (XtEventHandler)motDialogCBStructureNotifyEvent, (XtPointer)ih);

  XtAddCallback(ih->handle, XmNdestroyCallback, (XtCallbackProc)motDialogDestroyCallback, (XtPointer)ih);

  /*****************************/
  /* Create the dialog manager */
  /*****************************/

  dialog_manager = XtVaCreateManagedWidget(
              "dialog_manager",
              xmBulletinBoardWidgetClass,
              ih->handle,
              XmNmarginWidth, 0,
              XmNmarginHeight, 0,
              XmNwidth, 100,     /* set this to avoid size calculation problems */
              XmNheight, 100,
              XmNborderWidth, 0,
              XmNshadowThickness, 0,
              XmNnoResize, iupAttribGetInt(ih, "RESIZE")? False: True,
              XmNresizePolicy, XmRESIZE_NONE, /* no automatic resize of children */
              XmNuserData, ih, /* used only in motDialogConfigureNotify                   */
              XmNnavigationType, XmTAB_GROUP,
              NULL);

  XtOverrideTranslations(dialog_manager, XtParseTranslationTable("<Configure>: iupDialogConfigure()"));
  XtAddCallback(dialog_manager, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih);
  XtAddEventHandler(dialog_manager, KeyPressMask, False,(XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih);

  /* force the BGCOLOR to match the DLGBGCOLOR */
  motDialogSetBgColorAttrib(ih, IupGetGlobal("DLGBGCOLOR"));

  /* initialize the widget */
  XtRealizeWidget(ih->handle);

  /* child dialogs must be always on top of the parent */
  if (parent)
    XSetTransientForHint(iupmot_display, XtWindow(ih->handle), XtWindow(parent));

  if (mwm_decor != 0x7E)  /* some decoration was changed */
    motDialogSetWindowManagerStyle(ih);

  /* Ignore VISIBLE before mapping */
  iupAttribSetStr(ih, "VISIBLE", NULL);

  if (IupGetGlobal("_IUP_SET_DLGFGCOLOR"))
  {
    iupmotSetGlobalColorAttrib(dialog_manager, XmNforeground, "DLGFGCOLOR");
    IupSetGlobal("_IUP_SET_DLGFGCOLOR", NULL);
  }

  return IUP_NOERROR;
}
示例#15
0
文件: UI2DView.C 项目: bandi13/RGIS
UI2DView::UI2DView () : DBObject ("Noname 2DView",sizeof (UI2DView))

	{
	char name [DBStringLength];
	Widget menuBar, scrolledWindow, radioBox;
	Widget button;
	static Pixmap iconPixmap	 = (Pixmap) NULL, meshPixmap	 = (Pixmap) NULL;
	static Pixmap fullPixmap	 = (Pixmap) NULL, extentPixmap = (Pixmap) NULL;
	static Pixmap capturePixmap = (Pixmap) NULL, redrawPixmap = (Pixmap) NULL;
	static Pixmap zoomPixmap	 = (Pixmap) NULL, panePixmap	 = (Pixmap) NULL, userPixmap	 = (Pixmap) NULL;
	Pixel foreground, background;
	XWindowAttributes xwa;
	XSetWindowAttributes xswa;
	Atom deleteWindowAtom = XmInternAtom(XtDisplay(UITopLevel ()),(char *) "WM_DELETE_WINDOW",FALSE);

	_UI2DViewLIST.Add (this); sprintf (name,"2DView:%2d",RowID ()); Name (name);
	Image = (XImage *) NULL;
	DrawRegion = FullRegion = NULL;
	MaxVertexNumVAR = 0;
	PointARR = (XPoint *) NULL;
	RequiredEXT = (UIDataset ())->Extent ();
	DShell = XtVaCreatePopupShell ("UI2DView",xmDialogShellWidgetClass,UITopLevel (),
												XmNkeyboardFocusPolicy,		XmPOINTER,
												XmNtitle,						Name (),
												XmNtransient,					false,
												XmNminWidth,					600,
												XmNminHeight,					450,
												NULL);
	XmAddWMProtocolCallback (DShell,deleteWindowAtom,(XtCallbackProc) _UI2DViewDeleteCBK,(XtPointer) this);
	MainFormW = XtVaCreateManagedWidget ("UI2DViewForm",xmFormWidgetClass,DShell,
												XmNdialogStyle,				XmDIALOG_WORK_AREA,
												XmNshadowThickness,			0,
												XmNwidth,						600,
												XmNheight,						450,
												NULL);
	menuBar = XtVaCreateManagedWidget ("UI2DViewMenuBar",xmRowColumnWidgetClass,MainFormW,
												XmNtopAttachment,				XmATTACH_FORM,
												XmNtopOffset,					2,
												XmNleftAttachment,			XmATTACH_FORM,
												XmNleftOffset,					2,
												XmNrightAttachment, 			XmATTACH_FORM,
												XmNrightOffset,				2,
												XmNorientation,				XmHORIZONTAL,
												XmNrowColumnType,				XmWORK_AREA,
												NULL);
	XtVaGetValues (MainFormW,XmNforeground,	&foreground,XmNbackground,	&background,NULL);

	iconPixmap = iconPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen (UITopLevel()),(char *) "GHAAS2Dview.bmp",foreground,background): iconPixmap;
	XtVaSetValues (DShell,XmNiconPixmap, iconPixmap,NULL);

	fullPixmap = fullPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASfull.bmp",  foreground,background) : fullPixmap;
	extentPixmap = extentPixmap  == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASextent.bmp",foreground,background) : extentPixmap;
	capturePixmap= capturePixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAAScapture.bmp",foreground,background):capturePixmap;
	redrawPixmap = redrawPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASredraw.bmp", foreground,background) : redrawPixmap;
	zoomPixmap = zoomPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASzoom.bmp",  foreground,background) : zoomPixmap;
	panePixmap = panePixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASpane.bmp",  foreground,background) : panePixmap;
	userPixmap = userPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASuser.bmp",  foreground,background) : userPixmap;
	meshPixmap = meshPixmap == (Pixmap) NULL ?
					XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASmesh.bmp",  foreground,background) : meshPixmap;

	button = XtVaCreateManagedWidget ("UI2DViewRedrawButton",xmPushButtonGadgetClass,menuBar,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				redrawPixmap,
												NULL);
	XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewRedrawCBK,this);
	button = XtVaCreateManagedWidget ("UI2DViewFullButton",xmPushButtonGadgetClass,menuBar,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				fullPixmap,
												NULL);
	XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewFullActivateCBK,this);
	button = XtVaCreateManagedWidget ("UI2DViewExtentButton",xmPushButtonGadgetClass,menuBar,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				extentPixmap,
												NULL);
	XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewExtentActivateCBK,this);
	button = XtVaCreateManagedWidget ("UI2DViewCaptureButton",xmPushButtonGadgetClass,menuBar,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				capturePixmap,
												NULL);
	radioBox = XtVaCreateManagedWidget ("UI2DViewRadioBox",xmRowColumnWidgetClass,menuBar,
												XmNorientation,				XmHORIZONTAL,
												XmNpacking,						XmPACK_COLUMN,
												XmNisHomogeneous,				true,
												XmNentryClass,					xmToggleButtonGadgetClass,
												XmNradioBehavior,				true,
												NULL);
	ZoomToggle = XtVaCreateManagedWidget ("UI2DViewZoomToggle",xmToggleButtonGadgetClass,radioBox,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				zoomPixmap,
												XmNshadowThickness,			0,
												XmNset,							true,
												NULL);
	XtAddCallback (ZoomToggle,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewZoomToggleValueCBK,this);
	PaneToggle = XtVaCreateManagedWidget ("UI2DViewPaneToggle",xmToggleButtonGadgetClass,radioBox,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				panePixmap,
												XmNshadowThickness,			0,
												NULL);
	XtAddCallback (PaneToggle,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewPaneToggleValueCBK,this);
	UserToggle = XtVaCreateWidget ("UI2DViewUserToggle",xmToggleButtonGadgetClass,radioBox,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				userPixmap,
												XmNmappedWhenManaged,		false,
												XmNshadowThickness,			0,
												NULL);
	XtAddCallback (UserToggle,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewUserToggleValueCBK,this);
	if (_UI2DViewUserFunction != (UI2DViewUserFunction) NULL) XtManageChild (UserToggle);
	MeshOptionW = XtVaCreateManagedWidget ("UI2DViewMeshOption",xmToggleButtonGadgetClass,menuBar,
												XmNlabelType,					XmPIXMAP,
												XmNlabelPixmap,				meshPixmap,
												XmNshadowThickness,			0,
												NULL);
	XtAddCallback (MeshOptionW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewMeshOptionCBK,this);
	XtVaSetValues (menuBar,	XmNmenuHelpWidget, MeshOptionW, NULL);

	ScaleW = XtVaCreateManagedWidget ("UI2DViewScale",xmScaleWidgetClass,MainFormW,
												XmNtopAttachment,				XmATTACH_WIDGET,
												XmNtopWidget,					menuBar,
												XmNleftAttachment,			XmATTACH_FORM,
												XmNleftOffset,					2,
												XmNbottomAttachment,			XmATTACH_FORM,
												XmNbottomOffset,				18,
												XmNorientation,				XmVERTICAL,
												XmNwidth,						16,
												NULL);
	XtAddCallback (ScaleW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewScaleValueChangedCBK,this);
	scrolledWindow = XtVaCreateManagedWidget ("UI2DViewScrolledWindow",xmScrolledWindowWidgetClass,MainFormW,
												XmNtopAttachment,				XmATTACH_WIDGET,
												XmNtopWidget,					menuBar,
												XmNtopOffset,					2,
												XmNleftAttachment,			XmATTACH_WIDGET,
												XmNleftWidget,					ScaleW,
												XmNleftOffset,					3,
												XmNrightAttachment,			XmATTACH_FORM,
												XmNrightOffset,				3,
												XmNbottomAttachment,			XmATTACH_FORM,
												XmNbottomOffset,				3,
												XmNspacing,						2,
												NULL);
	HorScrollBarW = XtVaCreateManagedWidget ("UI2DViewHorScrollBar", xmScrollBarWidgetClass, scrolledWindow,
												XmNsliderSize,					100,
												XmNorientation,				XmHORIZONTAL,
												XmNheight,						16,
												NULL);
	XtAddCallback (HorScrollBarW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewHorScrollBarValueChangedCBK,this);
	VerScrollBarW = XtVaCreateManagedWidget ("UI2DViewVerScrollBar", xmScrollBarWidgetClass, scrolledWindow,
												XmNsliderSize,					100,
												XmNorientation,				XmVERTICAL,
												XmNwidth,						16,
												NULL);
	XtAddCallback (VerScrollBarW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewVerScrollBarValueChangedCBK,this);
	DrawingAreaW = XtVaCreateManagedWidget ("UI2DViewDrawingArea", xmDrawingAreaWidgetClass, scrolledWindow,
												XmNuserData,					this,
												XmNbackground,					UIColor (UIColorStandard,0),
												NULL);
	XtAddCallback (DrawingAreaW,XmNresizeCallback,(XtCallbackProc) _UI2DViewResizeCBK,this);
	XtAddEventHandler (DrawingAreaW,EnterWindowMask|LeaveWindowMask|PointerMotionMask|ButtonPressMask|ButtonReleaseMask, false,(XtEventHandler) _UI2DViewPointerEHR,this);
	XmScrolledWindowSetAreas(scrolledWindow,HorScrollBarW,VerScrollBarW,DrawingAreaW);

	_UI2DViewViewCursor  =  _UI2DViewViewCursor != (Cursor) NULL ? _UI2DViewViewCursor : XCreateFontCursor (XtDisplay (DrawingAreaW),XC_top_left_arrow),
	_UI2DViewUserCursor  =  _UI2DViewUserCursor != (Cursor) NULL ? _UI2DViewUserCursor : XCreateFontCursor (XtDisplay (DrawingAreaW),XC_crosshair);
	RegenCursor =  XCreateFontCursor (XtDisplay (DrawingAreaW),XC_watch);
	ActiveCursor = xswa.cursor = _UI2DViewViewCursor;
	XChangeWindowAttributes (XtDisplay (DrawingAreaW), XtWindow (DrawingAreaW), CWCursor, &xswa);

	XGetWindowAttributes (XtDisplay (DrawingAreaW),XtWindow (DrawingAreaW),&xwa);
	Background = xwa.backing_pixel;
	xswa.backing_store = Always;
	XChangeWindowAttributes (XtDisplay (DrawingAreaW),  XtWindow (DrawingAreaW),CWBackingStore,&xswa);
	InputMode (ZOOM_MODE);
	Size ();
	Set ();
	}
示例#16
0
文件: mask.c 项目: epicsdeb/alh
/******************************************************
  maskCreateDialog
******************************************************/
static void maskCreateDialog(ALINK *area)
{
	struct maskWindow *maskWindow;

	Widget maskDialogShell, maskDialog;
	Widget form;
	Widget nameLabelW, nameTextW;
	Widget labelW, pushButtonW, prev;
	int    i,j;
	static ActionAreaItem buttonItems[] = {
		         { "Dismiss", maskDismissCallback, NULL    },
		         { "Help",    maskHelpCallback,    NULL    },
		     	};
	static maskItem maskItem[] = {
		         { "Add/Cancel Alarms",         {{"Add",    0},{"Cancel",  1},{"Reset", 2}}},
		         { "Enable/Disable Alarms",     {{"Enable",10},{"Disable",11},{"Reset",12}}},
		         { "Ack/NoAck Alarms",          {{"Ack",   20},{"NoAck",  21},{"Reset",22}}},
		         { "Ack/NoAck Transient Alarms",{{"AckT",  30},{"NoAckT", 31},{"Reset",32}}},
		         { "Log/NoLog Alarms",          {{"Log",   40},{"NoLog",  41},{"Reset",42}}},
		     	};
	int num_buttons = 3;
	int num_rows = 5;

	if (!area) return;

	maskWindow = (struct maskWindow *)area->maskWindow;

	if (maskWindow && maskWindow->maskDialog){
		if (XtIsManaged(maskWindow->maskDialog)) return;
		else XtManageChild(maskWindow->maskDialog);
	}

	maskWindow = (struct maskWindow *)calloc(1,sizeof(struct maskWindow));
	area->maskWindow = (void *)maskWindow;
	maskWindow->area = (void *)area;

	maskDialogShell = XtVaCreatePopupShell("Modify Mask Settings",
	    transientShellWidgetClass, area->toplevel, 
	    XmNallowShellResize, TRUE,
	    NULL);

	/* Modify the window manager menu "close" callback */
	{
		Atom         WM_DELETE_WINDOW;
		XtVaSetValues(maskDialogShell,
		    XmNdeleteResponse, XmDO_NOTHING, NULL);
		WM_DELETE_WINDOW = XmInternAtom(XtDisplay(maskDialogShell),
		    "WM_DELETE_WINDOW", False);
		XmAddWMProtocolCallback(maskDialogShell,WM_DELETE_WINDOW,
		    (XtCallbackProc)maskDismissCallback, (XtPointer)maskWindow);
	}

	maskDialog = XtVaCreateWidget("maskDialog",
	    xmPanedWindowWidgetClass, maskDialogShell,
	    XmNallowResize,      TRUE,
	    XmNsashWidth,        1,
	    XmNsashHeight,       1,
	    XmNuserData,         area,
	    NULL);

	form = XtVaCreateWidget("control_area",
	    xmFormWidgetClass, maskDialog,
	    XmNfractionBase,    TIGHTNESS*(num_buttons+3) - 1,
	    XmNallowResize,     TRUE,
	    NULL);

	/* ---------------------------------
	     Group/Channel Name 
	     --------------------------------- */
	nameLabelW = XtVaCreateManagedWidget("nameLabelW",
	    xmLabelGadgetClass, form,
	    XmNalignment,       XmALIGNMENT_END,
	    XmNtopAttachment,   XmATTACH_FORM,
	    XmNrightAttachment, XmATTACH_POSITION,
	    XmNrightPosition,   (TIGHTNESS*(num_buttons+3) - 1)/2,
	    XmNrecomputeSize,   True,
	    (XtPointer)NULL);

	nameTextW = XtVaCreateManagedWidget("nameTextW",
	    xmLabelGadgetClass, form,
	    XmNalignment,       XmALIGNMENT_BEGINNING,
	    XmNleftAttachment,  XmATTACH_WIDGET,
	    XmNleftWidget,      nameLabelW,
	    XmNrightAttachment, XmATTACH_NONE,
	    XmNrecomputeSize,   True,
	    NULL);


	prev = nameLabelW;
	for (i = 0; i < num_rows; i++){
		labelW = XtVaCreateManagedWidget(maskItem[i].label,
		    xmLabelGadgetClass,  form,
		    XmNleftAttachment,   XmATTACH_FORM,
		    XmNtopAttachment,    XmATTACH_WIDGET,
		    XmNtopWidget,        prev,
		    XmNtopOffset,        10,
		    NULL);
		for (j = 0; j < num_buttons; j++){
			long index=maskItem[i].choice[j].index;
			pushButtonW = XtVaCreateManagedWidget(
			    maskItem[i].choice[j].label,
			    xmPushButtonWidgetClass, form,
			    XmNuserData,             (XtPointer)area,
			    XmNleftAttachment,       XmATTACH_POSITION,
			    XmNleftPosition,         TIGHTNESS*(j+3),
			    XmNtopAttachment,        XmATTACH_WIDGET,
			    XmNtopWidget,            prev,
			    XmNtopOffset,       5,
			    XmNrightAttachment,
			    j != num_buttons-1? XmATTACH_POSITION : XmATTACH_FORM,
			    XmNrightPosition,        TIGHTNESS*(j+3) + (TIGHTNESS-1),
			    NULL);
			XtAddCallback(pushButtonW, XmNactivateCallback,
			    (XtCallbackProc)maskActivateCallback,
			    (XtPointer)index);
			if (_passive_flag && i == ALARMACKT ) { /* ACKT */
				XtVaSetValues(pushButtonW, XmNsensitive, FALSE, NULL);
			}
		}
		prev=labelW;
	}

	XtManageChild(form);

	/* Set the client data "Dismiss" and "Help" button's callbacks. */
	buttonItems[0].data = (XtPointer)maskWindow;
	buttonItems[1].data = (XtPointer)maskWindow;

	(void)createActionButtons(maskDialog, buttonItems, XtNumber(buttonItems));

	XtManageChild(maskDialog);

	maskWindow->maskDialog = maskDialog;
	maskWindow->nameLabelW = nameLabelW;
	maskWindow->nameTextW = nameTextW;

	XtRealizeWidget(maskDialogShell);
}
示例#17
0
//
// Create a new foe window
// SG 09.02.91 : Create a new toplevel widget and give it an pixmap icon
// SG : 13.02.91 Fetch a caution box and save the id of the widget in the 
//               foe context for futher use
// SG : 24.02.91 Fetch a widget ( again !) . This time a message box
// SG : 24.03.91 Send the routine the desired position (x_top , y_top) 
// and the desired size ( width_adb , height_adb ) for the window to be created.
// The two first parameters are set to the top level widget
// and the two last paramters are set to the adb widget (see in uil file
// the widget hierarchy )
// SG 14.04.91 A new widget to fetch , the help widget ! 
// SG 2.05.91 New parameter : function ( edit , trace , view , simulate ..)
// to indicate which neted events and which menu entries should be alllowed.
//
pwr_tStatus WFoeMotif::create_window( int x_top,
				 int y_top,
				 int width_adb,
				 int height_adb, 
				 ldh_tSesContext ldhsession,
				 foe_eFuncAccess function_access)
{
  Arg	args[20];
  int	sts;
  Widget *children;
  int i, num_children;
  XmString   	TitleStr;
  Dimension icon_w, icon_h;

  /* DRM database hierarchy related variables */
  MrmHierarchy s_MrmH;
  MrmType dclass;
  char		uid_filename[200] = {"pwr_exe:wb_foe.uid"};
  char		*uid_filename_p = uid_filename;
  static Atom	MwmDeleteWind = 0;
  static char translations[] = "\
<FocusIn>: foe_inputfocus()\n";
  static XtTranslations compiled_translations = NULL;

  static XtActionsRec actions[] =
    {
      {(char*) "foe_inputfocus",      (XtActionProc) action_inputfocus}
    };
       
  sts = dcli_translate_filename( uid_filename, uid_filename);
  if ( EVEN(sts)) {
    printf( "** pwr_exe is not defined\n");
    exit(0);
  }

  /*
   * Now start the module creation
   */

  /* Save the context structure in the widget */
  XtSetArg (args[0], XmNuserData, (XtPointer) this);

  /*
   * Create a new main widget
   */
  /*
   * Open the UID files (the output of the UIL compiler) in the hierarchy
   * Register the items DRM needs to bind for us.
   * Create a new neted-widget
   * Close the hierarchy
   * Compile the additional button translations and augment and add actions
   */ 
  sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_MrmH);
  if (sts != MrmSUCCESS) {
    printf("can't open hierarchy\n");
    return 0;
  }

  register_callbacks();

  /* SG 09.02.91 : create the new hierarchy. By the way use a pixmap define
  with help of wb_foe_ptrn.h */

  /* create a pixmap for the icon */
  if ( icon_pixmap == 0 )
    sts = MrmFetchBitmapLiteral(s_MrmH,(char*) "icon",
				XtScreen(parent_wid), XtDisplay(parent_wid),
				&icon_pixmap, &icon_w, &icon_h);  
 
  i=0;
  XtSetArg(args[i],XmNiconName,name);  i++;
  XtSetArg(args[i],XtNiconPixmap,icon_pixmap);  i++;
  
  /* SG 11.02.91 Save the id of the top in the context */ 
  parent_wid = XtCreatePopupShell("plcEditor", 
		     topLevelShellWidgetClass, parent_wid, args, i);

  if (compiled_translations == NULL) 
    XtAppAddActions( XtWidgetToApplicationContext( parent_wid), 
						actions, XtNumber(actions));

  /* the positioning of a top level can only be define after the creation
      of the widget . So i do it know: 
     SG 24.02.91 use the parameters received x and y 
  */

  i=0;
  XtSetArg(args[i],XmNx,x_top);i++;
  XtSetArg(args[i],XmNy,y_top);i++;
  XtSetArg(args[i],XtNallowShellResize,TRUE), i++;

  if ( ! map_window) {
    XtSetArg(args[i],XmNmappedWhenManaged,FALSE); i++;
  }

  XtSetValues( parent_wid, args, i);

  XtSetArg (args[0], XmNuserData, (XtPointer) this);

  /* now that we have a top level we can get the main window */
  sts = MrmFetchWidgetOverride(s_MrmH, (char*) "foe_window", parent_wid ,
		name, args, 1,
		&widgets.foe_window, &dclass);
  if (sts != MrmSUCCESS) printf("can't fetch foedit widget\n");

  /* SG 24.02.91 Set the width and hight desired for the main window to his
	child the adb widget */
  i=0;
  XtSetArg(args[i],XmNwidth,width_adb);i++;
  XtSetArg(args[i],XmNheight,height_adb);i++;
  XtSetValues( widgets.adb  ,args,i);

  /* SG 24.02.91
     Get a litle message box widget that you will make appears when you want by
     calling foe_msgbox
  */

  if (MrmFetchWidget (s_MrmH, 
			(char*) "foe_msgbox", 
			widgets.foe_window,
			&widgets.msgbox,
			&dclass) != MrmSUCCESS)
	printf("can't fetch msgbox \n");

  TitleStr = XmStringCreateLtoR((char*) "PlcEdit Message" , (char*) "ISO8859-1");    
  XtSetArg(args[0],XmNdialogTitle,TitleStr);
  XtSetValues( widgets.msgbox, args, 1);
  XmStringFree(TitleStr);


  /* SG 13.02.91 
     Get a litle caution widget that you will make appears when you want by
     calling foe_popupmsg 
  */

  if (MrmFetchWidget (s_MrmH, 
			(char*) "foe_popupmsg", 
			widgets.foe_window,
			&widgets.caution,
			&dclass) != MrmSUCCESS)
    printf("can't fetch popupmsg\n");

  TitleStr = XmStringCreateLtoR((char*) "PlcEdit Confirm" , (char*) "ISO8859-1");    
  XtSetArg(args[0],XmNdialogTitle,TitleStr);
  XtSetValues( widgets.caution, args, 1);
  XmStringFree(TitleStr);


  /* create the pane widgets */
  /* create the palette module */
  /* SG 07.03.91 put two palletes in the sub pane widget */

  node_palctx = new PalMotif( this, widgets.subpane, "Objects",
		ldhsession, "PlcEditorPalette", 
		&widgets.node_palette, &sts);
  node_palette_managed = 1;

  navctx = new NavMotif( this, widgets.subpane, "Plant",
		ldhsession, "NavigatorW1",
		&widgets.nav_palette, &sts);
  XtUnmanageChild( widgets.nav_palette);

  con_palctx = new PalMotif( this, widgets.subpane, "Connections",
		ldhsession, "PlcEditorConPalette", 
		&widgets.con_palette, &sts);
  XtUnmanageChild( widgets.con_palette);


  /* Turn off traversal for sash widgets */
  XtVaGetValues(widgets.subpane, 
		XmNchildren, &children,
		XmNnumChildren, &num_children,
		NULL);
  for (i = 0; i < num_children; i++) {
    if (XmIsSash(children[i]))
      XtVaSetValues(children[i], XmNtraversalOn, False, NULL);
  }

  /* create the gredit module */
  XtManageChild(widgets.foe_window);


  gre = new WGreMotif( this, widgets.pane, "Name");

  ((WGreMotif *)gre)->new_navigator( widgets.subpane);

  if ( map_window)
    XtPopup(parent_wid, XtGrabNone);
  else
    XtRealizeWidget( parent_wid);

  gre->init();

  /* create the setup ie:
     enable netedevents,
     enable menu entries
     setup backcalls from the gredit module */

  function_setup();

  MrmCloseHierarchy(s_MrmH);

  if (compiled_translations == NULL) 
    compiled_translations = XtParseTranslationTable(translations);
  XtOverrideTranslations( widgets.foe_window, compiled_translations);

  XtUnmanageChild(widgets.textinput);

  if ( !(CoLogin::privilege() & pwr_mPrv_DevPlc ) || 
       (function_access == foe_eFuncAccess_View)) {
    /* Mode Edit and Simulate is not allowed */
    i=0;
    XtSetArg(args[i],XmNsensitive,0); i++;

    XtSetValues( widgets.edit_togg,args,i);
    XtSetValues( widgets.simulate_togg,args,i);
  }

  if (MwmDeleteWind == 0)
    MwmDeleteWind = XInternAtom(XtDisplay(parent_wid), "WM_DELETE_WINDOW", FALSE);

  if (MwmDeleteWind != 0) {
    XtVaSetValues(parent_wid, XmNdeleteResponse, XmDO_NOTHING, NULL);
    XmAddWMProtocolCallback(parent_wid, MwmDeleteWind, 
			    (XtCallbackProc)activate_quit, this);
  }

  CoWowMotif::GetAtoms( parent_wid, 0, &objid_atom, 0);

  /* SG 09.02.91 a top level should always be realized !
   * ML 16.03.94 changed Realize to Popup
   */

  return FOE__SUCCESS;
}
示例#18
0
文件: track_gui.c 项目: dranch/Xastir
void Track_station( /*@unused@*/ Widget w, /*@unused@*/ XtPointer clientData, /*@unused@*/ XtPointer callData) {
    static Widget pane, my_form, button_ok, button_close, button_clear, call, sep;
    Atom delw;

    if (!track_station_dialog) {

begin_critical_section(&track_station_dialog_lock, "track_gui.c:Track_station" );

        track_station_dialog = XtVaCreatePopupShell(langcode("WPUPTSP001"),
                xmDialogShellWidgetClass, appshell,
                XmNdeleteResponse, XmDESTROY,
                XmNdefaultPosition, FALSE,
                XmNfontList, fontlist1,
                NULL);

        pane = XtVaCreateWidget("Track_station pane",
                xmPanedWindowWidgetClass, 
                track_station_dialog,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                NULL);

        my_form =  XtVaCreateWidget("Track_station my_form",
                xmFormWidgetClass, 
                pane,
                XmNfractionBase, 3,
                XmNautoUnmanage, FALSE,
                XmNshadowThickness, 1,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                NULL);

        call = XtVaCreateManagedWidget(langcode("WPUPTSP002"),
                xmLabelWidgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_FORM,
                XmNtopOffset, 10,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_FORM,
                XmNleftOffset, 10,
                XmNrightAttachment, XmATTACH_NONE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        track_station_data = XtVaCreateManagedWidget("Track_station track locate data", 
                xmTextFieldWidgetClass, 
                my_form,
                XmNeditable,   TRUE,
                XmNcursorPositionVisible, TRUE,
                XmNsensitive, TRUE,
                XmNshadowThickness,    1,
                XmNcolumns, 15,
                XmNwidth, ((15*7)+2),
                XmNmaxLength, 15,
                XmNbackground, colors[0x0f],
                XmNtopAttachment,XmATTACH_FORM,
                XmNtopOffset, 5,
                XmNbottomAttachment,XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_WIDGET,
                XmNleftWidget, call,
                XmNleftOffset, 10,
                XmNrightAttachment,XmATTACH_NONE,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                XmNfontList, fontlist1,
                NULL);

        track_case_data  = XtVaCreateManagedWidget(langcode("WPUPTSP003"),
                xmToggleButtonWidgetClass,
                my_form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, call,
                XmNtopOffset, 20,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_FORM,
                XmNleftOffset ,10,
                XmNrightAttachment, XmATTACH_NONE,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        track_match_data  = XtVaCreateManagedWidget(langcode("WPUPTSP004"),
                xmToggleButtonWidgetClass,
                my_form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, call,
                XmNtopOffset, 20,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_WIDGET,
                XmNleftWidget,track_case_data,
                XmNrightOffset ,20,
                XmNrightAttachment, XmATTACH_NONE,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        sep = XtVaCreateManagedWidget("Track_station sep", 
                xmSeparatorGadgetClass,
                my_form,
                XmNorientation, XmHORIZONTAL,
                XmNtopAttachment,XmATTACH_WIDGET,
                XmNtopWidget,track_case_data,
                XmNtopOffset, 10,
                XmNbottomAttachment,XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_FORM,
                XmNrightAttachment,XmATTACH_FORM,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        button_ok = XtVaCreateManagedWidget(langcode("WPUPTSP005"),
                xmPushButtonGadgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, sep,
                XmNtopOffset, 5,
                XmNbottomAttachment, XmATTACH_FORM,
                XmNbottomOffset, 5,
                XmNleftAttachment, XmATTACH_POSITION,
                XmNleftPosition, 0,
                XmNleftOffset, 5,
                XmNrightAttachment, XmATTACH_POSITION,
                XmNrightPosition, 1,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        button_clear = XtVaCreateManagedWidget(langcode("WPUPTSP006"),
                xmPushButtonGadgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, sep,
                XmNtopOffset, 5,
                XmNbottomAttachment, XmATTACH_FORM,
                XmNbottomOffset, 5,
                XmNleftAttachment, XmATTACH_POSITION,
                XmNleftPosition, 1,
                XmNrightAttachment, XmATTACH_POSITION,
                XmNrightPosition, 2,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        button_close = XtVaCreateManagedWidget(langcode("UNIOP00003"),
                xmPushButtonGadgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, sep,
                XmNtopOffset, 5,
                XmNbottomAttachment, XmATTACH_FORM,
                XmNbottomOffset, 5,
                XmNleftAttachment, XmATTACH_POSITION,
                XmNleftPosition, 2,
                XmNrightAttachment, XmATTACH_POSITION,
                XmNrightPosition, 3,
                XmNrightOffset, 5,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        XtAddCallback(button_ok, XmNactivateCallback, Track_station_now, track_station_dialog);
        XtAddCallback(button_close, XmNactivateCallback, track_station_destroy_shell, track_station_dialog);
        XtAddCallback(button_clear, XmNactivateCallback, Track_station_clear, track_station_dialog);

        XmToggleButtonSetState(track_case_data,FALSE,FALSE);
        XmToggleButtonSetState(track_match_data,TRUE,FALSE);

        pos_dialog(track_station_dialog);

        delw = XmInternAtom(XtDisplay(track_station_dialog),"WM_DELETE_WINDOW", FALSE);
        XmAddWMProtocolCallback(track_station_dialog, delw, track_station_destroy_shell, (XtPointer)track_station_dialog);

//        if (track_station_on==1)
            XmTextFieldSetString(track_station_data,tracking_station_call);

        XtManageChild(my_form);
        XtManageChild(pane);

end_critical_section(&track_station_dialog_lock, "track_gui.c:Track_station" );

        XtPopup(track_station_dialog,XtGrabNone);
        fix_dialog_size(track_station_dialog);

        // Move focus to the Cancel button.  This appears to highlight the
        // button fine, but we're not able to hit the <Enter> key to
        // have that default function happen.  Note:  We _can_ hit the
        // <SPACE> key, and that activates the option.
//        XmUpdateDisplay(track_station_dialog);
        XmProcessTraversal(button_close, XmTRAVERSE_CURRENT);

    } else
        (void)XRaiseWindow(XtDisplay(track_station_dialog), XtWindow(track_station_dialog));
}
示例#19
0
UIAttribView::UIAttribView (DBObjData *data) : DBObject (data->Name (),sizeof (UIAttribView))

	{
	DBObjTableField *field;
	DBObjectLIST<DBObjTableField> *fields;
	Widget mainForm, scrolledW, rowCol, label;
	XmString string;
	Atom deleteWindowAtom = XmInternAtom(XtDisplay(UITopLevel ()),(char *) "WM_DELETE_WINDOW",FALSE);

	DataPTR = data;
	ItemTable = DataPTR->Table (DBrNItems);
	Name (UIAttribViewSTR);
	DShellWGT = XtVaCreatePopupShell ("UIAttribView",xmDialogShellWidgetClass,UITopLevel (),
								XmNkeyboardFocusPolicy, XmPOINTER,
								XmNtitle,               data->Name (),
								XmNtransient,           False,
								XmNminWidth,            400,
								XmNminHeight,           300,
								NULL);
	XmAddWMProtocolCallback (DShellWGT,deleteWindowAtom,(XtCallbackProc) _UIAttribViewDeleteCBK,(XtPointer) this);
	mainForm = XtVaCreateWidget ("UIAttribViewForm",xmFormWidgetClass,DShellWGT,
								XmNshadowThickness,			0,
								NULL);
	string = XmStringCreate ((char *) "Item:",UICharSetBold);
	label = XtVaCreateManagedWidget ("UIAttribViewNameLabel",xmLabelWidgetClass,mainForm,
								XmNtopAttachment,       XmATTACH_FORM,
								XmNtopOffset,           5,
								XmNleftAttachment,		XmATTACH_FORM,
								XmNleftOffset,          10,
								XmNlabelString,         string,
								XmNrecomputeSize,       False,
								NULL);
	XmStringFree (string);
	string = XmStringCreate ((char *) "",UICharSetNormal);
	ItemNameWGT = XtVaCreateManagedWidget ("UIAttribViewNameText",xmLabelWidgetClass,mainForm,
								XmNtopAttachment,       XmATTACH_FORM,
								XmNtopOffset,           5,
								XmNleftAttachment,      XmATTACH_WIDGET,
								XmNleftWidget,          label,
								XmNleftOffset,          5,
								XmNlabelString,         string,
								NULL);
	XmStringFree (string);
	scrolledW = XtVaCreateManagedWidget ("UIAttribViewScrolledW",xmScrolledWindowWidgetClass,mainForm,
								XmNtopAttachment,       XmATTACH_WIDGET,
								XmNtopWidget,           label,
								XmNtopOffset,           5,
								XmNleftAttachment,      XmATTACH_FORM,
								XmNleftOffset,          5,
								XmNrightAttachment,     XmATTACH_FORM,
								XmNrightOffset,         5,
								XmNbottomAttachment,    XmATTACH_FORM,
								XmNbottomOffset,        5,
								XmNheight,              150,
								XmNvisualPolicy,        XmCONSTANT,
								XmNscrollingPolicy,     XmAUTOMATIC,
								NULL);
	rowCol = XtVaCreateManagedWidget ("UIAttribViewRowColumn",xmRowColumnWidgetClass,scrolledW,
								XmNnumColumns,          2,
								XmNorientation,         XmHORIZONTAL,
								XmNrowColumnType,       XmWORK_AREA,
								NULL);
	NamesRowCol = XtVaCreateManagedWidget ("UIAttribViewNamesRowColumn",xmRowColumnWidgetClass,rowCol,
								XmNorientation,         XmVERTICAL,
								XmNrowColumnType,       XmWORK_AREA,
								XmNpacking,             XmPACK_COLUMN,
								XmNspacing,             0,
								NULL);
	FieldsRowCol = XtVaCreateManagedWidget ("UIAttribViewNamesRowColumn",xmRowColumnWidgetClass,rowCol,
								XmNorientation,         XmVERTICAL,
								XmNrowColumnType,       XmWORK_AREA,
								XmNspacing,             0,
								NULL);

	switch (DataPTR->Type ())
		{
		case DBTypeVectorPoint:
		case DBTypeVectorLine:
		case DBTypeVectorPolygon:
		case DBTypeGridDiscrete:
			fields = ItemTable->Fields ();
			for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
				if (DBTableFieldIsVisible (field) == true)	NewField (field->Name (),field->Format ());
			break;
		case DBTypeGridContinuous:
			{
			DBObjRecord *record;
			DBGridIF *gridIF = new DBGridIF (DataPTR);
			ItemTable = DataPTR->Table (DBrNLayers);
			for (record = ItemTable->First ();record != (DBObjRecord *) NULL;record = ItemTable->Next ())
				NewField (record->Name (),gridIF->ValueFormat ());
			delete gridIF;
			} break;
		case DBTypeNetwork:
			{
			DBObjTable *cellTable = DataPTR->Table (DBrNCells);

			NewField ((char *) "Basin Name",(char *) "%s");
			fields = ItemTable->Fields ();
			for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
				if (DBTableFieldIsVisible (field) == true)	NewField (field->Name (),field->Format ());

			fields =  cellTable->Fields ();
			for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
				if (DBTableFieldIsVisible (field) == true)	NewField (field->Name (),field->Format ());
			} break;
		default:	break;
		}
	XtManageChild (mainForm);
	UILoop ();
	}
示例#20
0
文件: dialog.c 项目: epicsdeb/alh
/******************************************************
  Create a fileSelectionBox
******************************************************/
Widget createFileDialog(Widget parent,void *okCallback,XtPointer okParm,
void *cancelCallback,XtPointer cancelParm,XtPointer userParm,
String title,String pattern,String directory)
{
	XmString        Xtitle;
	XmString        Xpattern;
	XmString        Xdirectory;
	XmString        Xcurrentdir=0;
	static Widget   fileselectdialog = 0; /* make it static for reuse */
	static void *oldOk= NULL;
	static void *oldCancel=NULL;
	static XtPointer oldOkParm = 0;
	static XtPointer oldCancelParm = 0;
	static Atom WM_DELETE_WINDOW = 0;
	char file_sel[]="file_sel";

	/* parent = 0 means we want to unmanage the fileSelectdialog */
	if (!parent){
		if (fileselectdialog && XtIsManaged(fileselectdialog))
			XtUnmanageChild(fileselectdialog);
		return(fileselectdialog);
	}

	/* destroy runtimeToplevel fileselectdialog 
	        so we will not have exposure problems */
	if ( parent && fileselectdialog &&
	    XtParent(XtParent(fileselectdialog)) != parent) {
		XtDestroyWidget(fileselectdialog);
		fileselectdialog = 0;
	}

	/* "Open" was selected.  Create a Motif FileSelectionDialog w/callback */
	if (!fileselectdialog) {
		fileselectdialog = XmCreateFileSelectionDialog(parent,
		    file_sel, NULL, 0);
		XtVaSetValues(fileselectdialog,
		    XmNallowShellResize, FALSE,
		    NULL);
		WM_DELETE_WINDOW = XmInternAtom(XtDisplay(fileselectdialog),
		    "WM_DELETE_WINDOW", False);
		XtAddCallback(fileselectdialog,XmNhelpCallback,
		    (XtCallbackProc)helpCallback,(XtPointer)NULL);
	} else {
		XtVaGetValues(fileselectdialog, XmNdirectory, &Xcurrentdir, NULL);
		if (oldOk)     XtRemoveCallback(fileselectdialog,XmNokCallback,
		    (XtCallbackProc)oldOk     ,(XtPointer)oldOkParm);
		if (oldCancel) XtRemoveCallback(fileselectdialog,XmNcancelCallback,
		    (XtCallbackProc)oldCancel ,(XtPointer)oldCancelParm);
		if (oldCancel) XmRemoveWMProtocolCallback(XtParent(fileselectdialog),
		    WM_DELETE_WINDOW,(XtCallbackProc)oldCancel,(XtPointer)oldCancelParm );
	}

	Xtitle=XmStringCreateLtoR(title,XmSTRING_DEFAULT_CHARSET);
	Xpattern=XmStringCreateLtoR(pattern,XmSTRING_DEFAULT_CHARSET);
	if ( !directory  && Xcurrentdir ) Xdirectory = Xcurrentdir;
	else Xdirectory = XmStringCreateLtoR(directory,XmSTRING_DEFAULT_CHARSET);

	XtVaSetValues(fileselectdialog,
	    XmNuserData,      userParm,
	    XmNdialogTitle,   Xtitle,
	    XmNdirectory,     Xdirectory,
	    XmNpattern,       Xpattern,
	    (XtPointer)NULL);

	XmStringFree(Xtitle);
	XmStringFree(Xpattern);
	XmStringFree(Xdirectory);

	XtAddCallback(fileselectdialog,XmNokCallback,
	    (XtCallbackProc)okCallback, (XtPointer)okParm);
	XtAddCallback(fileselectdialog,XmNcancelCallback,
	    (XtCallbackProc)cancelCallback,(XtPointer)cancelParm);
	XmAddWMProtocolCallback(XtParent(fileselectdialog),WM_DELETE_WINDOW,
	    (XtCallbackProc)cancelCallback,(XtPointer)cancelParm );

	oldOk = okCallback;
	oldCancel = cancelCallback;
	oldOkParm = okParm;
	oldCancelParm = cancelParm;

	XtManageChild(fileselectdialog);
	XFlush(display);
	/*
	     XtPopup(XtParent(fileselectdialog), XtGrabNone);
	*/
	return(fileselectdialog);
}
示例#21
0
static int motFileDlgPopup(Ihandle* ih, int x, int y)
{
  InativeHandle* parent = iupDialogGetNativeParent(ih);
  Widget filebox, dialog;
  int dialogtype, style = XmDIALOG_FULL_APPLICATION_MODAL;
  IFnss file_cb = NULL;
  Widget preview_canvas = NULL;
  char* value;

  iupAttribSetInt(ih, "_IUPDLG_X", x);   /* used in iupDialogUpdatePosition */
  iupAttribSetInt(ih, "_IUPDLG_Y", y);

  value = iupAttribGetStr(ih, "DIALOGTYPE");
  if (iupStrEqualNoCase(value, "SAVE"))
    dialogtype = IUP_DIALOGSAVE;
  else if (iupStrEqualNoCase(value, "DIR"))
    dialogtype = IUP_DIALOGDIR;
  else
    dialogtype = IUP_DIALOGOPEN;
  iupAttribSetInt(ih, "_IUPDLG_DIALOGTYPE", dialogtype);

  if (parent)
  {
    filebox = XmCreateFileSelectionDialog(parent, "filedialog", NULL, 0);
    dialog = XtParent(filebox);
  }
  else
  {
    dialog = XtAppCreateShell(NULL, "filedialog", topLevelShellWidgetClass, iupmot_display, NULL, 0);
    filebox = XmCreateFileSelectionBox(dialog, "filebox", NULL, 0);
    style = XmDIALOG_MODELESS;
    XtVaSetValues(dialog,
      XmNmwmInputMode, MWM_INPUT_FULL_APPLICATION_MODAL,
      XmNmappedWhenManaged, False,
      XmNsaveUnder, True,
      NULL);
  }
  if (!filebox)
    return IUP_NOERROR;

  if (!iupAttribGetBoolean(ih, "SHOWHIDDEN"))
    XtVaSetValues(filebox, XmNfileFilterStyle, XmFILTER_HIDDEN_FILES, NULL);

  value = iupAttribGet(ih, "TITLE");
  if (!value)
  {
    if (dialogtype == IUP_DIALOGSAVE)
      value = "IUP_SAVEAS";
    else if (dialogtype == IUP_DIALOGOPEN)
      value = "IUP_OPEN";
    else
      value = "IUP_SELECTDIR";
    iupAttribSetStr(ih, "TITLE", iupStrMessageGet(value));
  }
  iupmotSetString(filebox, XmNdialogTitle, value);

  XtVaSetValues(filebox,
                XmNdialogStyle, style,
                XmNautoUnmanage, False,
                XmNresizePolicy, XmRESIZE_GROW,
                NULL);

  if (dialogtype == IUP_DIALOGDIR)
    XtVaSetValues(filebox, XmNfileTypeMask, XmFILE_DIRECTORY, NULL);

  /* just check for the path inside FILE */
  value = iupAttribGet(ih, "FILE");
  if (value && value[0] == '/')
  {
    char* dir = iupStrFileGetPath(value);
    iupAttribStoreStr(ih, "DIRECTORY", dir);
    free(dir);
  }

  /* set XmNdirectory before XmNpattern and before XmNdirSpec */

  value = iupAttribGet(ih, "DIRECTORY");
  if (value)
    iupmotSetString(filebox, XmNdirectory, value);

  value = iupAttribGet(ih, "FILTER");
  if (value)
  {
    char *filter = value;
    char *p = strchr(value, ';');
    if (p) 
    {
      /* Use only the first filter */
      int size = p-value;
      filter = (char*)malloc(size+1);
      memcpy(filter, value, size);
      filter[size] = 0;
    }

    iupmotSetString(filebox, XmNpattern, filter);

    if (filter != value) 
      free(filter);
  }

  value = iupAttribGet(ih, "FILE");
  if (value)
  {
    char* file = value;

    if (value[0] != '/')  /* if does not contains a full path, then add the directory */
    {
      char* cur_dir = NULL;
      char* dir = iupAttribGet(ih, "DIRECTORY");
      if (!dir)
      {
        cur_dir = iupdrvGetCurrentDirectory();
        dir = cur_dir;
      }

      file = iupStrFileMakeFileName(dir, value);

      if (cur_dir)
        free(cur_dir);
    }

  /* clear value before setting. Do not know why we have to do this, 
     but if not cleared it will fail to set the XmNdirSpec value. */
    iupmotSetString(filebox, XmNdirSpec, "");
    iupmotSetString(filebox, XmNdirSpec, file);

    if (file != value)
      free(file);
  }

  if (!IupGetCallback(ih, "HELP_CB"))
    XtUnmanageChild(XmFileSelectionBoxGetChild(filebox, XmDIALOG_HELP_BUTTON));

  XtAddCallback(filebox, XmNokCallback, (XtCallbackProc)motFileDlgCallback, (XtPointer)ih);
  XtAddCallback(filebox, XmNcancelCallback, (XtCallbackProc)motFileDlgCallback, (XtPointer)ih);
  XtAddCallback(filebox, XmNhelpCallback, (XtCallbackProc)motFileDlgHelpCallback, (XtPointer)ih);

  if (dialogtype == IUP_DIALOGDIR)
  {
    Widget new_folder = XtVaCreateManagedWidget("new_folder", xmPushButtonWidgetClass, filebox, 
                                                XmNlabelType, XmSTRING, 
                                                NULL);
    iupmotSetString(new_folder, XmNlabelString, iupStrMessageGet("IUP_CREATEFOLDER"));
    XtAddCallback(new_folder, XmNactivateCallback, (XtCallbackProc)motFileDlgNewFolderCallback, (XtPointer)filebox);
  }
  else
  {
    file_cb = (IFnss)IupGetCallback(ih, "FILE_CB");
    if (file_cb)
    {
      Widget list = XmFileSelectionBoxGetChild(filebox, XmDIALOG_LIST);
      XtAddCallback(list, XmNbrowseSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);
      list = XmFileSelectionBoxGetChild(filebox, XmDIALOG_DIR_LIST);
      XtAddCallback(list, XmNbrowseSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);

      if (iupAttribGetBoolean(ih, "SHOWPREVIEW"))
      {
        Widget frame = XtVaCreateManagedWidget("preview_canvas", xmFrameWidgetClass, filebox, 
                                                        XmNshadowType, XmSHADOW_ETCHED_IN,
                                                        NULL);

        preview_canvas = XtVaCreateManagedWidget("preview_canvas", xmDrawingAreaWidgetClass, frame, 
                                                        XmNwidth, 180, 
                                                        XmNheight, 150,
                                                        XmNresizePolicy, XmRESIZE_GROW,
                                                        NULL);

        XtAddCallback(preview_canvas, XmNexposeCallback, (XtCallbackProc)motFileDlgPreviewCanvasExposeCallback, (XtPointer)ih);
        XtAddCallback(preview_canvas, XmNresizeCallback, (XtCallbackProc)motFileDlgPreviewCanvasResizeCallback,  (XtPointer)ih);

        iupAttribSetStr(ih, "_IUPDLG_FILEBOX", (char*)filebox);
      }
    }

    if (iupAttribGetBoolean(ih, "MULTIPLEFILES"))
    {
      Widget wList = XmFileSelectionBoxGetChild(filebox, XmDIALOG_LIST);
      XtVaSetValues(wList, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);

      if (file_cb)
        XtAddCallback(wList, XmNextendedSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);
    }
  }

  XmAddWMProtocolCallback(dialog, iupmot_wm_deletewindow, motFileDlgCBclose, (XtPointer)ih);
  XtManageChild(filebox);

  XtRealizeWidget(dialog);
  ih->handle = dialog;
  iupDialogUpdatePosition(ih);
  ih->handle = NULL;  /* reset handle */

  if (file_cb)
  {
    if (preview_canvas)
      motFileDlgPreviewCanvasInit(ih, preview_canvas);

    file_cb(ih, NULL, "INIT");
  }

  if (ih->userwidth && ih->userheight)
  {
    XtVaSetValues(dialog,
      XmNwidth, (XtArgVal)(ih->userwidth),
      XmNheight, (XtArgVal)(ih->userheight),
      NULL);
  }

  if (style == XmDIALOG_MODELESS)
    XtPopup(dialog, XtGrabExclusive);

  /* while the user hasn't provided an answer, simulate main loop.
  ** The answer changes as soon as the user selects one of the
  ** buttons and the callback routine changes its value. */
  iupAttribSetStr(ih, "STATUS", NULL);
  while (iupAttribGet(ih, "STATUS") == NULL)
    XtAppProcessEvent(iupmot_appcontext, XtIMAll);

  if (file_cb)
  {
    if (preview_canvas)
      XFreeGC(iupmot_display, (GC)iupAttribGet(ih, "PREVIEWDC"));

    file_cb(ih, NULL, "FINISH");
  }

  if (!iupAttribGet(ih, "_IUP_WM_DELETE"))
  {
    XtUnmanageChild(filebox);

    if (style == XmDIALOG_MODELESS)
    {
      XtPopdown(dialog);
      XtDestroyWidget(dialog);
    }
  }

  return IUP_NOERROR;
}
示例#22
0
/******************************************************
  audioSetupCreateDialog
******************************************************/
static void audioSetupCreateDialog(Widget menuButton)
{
    Widget audioSetupDialogShell;
    Widget form,form1;
    Widget filename;
    Widget scale;
    Widget button;
    Widget toggleButton;
    Widget frame, rowcol;
    Widget label;
    Pixel textBackground;
    XmString string;
    static ActionAreaItem audioSetup_items[] = {
         { "Dismiss", audioSetupDismissCallback, NULL} };
    ALINK      *area;

    if (!audioSetup.paudioInfo) initAudioSetup();

    textBackground = bg_pixel[3];

    XtVaGetValues(menuButton, XmNuserData, &area, NULL);

    if (audioSetup.audioSetupDialog){
        if (XtIsManaged(audioSetup.audioSetupDialog)) return;
        else XtManageChild(audioSetup.audioSetupDialog);
    }

    audioSetupDialogShell = XtVaCreatePopupShell("ALH Audio Setup",
        transientShellWidgetClass, area->toplevel, NULL, 0);

    /* Modify the window manager menu "close" callback */
    {
        Atom         WM_DELETE_WINDOW;
        XtVaSetValues(audioSetupDialogShell,
            XmNdeleteResponse, XmDO_NOTHING, NULL);
        WM_DELETE_WINDOW = XmInternAtom(XtDisplay(audioSetupDialogShell),
            "WM_DELETE_WINDOW", False);
        XmAddWMProtocolCallback(audioSetupDialogShell,WM_DELETE_WINDOW,
            (XtCallbackProc)audioSetupDismissCallback, (XtPointer)menuButton);
    }

    form = XtVaCreateWidget("audioSetupDialog",
        xmFormWidgetClass, audioSetupDialogShell,
        NULL);
    audioSetup.audioSetupDialog = form;

    string = XmStringCreateSimple("Audio Beep Output Port");
    label = XtVaCreateManagedWidget("audioOutputLabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_FORM,
        XmNtopWidget,              form,
        NULL);
    XmStringFree(string);

    frame = XtVaCreateWidget("frame",
        xmFrameWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    rowcol = XtVaCreateWidget("rowcol",
        xmRowColumnWidgetClass, frame,
        XmNspacing,         0,
        XmNmarginWidth,     10,
        XmNmarginHeight,    10,
        XmNradioBehavior,    TRUE,
        XmNbackground,      textBackground,
        NULL);

    toggleButton = XtVaCreateManagedWidget("None (Use keyboard speaker)",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.port==AUDIO_NONE)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_NONE);

    toggleButton = XtVaCreateManagedWidget("Internal speaker",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.port==AUDIO_SPEAKER)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_SPEAKER);

    toggleButton = XtVaCreateManagedWidget("Headphone",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.port==AUDIO_HEADPHONE)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_HEADPHONE);

    toggleButton = XtVaCreateManagedWidget("Line out",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.port==AUDIO_LINE_OUT)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_LINE_OUT);

    XtManageChild(rowcol);
    XtManageChild(frame);

    string = XmStringCreateSimple("Audio Source");
    label = XtVaCreateManagedWidget("audioAudioSourceLabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        NULL);
    XmStringFree(string);

    frame = XtVaCreateWidget("frame",
        xmFrameWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    audioSetup.audioSourceFrameWidget = frame;
    if (audioSetup.port==AUDIO_NONE) XtSetSensitive(frame, FALSE);
    else XtSetSensitive(frame, TRUE);

    rowcol = XtVaCreateWidget("rowcol",
        xmRowColumnWidgetClass, frame,
        XmNspacing,          0,
        XmNmarginWidth,      10,
        XmNmarginHeight,     10,
        XmNradioBehavior,    TRUE,
        XmNbackground,     textBackground,
        NULL);

    toggleButton = XtVaCreateManagedWidget("alh internal Hi pitch beep",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        /*1XmNalignment,XmALIGNMENT_CENTER*/
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.audioSource==AUDIO_SOURCE_HI)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupAudioSourceChangeCallback, (XtPointer)AUDIO_SOURCE_HI);

    toggleButton = XtVaCreateManagedWidget("alh internal Lo pitch beep",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.audioSource==AUDIO_SOURCE_LO)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupAudioSourceChangeCallback, (XtPointer)AUDIO_SOURCE_LO);

    toggleButton = XtVaCreateManagedWidget("Au/u-law (.au) file",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.audioSource==AUDIO_SOURCE_FILE)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupAudioSourceChangeCallback, (XtPointer)AUDIO_SOURCE_FILE);

    XtManageChild(rowcol);
    XtManageChild(frame);

    string = XmStringCreateSimple("Au/u-law (.au) filename");
    label = XtVaCreateManagedWidget("audioFilenamelabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        NULL);
    XmStringFree(string);

    button = XtVaCreateManagedWidget("Browse",
        xmPushButtonWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        XmNleftAttachment,         XmATTACH_WIDGET,
        XmNleftWidget,             label,
        XmNrightAttachment,        XmATTACH_FORM,
        XmNshadowThickness,        1,
        NULL);

    filename = XtVaCreateManagedWidget("filename",
        xmTextFieldWidgetClass, form,
        XmNbackground,      textBackground,
        XmNtopAttachment,   XmATTACH_WIDGET,
        XmNtopWidget,       button,
        XmNleftAttachment,  XmATTACH_FORM,
        XmNrightAttachment, XmATTACH_FORM,
        NULL);

    XtAddCallback(button, XmNactivateCallback,
        audioSetupFilenameBrowseCallback, filename);

    XmTextFieldSetString(filename,audioSetup.paudioInfo->filename);

    XtAddCallback(filename, XmNactivateCallback,
        audioSetupFilenameChangeCallback, NULL);

    string = XmStringCreateSimple("Audio Beep Volume");
    label = XtVaCreateManagedWidget("audioVolumelabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              filename,
        NULL);
    XmStringFree(string);

    frame = XtVaCreateWidget("frame",
        xmFrameWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    scale = XtVaCreateManagedWidget("VolumeScale",
        xmScaleWidgetClass, frame,
        XmNmaximum,          AUDIO_MAX_GAIN,
        XmNminimum,          AUDIO_MIN_GAIN,
        XmNvalue,            audioSetup.volume,
        XmNshowValue,        True,
        XmNorientation,      XmHORIZONTAL,
        XmNbackground,      textBackground,
        NULL);
    XtAddCallback(scale, XmNvalueChangedCallback,
        audioSetupVolumeChangeCallback, NULL);

    XtManageChild(frame);

    string = XmStringCreateSimple("Test Beep");
    label = XtVaCreateManagedWidget("audioTestlabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        XmNleftAttachment,         XmATTACH_FORM,
        NULL);
    XmStringFree(string);

    button = XtVaCreateManagedWidget("Beep",
        xmPushButtonWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        XmNshadowThickness,        2,
        NULL);
    XtAddCallback(button, XmNactivateCallback,
        audioSetupTestBeepCallback, NULL);

    /* Set the client data "Dismiss" button's callbacks. */
    audioSetup_items[0].data = (XtPointer)menuButton;

    form1 = createActionButtons(form, audioSetup_items,
        XtNumber(audioSetup_items));
    if (form1) XtVaSetValues(form1,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              button,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    XtManageChild(form);
    XtRealizeWidget(audioSetupDialogShell);
}
示例#23
0
文件: xgps.c 项目: gnehzuil/GeoSVR
static void
build_gui(Widget toplevel)
{
	Widget main_w, menubar, widget, sat_frame, sky_frame, gps_frame;
	Widget gps_form, gps_data, sw;

	Arg args[100];
	XGCValues gcv;
	Atom delw;
	int i;
	XmString string;
	XmString file, help, about, quit;

	/*@ -immediatetrans -usedef @*/
	/* the root application window */
	XtSetArg(args[0], XmNwidth, LEFTSIDE_WIDTH + SATDIAG_SIZE + 26);
	XtSetArg(args[1], XmNheight, SATDATA_HEIGHT + 14 * MAX_FONTSIZE + 12);
	/*@ +immediatetrans +usedef @*/
	XtSetValues(toplevel, args, 2);

	/*@ -onlytrans @*/
	main_w = XtVaCreateManagedWidget("main_window",
	    xmMainWindowWidgetClass,	toplevel,
	    NULL);

	/* Construct the menubar */
	file = XmStringCreateLocalized("File");
	help = XmStringCreateLocalized("Help");
	menubar = XmVaCreateSimpleMenuBar(main_w, "menubar",
	    XmVaCASCADEBUTTON,	file,	'F',
	    XmVaCASCADEBUTTON,	help,	'H',
	    NULL);
	XmStringFree(file);

	if ((widget = XtNameToWidget(menubar, "button_1")))
		XtVaSetValues(menubar, XmNmenuHelpWidget, widget, NULL);

	quit = XmStringCreateLocalized("Quit");
	(void)XmVaCreateSimplePulldownMenu(menubar, "file_menu", 0, file_cb,
	    XmVaPUSHBUTTON, quit, 'Q', NULL, NULL,
	    NULL);
	XmStringFree(quit);

	about = XmStringCreateLocalized("About");
	(void)XmVaCreateSimplePulldownMenu(menubar, "help_menu", 1, help_cb,
	    XmVaPUSHBUTTON, help,  'H', NULL, NULL,
	    XmVaSEPARATOR,
	    XmVaPUSHBUTTON, about, 'A', NULL, NULL,
	    NULL);
	XmStringFree(help);
	XmStringFree(about);

	XtManageChild(menubar);


	/* a form to assist with geometry negotiation */
	form = XtVaCreateManagedWidget("form",
	    xmFormWidgetClass,		main_w,
	    XmNfractionBase,		3,
	    NULL);

	/* satellite frame */
	sat_frame = XtVaCreateWidget("satellite_frame",
	    xmFrameWidgetClass,		form,
	    XmNshadowType,		XmSHADOW_ETCHED_IN,
	    XmNtopAttachment,		XmATTACH_FORM,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		1,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		2,
	    XmNleftAttachment,		XmATTACH_FORM,
	    NULL);
	(void)XtVaCreateManagedWidget("Satellite List",
	    xmLabelGadgetClass,		sat_frame,
	    XmNchildType,		XmFRAME_TITLE_CHILD,
	    XmNchildVerticalAlignment,	XmALIGNMENT_CENTER,
	    NULL);

	/* the left half of the screen */
	left = XtVaCreateManagedWidget("left",
	    xmFormWidgetClass, 	sat_frame,
	    NULL);

	/* skyview frame */
	sky_frame = XtVaCreateWidget("skyview_frame",
	    xmFrameWidgetClass,		form,
	    XmNshadowType,		XmSHADOW_ETCHED_IN,
	    XmNtopAttachment,		XmATTACH_FORM,
	    XmNrightAttachment,		XmATTACH_FORM,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		2,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		1,
	    NULL);
	(void)XtVaCreateManagedWidget("Skyview",
	    xmLabelGadgetClass,		sky_frame,
	    XmNchildType,		XmFRAME_TITLE_CHILD,
	    XmNchildVerticalAlignment,	XmALIGNMENT_CENTER,
	    NULL);

	/* the right half of the screen */
	right = XtVaCreateManagedWidget("right",
	    xmFormWidgetClass, 		sky_frame,
	    NULL);

	/* the application status bar */
	status_form = XtVaCreateManagedWidget("status_form",
	    xmFormWidgetClass,		form,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		2,
	    XmNleftAttachment,		XmATTACH_FORM,
	    XmNrightAttachment,		XmATTACH_FORM,
	    XmNtopAttachment,           XmATTACH_WIDGET,
	    XmNtopWidget,               left,
	    XmNfractionBase,		3,
	    NULL);
	status_frame = XtVaCreateWidget("status_frame",
	    xmFrameWidgetClass,		status_form,
	    XmNshadowType,		XmSHADOW_ETCHED_IN,
	    XmNtopAttachment,		XmATTACH_FORM,
	    XmNleftAttachment,		XmATTACH_FORM,
	    XmNrightAttachment,		XmATTACH_FORM,
	    XmNbottomAttachment,	XmATTACH_FORM,
	    NULL);
	(void)XtVaCreateManagedWidget("Message Data",
	    xmLabelGadgetClass,		status_frame,
	    XmNchildType,		XmFRAME_TITLE_CHILD,
	    XmNchildVerticalAlignment,	XmALIGNMENT_CENTER,
	    NULL);
	status = XtVaCreateManagedWidget("status", 
					 xmTextFieldWidgetClass, status_form,
					 XmNcursorPositionVisible, False,
					 XmNeditable, False,
					 XmNmarginHeight, 1,
					 XmNhighlightThickness, 0,
					 XmNshadowThickness, 2,
					 XmNleftAttachment, XmATTACH_FORM,
					 XmNrightAttachment, XmATTACH_FORM,
					 XmNtopAttachment, XmATTACH_FORM,
					 XmNbottomAttachment, XmATTACH_FORM,
					 NULL);

	/* gps information frame */
	gps_form = XtVaCreateManagedWidget("gps_form",
	    xmFormWidgetClass,		form,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		2,
	    XmNleftAttachment,		XmATTACH_FORM,
	    XmNrightAttachment,		XmATTACH_FORM,
	    XmNbottomAttachment,	XmATTACH_FORM,
	    XmNtopAttachment,           XmATTACH_WIDGET,
	    XmNtopWidget,               status_form,
	    XmNfractionBase,		3,
	    NULL);
	gps_frame = XtVaCreateWidget("gps_frame",
	    xmFrameWidgetClass,		gps_form,
	    XmNshadowType,		XmSHADOW_ETCHED_IN,
	    XmNtopAttachment,		XmATTACH_FORM,
	    XmNleftAttachment,		XmATTACH_FORM,
	    XmNrightAttachment,		XmATTACH_FORM,
	    XmNbottomAttachment,	XmATTACH_FORM,
	    NULL);
	(void)XtVaCreateManagedWidget("GPS Data",
	    xmLabelGadgetClass,		gps_frame,
	    XmNchildType,		XmFRAME_TITLE_CHILD,
	    XmNchildVerticalAlignment,	XmALIGNMENT_CENTER,
	    NULL);
	sw = XtVaCreateManagedWidget("scrolled_w",
	    xmScrolledWindowWidgetClass,	gps_frame,
	    XmNscrollingPolicy,			XmAUTOMATIC,
	    NULL);
	gps_data = XtVaCreateWidget("gps_data",
	    xmFormWidgetClass,		sw,
	    XmNfractionBase,		30,
	    NULL);

	/* satellite location and SNR data panel */
	satellite_list = XtVaCreateManagedWidget("satellite_list",
	    xmListWidgetClass,		left,
	    XmNbackground,		get_pixel(toplevel, "snow"),
	    XmNlistSizePolicy,		XmCONSTANT,
	    XmNhighlightThickness,	0,
	    XmNlistSpacing,		4,
	    XmNtopAttachment,		XmATTACH_FORM,
	    XmNrightAttachment,		XmATTACH_FORM,
	    XmNbottomAttachment,	XmATTACH_FORM,
	    XmNleftAttachment,		XmATTACH_FORM,
	    NULL);

	/* the satellite diagram */
	satellite_diagram = XtVaCreateManagedWidget("satellite_diagram",
	    xmDrawingAreaWidgetClass,	right, 
	    XmNbackground,		get_pixel(toplevel, "snow"),
	    XmNheight,			SATDIAG_SIZE + 24,
	    XmNwidth,			SATDIAG_SIZE,
	    XmNtopAttachment,		XmATTACH_FORM,
	    XmNrightAttachment,		XmATTACH_FORM,
	    XmNbottomAttachment,	XmATTACH_FORM,
	    XmNleftAttachment,		XmATTACH_FORM,
	    NULL);

	gcv.foreground = BlackPixelOfScreen(XtScreen(satellite_diagram));
	gc = XCreateGC(XtDisplay(satellite_diagram),
	RootWindowOfScreen(XtScreen(satellite_diagram)), GCForeground, &gcv);
	register_canvas(satellite_diagram, gc);
	XtVaSetValues(satellite_diagram, XmNuserData, gc, NULL);
	/*@i@*/XtAddCallback(satellite_diagram, XmNexposeCallback, redraw, NULL);
	/*@i@*/XtAddCallback(satellite_diagram, XmNresizeCallback, resize, NULL);

	/* the data display */
	(void)XtVaCreateManagedWidget("Time", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		0,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		5,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		6,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		0,
	    NULL);
	(void)XtVaCreateManagedWidget("Latitude", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		6,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		5,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		12,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		0,
	    NULL);
	(void)XtVaCreateManagedWidget("Longitude", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		12,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		5,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		18,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		0,
	    NULL);
	(void)XtVaCreateManagedWidget("Altitude", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		18,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		5,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		24,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		0,
	    NULL);
	(void)XtVaCreateManagedWidget("Speed", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		24,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		5,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		30,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		0,
	    NULL);

	text_1 = XtVaCreateManagedWidget("time",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		0,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		15,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		6,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		5,
	    NULL);
	text_2 = XtVaCreateManagedWidget("latitude",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		6,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		15,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		12,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		5,
	    NULL);
	text_3 = XtVaCreateManagedWidget("longitude",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		12,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		15,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		18,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		5,
	    NULL);
	text_4 = XtVaCreateManagedWidget("altitude",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		18,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		15,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		24,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		5,
	    NULL);
	text_5 = XtVaCreateManagedWidget("speed",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		24,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		15,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		30,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		5,
	    NULL);

	(void)XtVaCreateManagedWidget("EPH", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		0,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		20,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		6,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		15,
	    NULL);
	(void)XtVaCreateManagedWidget("EPV", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		6,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		20,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		12,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		15,
	    NULL);
	(void)XtVaCreateManagedWidget("Climb", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		12,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		20,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		18,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		15,
	    NULL);
	(void)XtVaCreateManagedWidget("Track", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		18,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		20,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		24,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		15,
	    NULL);
	(void)XtVaCreateManagedWidget("Status", xmLabelGadgetClass, gps_data,
	    XmNalignment,		XmALIGNMENT_END,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		24,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		20,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		30,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		15,
	    NULL);

	text_7 = XtVaCreateManagedWidget("eph",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		0,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		30,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		6,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		20,
	    NULL);
	text_8 = XtVaCreateManagedWidget("epv",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		6,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		30,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		12,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		20,
	    NULL);
	text_9 = XtVaCreateManagedWidget("climb",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		12,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		30,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		18,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		20,
	    NULL);
	text_6 = XtVaCreateManagedWidget("track",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		18,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		30,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		24,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		20,
	    NULL);
	text_10 = XtVaCreateManagedWidget("status",
	    xmTextFieldWidgetClass,	gps_data,
	    XmNeditable,		False,
	    XmNcursorPositionVisible,	False,
	    XmNtopAttachment,		XmATTACH_POSITION,
	    XmNtopPosition,		24,
	    XmNrightAttachment,		XmATTACH_POSITION,
	    XmNrightPosition,		30,
	    XmNbottomAttachment,	XmATTACH_POSITION,
	    XmNbottomPosition,		30,
	    XmNleftAttachment,		XmATTACH_POSITION,
	    XmNleftPosition,		20,
	    NULL);

	XtManageChild(gps_data);
	XtManageChild(sat_frame);
	XtManageChild(sky_frame);
	XtManageChild(gps_frame);

	XtVaSetValues(main_w,
	    XmNmenuBar,		menubar,
	    XmNworkWindow,	form,
	    NULL);

	XtRealizeWidget(toplevel);
	delw = XmInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
	    (Boolean)False);
	/*@ -nullpass @*/
	(void)XmAddWMProtocolCallback(toplevel, delw, 
		(XtCallbackProc)quit_cb, NULL);
	/*@ +onlytrans @*/

	/* create empty list items to be replaced on update */
	string = XmStringCreateSimple(" ");
	for (i = 0; i <= MAXCHANNELS; i++)
		XmListAddItem(satellite_list, string, 0);
	XmStringFree(string);
}
示例#24
0
bool wxTopLevelWindowMotif::Create( wxWindow *parent, wxWindowID id,
                                    const wxString& title,
                                    const wxPoint& pos,
                                    const wxSize& size,
                                    long style,
                                    const wxString& name )
{
    SetName(name);
    m_windowStyle = style;

    if ( parent )
        parent->AddChild(this);

    wxTopLevelWindows.Append(this);

    m_windowId = ( id > -1 ) ? id : NewControlId();
    // MBN: More backward compatible, but uglier
    m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    m_inheritFont = true;

    bool retval = XmDoCreateTLW( parent, id, title, pos, size, style, name );

    if( !retval ) return false;

    // Intercept CLOSE messages from the window manager
    Widget shell = (Widget)GetShellWidget();
    Atom WM_DELETE_WINDOW = XmInternAtom( XtDisplay( shell ),
                                          "WM_DELETE_WINDOW", False );

    // Remove and add WM_DELETE_WINDOW so ours is only handler
    // This only appears to be necessary for wxDialog, but does not hurt
    // for wxFrame
    XmRemoveWMProtocols( shell, &WM_DELETE_WINDOW, 1 );
    XmAddWMProtocols( shell, &WM_DELETE_WINDOW, 1 );
    XmActivateWMProtocol( shell, WM_DELETE_WINDOW );

    // Modified Steve Hammes for Motif 2.0
#if (XmREVISION > 1 || XmVERSION > 1)
    XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW,
                             (XtCallbackProc)wxCloseTLWCallback,
                             (XtPointer)this );
#elif XmREVISION == 1
    XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW,
                             (XtCallbackProc)wxCloseTLWCallback,
                             (caddr_t)this );
#else
    XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW,
                             (void (*)())wxCloseTLWCallback, (caddr_t)this );
#endif

    // This patch come from Torsten Liermann [email protected]
    if( XmIsMotifWMRunning( shell ) )
    {
        int decor = 0 ;
        if( !(m_windowStyle & wxNO_BORDER) )
            decor |= MWM_DECOR_BORDER;
        if( m_windowStyle & wxRESIZE_BORDER )
            decor |= MWM_DECOR_RESIZEH;
        if( m_windowStyle & wxSYSTEM_MENU )
            decor |= MWM_DECOR_MENU;
        if( ( m_windowStyle & wxCAPTION ) ||
            ( m_windowStyle & wxTINY_CAPTION_HORIZ ) ||
            ( m_windowStyle & wxTINY_CAPTION_VERT ) )
            decor |= MWM_DECOR_TITLE;
        if( m_windowStyle & wxRESIZE_BORDER )
            decor |= MWM_DECOR_BORDER;
        if( m_windowStyle & wxMINIMIZE_BOX )
            decor |= MWM_DECOR_MINIMIZE;
        if( m_windowStyle & wxMAXIMIZE_BOX )
            decor |= MWM_DECOR_MAXIMIZE;

        XtVaSetValues( shell,
                       XmNmwmDecorations, decor,
                       NULL );
    }
    else
    {
        // This allows non-Motif window managers to support at least the
        // no-decorations case.
        if( ( m_windowStyle & wxCAPTION ) != wxCAPTION )
            XtVaSetValues( shell,
                           XmNoverrideRedirect, True,
                           NULL );
    }

    XtAddEventHandler( (Widget)GetClientWidget(),
                       ButtonPressMask | ButtonReleaseMask |
                       PointerMotionMask | KeyPressMask,
                       False,
                       wxTLWEventHandler,
                       (XtPointer)this );

    return retval;
}
示例#25
0
void view_all_messages( /*@unused@*/ Widget w, /*@unused@*/ XtPointer clientData, /*@unused@*/ XtPointer callData) {
    Widget pane, my_form, button_close, dist, dist_units;
    Widget option_box, tnc_data, net_data, tnc_net_data,
        read_mine_only_button;
    unsigned int n;
#define NCNT 50
#define IncN(n) if (n< NCNT) n++; else fprintf(stderr, "Oops, too many arguments for array!\a")
    Arg args[NCNT];
    Atom delw;
    char temp[10];

    if (!All_messages_dialog) {

begin_critical_section(&All_messages_dialog_lock, "view_message_gui.c:view_all_messages" );

        All_messages_dialog = XtVaCreatePopupShell(langcode("AMTMW00001"),
                xmDialogShellWidgetClass, appshell,
                XmNdeleteResponse, XmDESTROY,
                XmNdefaultPosition, FALSE,
                XmNfontList, fontlist1,
                NULL);

        pane = XtVaCreateWidget("view_all_messages pane",
                xmPanedWindowWidgetClass, 
                All_messages_dialog,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                NULL);

        my_form =  XtVaCreateWidget("view_all_messages my_form",
                xmFormWidgetClass, 
                pane,
                XmNfractionBase, 5,
                XmNautoUnmanage, FALSE,
                XmNshadowThickness, 1,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                NULL);

        dist = XtVaCreateManagedWidget(langcode("AMTMW00002"),
                xmLabelWidgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_FORM,
                XmNtopOffset, 10,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_FORM,
                XmNleftOffset, 10,
                XmNrightAttachment, XmATTACH_NONE,
                XmNtraversalOn, FALSE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        vm_dist_data = XtVaCreateManagedWidget("view_all_messages dist_data", 
                xmTextFieldWidgetClass, 
                my_form,
                XmNeditable,   TRUE,
                XmNcursorPositionVisible, TRUE,
                XmNsensitive, TRUE,
                XmNshadowThickness,    1,
                XmNcolumns, 8,
                XmNwidth, ((8*7)+2),
                XmNmaxLength, 8,
                XmNbackground, colors[0x0f],
                XmNtopAttachment, XmATTACH_FORM,
                XmNtopOffset, 5,
                XmNbottomAttachment,XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_WIDGET,
                XmNleftWidget, dist,
                XmNleftOffset, 10,
                XmNrightAttachment,XmATTACH_NONE,
                XmNfontList, fontlist1,
                NULL);

        dist_units = XtVaCreateManagedWidget((english_units?langcode("UNIOP00004"):langcode("UNIOP00005")),
                xmLabelWidgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_FORM,
                XmNtopOffset, 10,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_WIDGET,
                XmNleftWidget, vm_dist_data,
                XmNleftOffset, 10,
                XmNrightAttachment, XmATTACH_NONE,
                XmNtraversalOn, FALSE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        button_range = XtVaCreateManagedWidget(langcode("BULMW00003"),
                xmPushButtonGadgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_FORM,
                XmNtopOffset, 5,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_WIDGET,
                XmNleftWidget, dist_units,
                XmNleftOffset, 10,
                XmNrightAttachment, XmATTACH_NONE,
                XmNnavigationType, XmTAB_GROUP,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        XtAddCallback(button_range, XmNactivateCallback, All_messages_change_range, All_messages_dialog);

        button_close = XtVaCreateManagedWidget(langcode("UNIOP00003"),
                xmPushButtonGadgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_FORM,
                XmNtopOffset, 5,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_WIDGET,
                XmNleftWidget, button_range,
                XmNleftOffset, 10,
                XmNrightAttachment, XmATTACH_FORM,
                XmNnavigationType, XmTAB_GROUP,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        XtAddCallback(button_close, XmNactivateCallback, All_messages_destroy_shell, All_messages_dialog);

        n=0;
        XtSetArg(args[n],XmNforeground, MY_FG_COLOR); n++;
        XtSetArg(args[n],XmNbackground, MY_BG_COLOR); n++;
        XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
        XtSetArg(args[n], XmNtopWidget, dist); n++;
        XtSetArg(args[n], XmNtopOffset, 5); n++;
        XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
        XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
        XtSetArg(args[n], XmNleftOffset, 5); n++;
        XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
        XtSetArg(args[n], XmNfontList, fontlist1); n++;

        option_box = XmCreateRadioBox(my_form,
                "Vew Messages option box",
                args,
                n);

        XtVaSetValues(option_box,
                XmNpacking, XmPACK_TIGHT,
                XmNorientation, XmHORIZONTAL,
                NULL);

        tnc_data = XtVaCreateManagedWidget(langcode("WPUPDPD002"),
                xmToggleButtonGadgetClass,
                option_box,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        XtAddCallback(tnc_data,XmNvalueChangedCallback,Read_messages_packet_toggle,"1");

        net_data = XtVaCreateManagedWidget(langcode("WPUPDPD003"),
                xmToggleButtonGadgetClass,
                option_box,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        XtAddCallback(net_data,XmNvalueChangedCallback,Read_messages_packet_toggle,"2");

        tnc_net_data = XtVaCreateManagedWidget(langcode("WPUPDPD004"),
                xmToggleButtonGadgetClass,
                option_box,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        XtAddCallback(tnc_net_data,XmNvalueChangedCallback,Read_messages_packet_toggle,"0");

        read_mine_only_button = XtVaCreateManagedWidget(langcode("WPUPDPD008"),
                xmToggleButtonGadgetClass,
                my_form,
                XmNvisibleWhenOff, TRUE,
                XmNindicatorSize, 12,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, dist,
                XmNtopOffset, 10,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_WIDGET,
                XmNleftWidget, option_box,
                XmNleftOffset, 20,
                XmNrightAttachment, XmATTACH_NONE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);
 
        XtAddCallback(read_mine_only_button,XmNvalueChangedCallback,Read_messages_mine_only_toggle,"1");

        n=0;
        XtSetArg(args[n], XmNrows, 15); IncN(n);
        XtSetArg(args[n], XmNcolumns, 85); IncN(n);
        XtSetArg(args[n], XmNeditable, FALSE); IncN(n);
        XtSetArg(args[n], XmNtraversalOn, TRUE); IncN(n);
        XtSetArg(args[n], XmNlistSizePolicy, XmVARIABLE); IncN(n);
        XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); IncN(n);
        XtSetArg(args[n], XmNwordWrap, TRUE); IncN(n);
        XtSetArg(args[n], XmNscrollHorizontal, TRUE); IncN(n);
        XtSetArg(args[n], XmNscrollVertical, TRUE); IncN(n);
//        XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); IncN(n);
        XtSetArg(args[n], XmNselectionPolicy, XmMULTIPLE_SELECT); IncN(n);
        XtSetArg(args[n], XmNcursorPositionVisible, FALSE); IncN(n);
        XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); IncN(n);
        XtSetArg(args[n], XmNtopWidget, option_box); IncN(n);
        XtSetArg(args[n], XmNtopOffset, 5); IncN(n);
        XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); IncN(n);
        XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); IncN(n);
        XtSetArg(args[n], XmNleftOffset, 5); IncN(n);
        XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); IncN(n);
        XtSetArg(args[n], XmNrightOffset, 5); IncN(n);
        XtSetArg(args[n], XmNforeground, MY_FG_COLOR); IncN(n);
        XtSetArg(args[n], XmNbackground, MY_BG_COLOR); IncN(n);
        XtSetArg(args[n], XmNfontList, fontlist1); n++;
 
        view_messages_text = XmCreateScrolledText(my_form,
                "view_all_messages text",
                args,
                n);

// It's hard to get tab groups working with ScrolledText widgets.  Tab'ing in is
// fine, but then I'm stuck in insert mode and it absorbs the tabs and beeps.

        pos_dialog(All_messages_dialog);

        delw = XmInternAtom(XtDisplay(All_messages_dialog),"WM_DELETE_WINDOW", FALSE);
        XmAddWMProtocolCallback(All_messages_dialog, delw, All_messages_destroy_shell, (XtPointer)All_messages_dialog);

        sprintf(temp,"%d",vm_range);
        XmTextFieldSetString(vm_dist_data,temp);

        switch (Read_messages_packet_data_type) {
            case(0):
                XmToggleButtonSetState(tnc_net_data,TRUE,FALSE);
                break;

            case(1):
                XmToggleButtonSetState(tnc_data,TRUE,FALSE);
                break;

            case(2):
                XmToggleButtonSetState(net_data,TRUE,FALSE);
                break;

            default:
                XmToggleButtonSetState(tnc_net_data,TRUE,FALSE);
                break;
        }

        if (Read_messages_mine_only) {
            XmToggleButtonSetState(read_mine_only_button,TRUE,FALSE);
            XtSetSensitive(vm_dist_data, FALSE);
        }
        else {
            XmToggleButtonSetState(read_mine_only_button,FALSE,FALSE);
            XtSetSensitive(vm_dist_data, TRUE);
        }

        XtManageChild(option_box);
        XtManageChild(view_messages_text);
        XtVaSetValues(view_messages_text, XmNbackground, colors[0x0f], NULL);
        XtManageChild(my_form);
        XtManageChild(pane);

        redraw_on_new_packet_data=1;

        // Dump all currently active messages to the new window
        view_message_display_file('M');

end_critical_section(&All_messages_dialog_lock, "view_message_gui.c:view_all_messages" );

        XtPopup(All_messages_dialog,XtGrabNone);
//        fix_dialog_vsize(All_messages_dialog);

        // Move focus to the Close button.  This appears to highlight the
        // button fine, but we're not able to hit the <Enter> key to
        // have that default function happen.  Note:  We _can_ hit the
        // <SPACE> key, and that activates the option.
//        XmUpdateDisplay(All_messages_dialog);
        XmProcessTraversal(button_close, XmTRAVERSE_CURRENT); 


    }
    else {
        (void)XRaiseWindow(XtDisplay(All_messages_dialog), XtWindow(All_messages_dialog));
    }
}
示例#26
0
//
//	Create a new ute window
//
WUtedGtk::WUtedGtk( void	       	*wu_parent_ctx,
		    GtkWidget		*wu_parent_wid,
		    const char	       	*wu_name,
		    const char	       	*wu_iconname,
		    ldh_tWBContext	wu_ldhwb,
		    ldh_tSesContext	wu_ldhses,
		    int	       	wu_editmode,
		    void 	       	(*wu_quit_cb)(void *),
		    pwr_tStatus     	*status) :
  WUted(wu_parent_ctx,wu_name,wu_iconname,wu_ldhwb,wu_ldhses,wu_editmode,wu_quit_cb,
	status), parent_wid(wu_parent_wid), cursor(0)
{
  const int	window_width = 800;
  const int    	window_height = 400;

  memset( &widgets, 0, sizeof(widgets));

  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
			   "default-height", window_height,
			   "default-width", window_width,
			   NULL);

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);

  CoWowGtk::SetWindowIcon( toplevel);

  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File Entry
  GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_quit), this);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // View Entry
  GtkWidget *view_show_cmd = gtk_menu_item_new_with_mnemonic( "_Show Current Command");
  g_signal_connect( view_show_cmd, "activate", 
		    G_CALLBACK(activate_show_cmd), this);

  GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_show_cmd);

  GtkWidget *view = gtk_menu_item_new_with_mnemonic("_View");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

  // Commands entry
  GtkMenu *commands_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  GtkMenu *current_menu = commands_menu;
  
  int j = 0;
  int in_submenu = 0;
  uted_sCommand *next_cmd;
  for ( uted_sCommand *command_ptr = commands; command_ptr->command[0]; command_ptr++) {

    // Build submenu if first command verb is equal to next
    char cmd_verb[5][80];
    int num;
    char next_cmd_verb[5][80];
    int next_num;
    num = dcli_parse( command_ptr->command, " ", "", (char *)cmd_verb, 
		      sizeof( cmd_verb) / sizeof( cmd_verb[0]), sizeof( cmd_verb[0]), 0);

    
    next_cmd = command_ptr + 1;
    int close_submenu = 0;
    if ( next_cmd->command[0]) {
      next_num = dcli_parse( next_cmd->command, " ", "", (char *)next_cmd_verb, 
			     sizeof( next_cmd_verb) / sizeof( next_cmd_verb[0]), 
			     sizeof( next_cmd_verb[0]), 0);

      if ( in_submenu) {
	// Check if time to close menu
	if ( strcmp( cmd_verb[0], next_cmd_verb[0]) != 0) {
	  // Close submenu
	  close_submenu = 1;
	}
      }
      else if ( strcmp( cmd_verb[0], next_cmd_verb[0]) == 0) {
	// Open submenu
	GtkWidget *submenu_item = gtk_menu_item_new_with_label( cmd_verb[0]);
	GtkMenu *submenu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenu_item),
				  GTK_WIDGET(submenu));
	gtk_menu_shell_append(GTK_MENU_SHELL(commands_menu), submenu_item);
	current_menu = submenu;
	in_submenu = 1;
      }
    }
    else if ( in_submenu) {
      // Last command
      close_submenu = 1;
    }


    widgets.optmenubuttons[j] = gtk_menu_item_new();
    widgets.optmenubuttonslabel[j] = gtk_label_new( command_ptr->command);
    gtk_misc_set_alignment( GTK_MISC(widgets.optmenubuttonslabel[j]), 0.0, 0.5);
    gtk_container_add( GTK_CONTAINER(widgets.optmenubuttons[j]), 
		       widgets.optmenubuttonslabel[j]);
    
    g_signal_connect( widgets.optmenubuttons[j], "activate", 
		      G_CALLBACK(activate_command), this);
    gtk_menu_shell_append(GTK_MENU_SHELL(current_menu), widgets.optmenubuttons[j]);

    if ( close_submenu) {
      current_menu = commands_menu;
      in_submenu = 0;
    }

    j++;
  }

  GtkWidget *commands = gtk_menu_item_new_with_mnemonic("_Commands");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), commands);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(commands), GTK_WIDGET(commands_menu));

  // Menu Help
  GtkWidget *help_utils = gtk_image_menu_item_new_with_mnemonic("_On Window");
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_utils), 
				 gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_utils, "activate", G_CALLBACK(activate_helputils), this);
  gtk_widget_add_accelerator( help_utils, "activate", accel_g,
			      'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *help_cmd = gtk_menu_item_new_with_mnemonic( "On _Commands");
  g_signal_connect( help_cmd, "activate", 
		    G_CALLBACK(activate_helppwr_plc), this);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_utils);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_cmd);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  // Qualifier labels, entries and checkboxes
  GtkWidget *qual_box_qual = gtk_vbox_new( FALSE, 0);
  GtkWidget *qual_box_value = gtk_vbox_new( FALSE, 0);
  for ( j = 0; j < 10; j++) {
    widgets.qualifier[j] = gtk_label_new( "Qual");
    gtk_widget_set_size_request( widgets.qualifier[j], 120, 20);
    gtk_misc_set_alignment( GTK_MISC(widgets.qualifier[j]), 0.0, 0.5);
    gtk_box_pack_start( GTK_BOX(qual_box_qual), widgets.qualifier[j], FALSE, FALSE, 5);
    GtkWidget *box = gtk_hbox_new( FALSE, 0);
    widgets.value[j] = gtk_entry_new();
    gtk_widget_set_size_request( widgets.value[j], -1, 20);
    gtk_box_pack_start( GTK_BOX(box), widgets.value[j], TRUE, TRUE, 0);
    widgets.present[j] = gtk_check_button_new();
    gtk_widget_set_size_request( widgets.present[j], -1, 20);
    gtk_box_pack_start( GTK_BOX(box), widgets.present[j], FALSE, FALSE, 0);
    gtk_box_pack_start( GTK_BOX(qual_box_value), box, FALSE, FALSE, 5);
  }

  g_signal_connect( widgets.present[0], "toggled", G_CALLBACK(activate_present1), this);
  g_signal_connect( widgets.present[1], "toggled", G_CALLBACK(activate_present2), this);
  g_signal_connect( widgets.present[2], "toggled", G_CALLBACK(activate_present3), this);
  g_signal_connect( widgets.present[3], "toggled", G_CALLBACK(activate_present4), this);
  g_signal_connect( widgets.present[4], "toggled", G_CALLBACK(activate_present5), this);
  g_signal_connect( widgets.present[5], "toggled", G_CALLBACK(activate_present6), this);
  g_signal_connect( widgets.present[6], "toggled", G_CALLBACK(activate_present7), this);
  g_signal_connect( widgets.present[7], "toggled", G_CALLBACK(activate_present8), this);
  g_signal_connect( widgets.present[8], "toggled", G_CALLBACK(activate_present9), this);
  g_signal_connect( widgets.present[9], "toggled", G_CALLBACK(activate_present10), this);

  // Command label
  GtkWidget *cmdlabel = gtk_label_new( "Command");
  widgets.commandlabel = gtk_label_new( "No command selected");
  gtk_misc_set_alignment( GTK_MISC(widgets.commandlabel), 0.0, 0.5);
  gtk_widget_set_size_request( widgets.commandlabel, 140, -1);

  GtkWidget *vbox_command = gtk_hbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox_command), cmdlabel, FALSE, FALSE, 10);
  gtk_box_pack_start( GTK_BOX(vbox_command), widgets.commandlabel, FALSE, FALSE, 10);

  // Apply button
  GtkWidget *applybutton = gtk_button_new_with_label( "Apply");
  gtk_widget_set_size_request( applybutton, 70, 25);
  g_signal_connect( applybutton, "clicked", 
  		    G_CALLBACK(activate_ok), this);

  GtkWidget *left_box = gtk_vbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(left_box), vbox_command, FALSE, FALSE, 10);

  GtkWidget *button_box = gtk_hbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(button_box), applybutton, FALSE, FALSE, 50);

  GtkWidget *qual_box = gtk_hbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(qual_box), left_box, FALSE, FALSE, 10);
  gtk_box_pack_start( GTK_BOX(qual_box), gtk_vseparator_new(), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(qual_box), qual_box_qual, FALSE, FALSE, 10);
  gtk_box_pack_start( GTK_BOX(qual_box), qual_box_value, TRUE, TRUE, 10);


  // Statusbar
  GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
  widgets.label = gtk_label_new( "");
  gtk_box_pack_start( GTK_BOX(statusbar), widgets.label, FALSE, FALSE, 20);


  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), qual_box, TRUE, TRUE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 3);
  gtk_box_pack_start( GTK_BOX(vbox), button_box, FALSE, FALSE, 3);
  gtk_box_pack_start( GTK_BOX(vbox), statusbar, FALSE, FALSE, 3);

  gtk_container_add( GTK_CONTAINER(toplevel), vbox);

  gtk_widget_show_all( toplevel);

  batch_sts = UTED_BATCH_CURRSESS;
  reset_qual();
  enable_entries( wu_editmode);

#if 0
  Arg		args[20];
  pwr_tStatus	sts;
  int i;
  MrmHierarchy	s_MrmH;
  MrmType	dclass;

  /* DRM database hierarchy related variables */
  static Pixmap icon = 0;
  Dimension	icon_w;
  Dimension	icon_h;

  static Atom	MwmDeleteWind = 0;
  char		uid_filename[200] = {"pwr_exe:wb_uted.uid"};
  char		*uid_filename_p = uid_filename;

  static MrmRegisterArg	reglist[] = {
    /* First the context variable */
    { "uted_ctx", 0 },

    /* Callbacks for the controlled foe widget */
    {"uted_create_adb",(caddr_t)create_adb},
    {"uted_create_quit",(caddr_t)create_quit},
    {"uted_activate_quit",(caddr_t)activate_quit},
    {"uted_create_commandlabel",(caddr_t)create_commandlabel},
    {"uted_create_batchoptmenu",(caddr_t)create_batchoptmenu},
    {"uted_create_batch",(caddr_t)create_batch},
    {"uted_create_currsess",(caddr_t)create_currsess},
    {"uted_create_file_entry",(caddr_t)create_file_entry},
    {"uted_create_label",(caddr_t)create_label},
    {"uted_create_adb",(caddr_t)create_adb},
    {"uted_activate_command",(caddr_t)activate_command},
    {"uted_create_command",(caddr_t)create_command},
    {"uted_activate_batch",(caddr_t)activate_batch},
    {"uted_activate_currsess",(caddr_t)activate_currsess},
    {"uted_activate_ok",(caddr_t)activate_ok},
    {"uted_activate_cancel",(caddr_t)activate_cancel},
    {"uted_activate_show_cmd",(caddr_t)activate_show_cmd},
    {"uted_create_commandwind_button",(caddr_t)create_commandwind_button},
    {"uted_activate_cmd_wind",(caddr_t)activate_cmd_wind},
    {"uted_create_cmd_wind",(caddr_t)create_cmd_wind},
    {"uted_create_timelabel",(caddr_t)create_timelabel},
    {"uted_create_timevalue",(caddr_t)create_timevalue},
    {"uted_create_qualifier1",(caddr_t)create_qualifier1},
    {"uted_create_value1",(caddr_t)create_value1},
    {"uted_activate_present1",(caddr_t)activate_present1},
    {"uted_create_present1",(caddr_t)create_present1},
    {"uted_create_qualifier2",(caddr_t)create_qualifier2},
    {"uted_create_value2",(caddr_t)create_value2},
    {"uted_activate_present2",(caddr_t)activate_present2},
    {"uted_create_present2",(caddr_t)create_present2},
    {"uted_create_qualifier3",(caddr_t)create_qualifier3},
    {"uted_create_value3",(caddr_t)create_value3},
    {"uted_activate_present3",(caddr_t)activate_present3},
    {"uted_create_present3",(caddr_t)create_present3},
    {"uted_create_qualifier4",(caddr_t)create_qualifier4},
    {"uted_create_value4",(caddr_t)create_value4},
    {"uted_activate_present4",(caddr_t)activate_present4},
    {"uted_create_present4",(caddr_t)create_present4},
    {"uted_create_qualifier5",(caddr_t)create_qualifier5},
    {"uted_create_value5",(caddr_t)create_value5},
    {"uted_activate_present5",(caddr_t)activate_present5},
    {"uted_create_present5",(caddr_t)create_present5},
    {"uted_create_qualifier6",(caddr_t)create_qualifier6},
    {"uted_create_value6",(caddr_t)create_value6},
    {"uted_activate_present6",(caddr_t)activate_present6},
    {"uted_create_present6",(caddr_t)create_present6},
    {"uted_create_qualifier7",(caddr_t)create_qualifier7},
    {"uted_create_value7",(caddr_t)create_value7},
    {"uted_activate_present7",(caddr_t)activate_present7},
    {"uted_create_present7",(caddr_t)create_present7},
    {"uted_create_qualifier8",(caddr_t)create_qualifier8},
    {"uted_create_value8",(caddr_t)create_value8},
    {"uted_activate_present8",(caddr_t)activate_present8},
    {"uted_create_present8",(caddr_t)create_present8},
    {"uted_create_qualifier9",(caddr_t)create_qualifier9},
    {"uted_create_value9",(caddr_t)create_value9},
    {"uted_activate_present9",(caddr_t)activate_present9},
    {"uted_create_present9",(caddr_t)create_present9},
    {"uted_create_qualifier10",(caddr_t)create_qualifier10},
    {"uted_create_value10",(caddr_t)create_value10},
    {"uted_activate_present10",(caddr_t)activate_present10},
    {"uted_create_present10",(caddr_t)create_present10},
    {"uted_activate_helputils",(caddr_t)activate_helputils},
    {"uted_activate_helppwr_plc",(caddr_t)activate_helppwr_plc},
    {"uted_commandchanged",(caddr_t)commandchanged},
    {"uted_qbox_cr",(caddr_t)qbox_cr},
    {"uted_qbox_yes_cb",(caddr_t)qbox_yes_cb},
    {"uted_qbox_no_cb",(caddr_t)qbox_no_cb},
    {"uted_qbox_cancel_cb",(caddr_t)qbox_cancel_cb}
  };

  static int	reglist_num = (sizeof reglist / sizeof reglist[0]);

  /*
   * Now start the module creation
   */

  sts = dcli_translate_filename( uid_filename, uid_filename);
  if ( EVEN(sts)) {
    printf( "** pwr_exe is not defined\n");
    exit(0);
  }

  /* set initialization values in context */

  /* Save the context structure in the widget */
  XtSetArg (args[0], XmNuserData, (unsigned int) this);

  /*
   * Create a new widget
   * Open the UID files (the output of the UIL compiler) in the hierarchy
   * Register the items DRM needs to bind for us.
   * Create a new widget
   * Close the hierarchy
   * Compile the additional button translations and augment and add actions
   */ 
  sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_MrmH);
  if (sts != MrmSUCCESS) printf("can't open hierarchy\n");

  reglist[0].value = (caddr_t) this;

  MrmRegisterNames(reglist, reglist_num);

  if (icon == 0)
    sts = MrmFetchBitmapLiteral(s_MrmH,"icon", 
	      XtScreen(parent_wid), XtDisplay(parent_wid),
	      &icon, &icon_w, &icon_h);

  i=0;
  XtSetArg(args[i],XmNiconName, wu_iconname);  i++;
  XtSetArg(args[i],XmNiconPixmap, icon);  i++;
  XtSetArg(args[i],XmNtitle, name);  i++;
  
  /* SG 11.02.91 Save the id of the top in the context */ 
  parent_wid = XtCreatePopupShell("utilities", 
			       topLevelShellGtkWidgetClass, parent_wid, args, i);

  /* the positioning of a top level can only be define after the creation
      of the widget . So i do it know: 
     SG 24.02.91 use the parameters received x and y 
  */
  i=0;
  XtSetArg(args[i],XmNx,100);i++;
  XtSetArg(args[i],XmNy,100);i++;
  XtSetArg(args[i],XtNallowShellResize,TRUE), i++;
  XtSetValues( parent_wid, args, i);

  /* now that we have a top level we can get the main window */
  sts = MrmFetchGtkWidgetOverride(s_MrmH, "uted_window", parent_wid ,
		name, args, 1,
		&widgets.uted_window, &dclass);
  if (sts != MrmSUCCESS) printf("can't fetch utedit widget\n");

  XtManageChild( widgets.uted_window);

  /* SG 09.02.91 a top level should always be realized ! */
  XtPopup( parent_wid, XtGrabNone );

  /* Ask MRM to fetch the question box */
  i=0;
  if (MrmFetchGtkWidgetOverride(s_MrmH,
			"uted_qbox", 
	     	        widgets.uted_window,
			0,
			args , i,
			&widgets.questionbox, &dclass) != MrmSUCCESS) {
    printf("can't fetch uted_qbox widget\n");
  }

  MrmCloseHierarchy(s_MrmH);

  reset_qual();

  batch_sts = UTED_BATCH_CURRSESS;
  XtSetArg(args[0],XmNsensitive, 0);
  XtSetValues( widgets.timelabel,args,1);
  XtUnmanageChild( widgets.timevalue);
  XtUnmanageChild( widgets.command_window);
  enable_entries( wu_editmode);


  if (MwmDeleteWind == 0)
     MwmDeleteWind = XInternAtom(XtDisplay(parent_wid), "WM_DELETE_WINDOW", FALSE);

  if (MwmDeleteWind != 0)
  {
    XtVaSetValues( parent_wid, XmNdeleteResponse, XmDO_NOTHING, NULL);
    XmAddWMProtocolCallback( parent_wid, MwmDeleteWind, 
       (XtCallbackProc) activate_quit, this);
  }
#endif
  *status = FOE__SUCCESS;
}
示例#27
0
文件: track_gui.c 项目: dranch/Xastir
void Download_findu_trail( /*@unused@*/ Widget w, /*@unused@*/ XtPointer clientData, /*@unused@*/ XtPointer callData) {
    static Widget pane, my_form, button_ok, button_cancel, call, sep;
    Atom delw;
    XmString x_str;


    if (!download_findu_dialog) {

begin_critical_section(&download_findu_dialog_lock, "track_gui.c:Download_findu_trail" );

        download_findu_dialog = XtVaCreatePopupShell(langcode("WPUPTSP007"),
                xmDialogShellWidgetClass, appshell,
                XmNdeleteResponse,XmDESTROY,
                XmNdefaultPosition, FALSE,
                XmNfontList, fontlist1,
                NULL);

        pane = XtVaCreateWidget("Download_findu_trail pane",
                xmPanedWindowWidgetClass, 
                download_findu_dialog,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                NULL);

        my_form =  XtVaCreateWidget("Download_findu_trail my_form",
                xmFormWidgetClass, 
                pane,
                XmNfractionBase, 2,
                XmNautoUnmanage, FALSE,
                XmNshadowThickness, 1,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                NULL);

        call = XtVaCreateManagedWidget(langcode("WPUPTSP008"),
                xmLabelWidgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_FORM,
                XmNtopOffset, 10,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_FORM,
                XmNleftOffset, 10,
                XmNrightAttachment, XmATTACH_NONE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        download_trail_station_data = XtVaCreateManagedWidget("download_trail_station_data", 
                xmTextFieldWidgetClass, 
                my_form,
                XmNeditable,   TRUE,
                XmNcursorPositionVisible, TRUE,
                XmNsensitive, TRUE,
                XmNshadowThickness,    1,
                XmNcolumns, 15,
                XmNwidth, ((15*7)+2),
                XmNmaxLength, 15,
                XmNbackground, colors[0x0f],
                XmNtopAttachment,XmATTACH_FORM,
                XmNtopOffset, 5,
                XmNbottomAttachment,XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_WIDGET,
                XmNleftWidget, call,
                XmNleftOffset, 10,
                XmNrightAttachment,XmATTACH_NONE,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                XmNfontList, fontlist1,
                NULL);

        x_str = XmStringCreateLocalized(langcode("WPUPTSP009"));
        posit_start_value = XtVaCreateManagedWidget("Start of Trail (hrs ago)", 
                xmScaleWidgetClass, 
                my_form,
                XmNtopAttachment,XmATTACH_WIDGET,
                XmNtopWidget, call,
                XmNtopOffset, 15,
                XmNbottomAttachment,XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_FORM,
                XmNleftOffset, 10,
                XmNrightAttachment,XmATTACH_NONE,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                //XmNwidth, 190,
                XmNrightAttachment, XmATTACH_FORM,
                XmNrightOffset, 10,
                XmNsensitive, TRUE,
                XmNorientation, XmHORIZONTAL,
                XmNborderWidth, 1,
                XmNminimum, 1,
                XmNmaximum, MAX_FINDU_START_TIME,
                XmNshowValue, TRUE,
                XmNvalue, posit_start,
// Note:  Some versions of OpenMotif (distributed with Fedora,
// perhaps others) don't work properly with XtVaTypedArg() as used
// here, instead showing blank labels for the Scale widgets.
//                XtVaTypedArg, XmNtitleString, XmRString, langcode("WPUPTSP009"), 22,
                XmNtitleString, x_str,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);
        XmStringFree(x_str);

        x_str = XmStringCreateLocalized(langcode("WPUPTSP010"));
        posit_length_value = XtVaCreateManagedWidget("Length of trail (hrs)", 
                xmScaleWidgetClass, 
                my_form,
                XmNtopAttachment,XmATTACH_WIDGET,
                XmNtopWidget, posit_start_value,
                XmNtopOffset, 15,
                XmNbottomAttachment,XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_FORM,
                XmNleftOffset, 10,
                XmNrightAttachment,XmATTACH_NONE,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                //XmNwidth, 190,
                XmNrightAttachment, XmATTACH_FORM,
                XmNrightOffset, 10,
                XmNsensitive, TRUE,
                XmNorientation, XmHORIZONTAL,
                XmNborderWidth, 1,
                XmNminimum, 1,
                XmNmaximum, MAX_FINDU_DURATION,
                XmNshowValue, TRUE,
                XmNvalue, posit_length,
// Note:  Some versions of OpenMotif (distributed with Fedora,
// perhaps others) don't work properly with XtVaTypedArg() as used
// here, instead showing blank labels for the Scale widgets.
//                XtVaTypedArg, XmNtitleString, XmRString, langcode("WPUPTSP010"), 19,
                XmNtitleString, x_str,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);
        XmStringFree(x_str);

        sep = XtVaCreateManagedWidget("Download_findu_trail sep", 
                xmSeparatorGadgetClass,
                my_form,
                XmNorientation, XmHORIZONTAL,
                XmNtopAttachment,XmATTACH_WIDGET,
                XmNtopWidget,posit_length_value,
                XmNtopOffset, 10,
                XmNbottomAttachment,XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_FORM,
                XmNrightAttachment,XmATTACH_FORM,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        button_ok = XtVaCreateManagedWidget(langcode("WPUPTSP007"),
                xmPushButtonGadgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, sep,
                XmNtopOffset, 5,
                XmNbottomAttachment, XmATTACH_FORM,
                XmNbottomOffset, 5,
                XmNleftAttachment, XmATTACH_POSITION,
                XmNleftPosition, 0,
                XmNleftOffset, 5,
                XmNrightAttachment, XmATTACH_POSITION,
                XmNrightPosition, 1,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);
        if (fetching_findu_trail_now)
            XtSetSensitive(button_ok, FALSE);

        button_cancel = XtVaCreateManagedWidget(langcode("UNIOP00002"),
                xmPushButtonGadgetClass, 
                my_form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, sep,
                XmNtopOffset, 5,
                XmNbottomAttachment, XmATTACH_FORM,
                XmNbottomOffset, 5,
                XmNleftAttachment, XmATTACH_POSITION,
                XmNleftPosition, 1,
                XmNrightAttachment, XmATTACH_POSITION,
                XmNrightPosition, 2,
                XmNrightOffset, 5,
                XmNnavigationType, XmTAB_GROUP,
                XmNtraversalOn, TRUE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        XtAddCallback(button_ok, XmNactivateCallback, Download_trail_now, download_findu_dialog);
        XtAddCallback(button_cancel, XmNactivateCallback, Download_trail_destroy_shell, download_findu_dialog);
        XtAddCallback(posit_start_value, XmNvalueChangedCallback, Reset_posit_length_max, download_findu_dialog);

        pos_dialog(download_findu_dialog);

        delw = XmInternAtom(XtDisplay(download_findu_dialog),"WM_DELETE_WINDOW", FALSE);
        XmAddWMProtocolCallback(download_findu_dialog, delw, Download_trail_destroy_shell, (XtPointer)download_findu_dialog);

        XmTextFieldSetString(download_trail_station_data,download_trail_station_call);

        XtManageChild(my_form);
        XtManageChild(pane);

end_critical_section(&download_findu_dialog_lock, "track_gui.c:Download_trail" );

        XtPopup(download_findu_dialog,XtGrabNone);
        fix_dialog_size(download_findu_dialog);

        // Move focus to the Cancel button.  This appears to highlight the
        // button fine, but we're not able to hit the <Enter> key to
        // have that default function happen.  Note:  We _can_ hit the
        // <SPACE> key, and that activates the option.
//        XmUpdateDisplay(download_findu_dialog);
        XmProcessTraversal(button_cancel, XmTRAVERSE_CURRENT);

    } else
        (void)XRaiseWindow(XtDisplay(download_findu_dialog), XtWindow(download_findu_dialog));
}
示例#28
0
void createColor()
{
 Widget paletteRC;

 XmString buttons[N_MAX_MENU_ELES];
 KeySym keySyms[N_MAX_MENU_ELES];
 XmButtonType buttonType[N_MAX_MENU_ELES];
 Widget colorMB;
 Widget colorHelpPDM;
 Widget menuHelpWidget;

 Pixel fg, bg;
 int i, n, childCount;
 Arg args[10];


/*
 * create a main window in a dialog, and then the palette radio box
 */
 n = 0;
 XtSetArg(args[n],XtNiconName,"Colors"); n++;
 XtSetArg(args[n],XtNtitle,"Color Palette"); n++;
 XtSetArg(args[n],XtNallowShellResize,TRUE); n++;
 XtSetArg(args[n],XmNkeyboardFocusPolicy,XmEXPLICIT); n++;
/* map window manager menu Close function to application close... */
 XtSetArg(args[n],XmNdeleteResponse,XmDO_NOTHING); n++;
 XtSetArg(args[n],XmNmwmDecorations,MWM_DECOR_ALL|MWM_DECOR_RESIZEH); n++;
 colorS = XtCreatePopupShell("colorS",topLevelShellWidgetClass,
				mainShell,args,n);
 XmAddWMProtocolCallback(colorS,WM_DELETE_WINDOW,
				(XtCallbackProc)wmCloseCallback,
				(XtPointer)OTHER_SHELL);

 colorMW = XmCreateMainWindow(colorS,"colorMW",NULL,0);


/*
 * create the menu bar
 */
  buttons[0] = XmStringCreateSimple("File");
  buttons[1] = XmStringCreateSimple("Help");
#if 0
  keySyms[0] = 'F';
  keySyms[1] = 'H';
  n = 0;
  XtSetArg(args[n],XmNbuttonCount,N_MAIN_MENU_ELES); n++;
  XtSetArg(args[n],XmNbuttons,buttons); n++;
  XtSetArg(args[n],XmNbuttonMnemonics,keySyms); n++;
  XtSetArg(args[n],XmNforeground,defaultForeground); n++;
  XtSetArg(args[n],XmNbackground,defaultBackground); n++;
  colorMB = XmCreateSimpleMenuBar(colorMW, "colorMB",args,n);
#endif

  colorMB = XmVaCreateSimpleMenuBar(colorMW, "colorMB",
    XmVaCASCADEBUTTON, buttons[0], 'F',
    XmVaCASCADEBUTTON, buttons[1], 'H',
    NULL);


/* color colorMB properly (force so VUE doesn't interfere) */
  colorMenuBar(colorMB,defaultForeground,defaultBackground);

  /* set the Help cascade button in the menu bar */
  menuHelpWidget = XtNameToWidget(colorMB,"*button_1");
  XtVaSetValues(colorMB,XmNmenuHelpWidget,menuHelpWidget,
		NULL);
  for (i = 0; i < N_MAIN_MENU_ELES; i++) XmStringFree(buttons[i]);


/*
 * create the file pulldown menu pane
 */
  buttons[0] = XmStringCreateSimple("Close");
  keySyms[0] = 'C';
  buttonType[0] = XmPUSHBUTTON;
  n = 0;
  XtSetArg(args[n],XmNbuttonCount,N_FILE_MENU_ELES); n++;
  XtSetArg(args[n],XmNbuttons,buttons); n++;
  XtSetArg(args[n],XmNbuttonType,buttonType); n++;
  XtSetArg(args[n],XmNbuttonMnemonics,keySyms); n++;
  XtSetArg(args[n],XmNpostFromButton,FILE_BTN_POSN); n++;
  XtSetArg(args[n],XmNsimpleCallback,fileMenuSimpleCallback);
	n++;
  XmCreateSimplePulldownMenu(colorMB,"colorFilePDM",
	args,n);
  for (i = 0; i < N_FILE_MENU_ELES; i++) XmStringFree(buttons[i]);



/*
 * create the help pulldown menu pane
 */
  buttons[0] = XmStringCreateSimple("On Color Palette...");
  keySyms[0] = 'C';
  buttonType[0] = XmPUSHBUTTON;
  n = 0;
  XtSetArg(args[n],XmNbuttonCount,N_HELP_MENU_ELES); n++;
  XtSetArg(args[n],XmNbuttons,buttons); n++;
  XtSetArg(args[n],XmNbuttonType,buttonType); n++;
  XtSetArg(args[n],XmNbuttonMnemonics,keySyms); n++;
  XtSetArg(args[n],XmNpostFromButton,HELP_BTN_POSN); n++;
  colorHelpPDM = XmCreateSimplePulldownMenu(colorMB,
		"colorHelpPDM",args,n);
  XmStringFree(buttons[0]);
  /* (MDA) for now, disable this menu */
  XtSetSensitive(colorHelpPDM,False);



/*
 * Add the Palette Radio Box for the drawing color toggle buttons
 *
 */
 n = 0;
 XtSetArg(args[n],XmNadjustLast,False); n++;
 XtSetArg(args[n],XmNadjustLast,False); n++;
 XtSetArg(args[n],XmNpacking,XmPACK_COLUMN); n++;
 XtSetArg(args[n],XmNorientation,XmVERTICAL); n++;
 XtSetArg(args[n],XmNnumColumns,(short)(DL_MAX_COLORS/DL_COLORS_COLUMN_SIZE)); n++;
 XtSetArg(args[n],XmNspacing,0); n++;
 paletteRC = XmCreateRowColumn(colorMW,"paletteRC",args,n);
 XtVaGetValues(paletteRC,XmNforeground,&fg,XmNbackground,&bg,NULL);


/*
 * create the (maximum number of) color buttons
 */

  n = 0;
  XtSetArg(args[n],XmNlabelType,XmPIXMAP); n++;
  XtSetArg(args[n],XmNrecomputeSize,False); n++;
  for (childCount = 0; childCount < DL_MAX_COLORS; childCount++) {
    /* use values in default colormap if in valid area of colormap */
    globalColorPalettePB[childCount] = XmCreatePushButton(paletteRC,"colorPB",
							  args,n);
    XtAddCallback(globalColorPalettePB[childCount],XmNactivateCallback,
		colorPaletteActivateCallback,
		(XtPointer)childCount);
  }

/* want to keep same shadow colors... but different background */
  for (childCount = 0; childCount < DL_MAX_COLORS; childCount++) {
    XtSetArg(args[0],XmNbackground,(Pixel)defaultColormap[childCount]);
    XtSetValues(globalColorPalettePB[childCount],args,1);
  }

  XmMainWindowSetAreas(colorMW,colorMB,NULL,NULL,NULL,paletteRC);


/*
 * manage the composites
 */
  XtManageChild(colorMB);
  XtManageChildren(globalColorPalettePB,childCount);
  XtManageChild(paletteRC);
  XtManageChild(colorMW);


}
示例#29
0
static void make_edit_find_dialog(bool managed)
{
  if (!edit_find_dialog)
    {
      Widget dl, rc;
      Arg args[20];
      int n;
      XmString xmstr1, xmstr3, titlestr;

      n = 0;
      XtSetArg(args[n], XmNbackground, ss->basic_color); n++;
      xmstr1 = XmStringCreateLocalized((char *)"Go Away");
      xmstr3 = XmStringCreateLocalized((char *)"Previous");
      titlestr = XmStringCreateLocalized((char *)"Find");
      XtSetArg(args[n], XmNokLabelString, xmstr1); n++;
      XtSetArg(args[n], XmNcancelLabelString, xmstr3); n++;
      XtSetArg(args[n], XmNautoUnmanage, false); n++;
      XtSetArg(args[n], XmNdialogTitle, titlestr); n++;
      XtSetArg(args[n], XmNresizePolicy, XmRESIZE_GROW); n++;
      XtSetArg(args[n], XmNnoResize, false); n++;
      XtSetArg(args[n], XmNtransient, false); n++;
      edit_find_dialog = XmCreateMessageDialog(MAIN_SHELL(ss), (char *)"find", args, n);
      
      XmStringFree(xmstr1);
      XmStringFree(xmstr3);
      XmStringFree(titlestr);
      
      XtUnmanageChild(XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_SYMBOL_LABEL));
      XtUnmanageChild(XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_MESSAGE_LABEL));
      
      XtAddCallback(edit_find_dialog, XmNhelpCallback, edit_find_help_callback, NULL);
      XtAddCallback(edit_find_dialog, XmNcancelCallback, edit_find_previous_callback, NULL);
      XtAddCallback(edit_find_dialog, XmNokCallback, edit_find_cancel_callback, NULL);
      
      n = 0;
      XtSetArg(args[n], XmNbackground, ss->highlight_color); n++;
      XtSetArg(args[n], XmNarmColor, ss->selection_color); n++;
      findnextB = XtCreateManagedWidget("Next", xmPushButtonGadgetClass, edit_find_dialog, args, n);
      XtAddCallback(findnextB, XmNactivateCallback, edit_find_next_callback, NULL);
      
      rc = XtCreateManagedWidget("row", xmFormWidgetClass, edit_find_dialog, NULL, 0);
      
      n = 0;
      XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
      XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
      XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
      XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
      dl = XtCreateManagedWidget("find:", xmLabelWidgetClass, rc, args, n);
      
      n = 0;
      XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
      XtSetArg(args[n], XmNleftWidget, dl); n++;
      XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
      XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
      XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
      edit_find_text = make_textfield_widget("text", rc, args, n, ACTIVATABLE, add_completer_func(expression_completer, NULL));
      
      n = 0;
      XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
      XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
      XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
      XtSetArg(args[n], XmNtopWidget, edit_find_text); n++;
      XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
      XtSetArg(args[n], XmNmarginHeight, 10); n++;
      edit_find_label = XtCreateManagedWidget("    ", xmLabelWidgetClass, rc, args, n);
      
      n = 0;
      XtSetArg(args[n], XmNbackground, ss->basic_color); n++;
      XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
      XtSetArg(args[n], XmNtopWidget, edit_find_label); n++;
      XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
      XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
      XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
      XtSetArg(args[n], XmNallowResize, true); n++;
      XtSetArg(args[n], XmNshadowType, XmSHADOW_ETCHED_IN); n++;
      XtSetArg(args[n], XmNshadowThickness, 2); n++;
      find_error_frame = XtCreateManagedWidget("find-error-frame", xmFrameWidgetClass, rc, args, n);

      n = 0;
      XtSetArg(args[n], XmNbackground, ss->highlight_color); n++;
      find_error_label = XtCreateManagedWidget("", xmLabelWidgetClass, find_error_frame, args, n);
      
      map_over_children(edit_find_dialog, set_main_color_of_widget);
      XtVaSetValues(XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_OK_BUTTON), XmNarmColor, ss->selection_color, NULL);
      XtVaSetValues(XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_CANCEL_BUTTON), XmNarmColor, ss->selection_color, NULL);
      XtVaSetValues(XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_HELP_BUTTON), XmNarmColor, ss->selection_color, NULL);
      XtVaSetValues(XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_OK_BUTTON), XmNbackground, ss->highlight_color, NULL);
      XtVaSetValues(XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_CANCEL_BUTTON), XmNbackground, ss->highlight_color, NULL);
      XtVaSetValues(XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_HELP_BUTTON), XmNbackground, ss->highlight_color, NULL);

      cancelB = XmMessageBoxGetChild(edit_find_dialog, XmDIALOG_OK_BUTTON);
      set_dialog_widget(FIND_DIALOG, edit_find_dialog);

      XtUnmanageChild(find_error_frame);

      if (managed) XtManageChild(edit_find_dialog);

      {
	Atom wm_delete_window;
	wm_delete_window = XmInternAtom(MAIN_DISPLAY(ss), (char *)"WM_DELETE_WINDOW", false);
	XmAddWMProtocolCallback(XtParent(edit_find_dialog), wm_delete_window, find_dialog_close, NULL);
      }
    }
  else
    {
      if (managed)
	{
	  if (!XtIsManaged(edit_find_dialog)) XtManageChild(edit_find_dialog);
	  raise_dialog(edit_find_dialog);
	}
    }
}
示例#30
0
void Jump_location(/*@unused@*/ Widget w, /*@unused@*/ XtPointer clientData, /*@unused@*/ XtPointer callData) {
    static Widget  pane,form, button_ok, button_add, button_delete, button_cancel, locdata, location_name;
    int n;
    Arg al[50];           /* Arg List */
    unsigned int ac = 0;           /* Arg Count */
    Atom delw;
    char location_db_path[MAX_VALUE];

    get_user_base_dir("data/locations_db.dat", location_db_path, 
                      sizeof(location_db_path));

    if(!location_dialog) {

begin_critical_section(&location_dialog_lock, "location_gui.c:Jump_location" );

        location_dialog = XtVaCreatePopupShell(langcode("JMLPO00001"),
                xmDialogShellWidgetClass,
                appshell,
                XmNdeleteResponse,XmDESTROY,
                XmNdefaultPosition, FALSE,
                XmNresize, FALSE,
                XmNfontList, fontlist1,
                NULL);

        pane = XtVaCreateWidget("Jump_location pane",
                xmPanedWindowWidgetClass,
                location_dialog,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                NULL);

        form =  XtVaCreateWidget("Jump_location form",
                xmFormWidgetClass,
                pane,
                XmNfractionBase, 5,
                XmNautoUnmanage, FALSE,
                XmNshadowThickness, 1,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                NULL);

        /*set args for color */
        ac=0;
        XtSetArg(al[ac], XmNvisibleItemCount, 11); ac++;
        XtSetArg(al[ac], XmNtraversalOn, TRUE); ac++;
        XtSetArg(al[ac], XmNshadowThickness, 3); ac++;
        XtSetArg(al[ac], XmNbackground, colors[0x0ff]); ac++;
        XtSetArg(al[ac], XmNselectionPolicy, XmSINGLE_SELECT); ac++;
        XtSetArg(al[ac], XmNscrollBarPlacement, XmBOTTOM_RIGHT); ac++;
        XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
        XtSetArg(al[ac], XmNtopOffset, 5); ac++;
        XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
        XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
        XtSetArg(al[ac], XmNrightOffset, 5); ac++;
        XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
        XtSetArg(al[ac], XmNleftOffset, 5); ac++;
        XtSetArg(al[ac], XmNforeground, MY_FG_COLOR); ac++;
        XtSetArg(al[ac], XmNbackground, MY_BG_COLOR); ac++;
        XtSetArg(al[ac], XmNfontList, fontlist1); ac++;
 
        location_list = XmCreateScrolledList(form,
                "Jump_location list",
                al,
                ac);

        n=1;
        clear_sort_file(location_db_path);
        jump_sort();
        sort_list(location_db_path,200,location_list,&n);

        locdata = XtVaCreateManagedWidget(langcode("JMLPO00003"),
                xmLabelWidgetClass, 
                form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, XtParent(location_list),
                XmNtopOffset, 10,
                XmNbottomAttachment, XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_FORM,
                XmNleftOffset, 5,
                XmNrightAttachment, XmATTACH_NONE,
                MY_FOREGROUND_COLOR,
                MY_BACKGROUND_COLOR,
                XmNfontList, fontlist1,
                NULL);

        location_name = XtVaCreateManagedWidget("Jump_location Location_name", 
                xmTextFieldWidgetClass, 
                form,
                XmNeditable,   TRUE,
                XmNcursorPositionVisible, TRUE,
                XmNsensitive, TRUE,
                XmNshadowThickness,      1,
                XmNcolumns,21,
                XmNwidth,((21*7)+2),
                XmNbackground, colors[0x0f],
                XmNtopAttachment,XmATTACH_WIDGET,
                XmNtopWidget, XtParent(location_list),
                XmNtopOffset, 5,
                XmNbottomAttachment,XmATTACH_NONE,
                XmNleftAttachment, XmATTACH_WIDGET,
                XmNleftWidget,locdata,
                XmNrightAttachment,XmATTACH_FORM,
                XmNrightOffset, 5,
                XmNfontList, fontlist1,
                NULL);

        button_ok = XtVaCreateManagedWidget(langcode("JMLPO00002"),
                xmPushButtonGadgetClass, 
                form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, locdata,
                XmNtopOffset,15,
                XmNbottomAttachment, XmATTACH_FORM,
                XmNbottomOffset,5,
                XmNleftAttachment, XmATTACH_POSITION,
                XmNleftPosition, 0,
                XmNleftOffset, 3,
                XmNrightAttachment, XmATTACH_POSITION,
                XmNrightPosition, 1,
                XmNnavigationType, XmTAB_GROUP,
                XmNfontList, fontlist1,
                NULL);

        button_add = XtVaCreateManagedWidget(langcode("UNIOP00007"),
                xmPushButtonGadgetClass, 
                form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, locdata,
                XmNtopOffset,15,
                XmNbottomAttachment, XmATTACH_FORM,
                XmNbottomOffset,5,
                XmNleftAttachment, XmATTACH_POSITION,
                XmNleftPosition, 1,
                XmNrightAttachment, XmATTACH_POSITION,
                XmNrightPosition, 2,
                XmNnavigationType, XmTAB_GROUP,
                XmNfontList, fontlist1,
                NULL);

        button_delete = XtVaCreateManagedWidget(langcode("UNIOP00008"),
                xmPushButtonGadgetClass, 
                form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, locdata,
                XmNtopOffset,15,
                XmNbottomAttachment, XmATTACH_FORM,
                XmNbottomOffset,5,
                XmNleftAttachment, XmATTACH_POSITION,
                XmNleftPosition, 2,
                XmNrightAttachment, XmATTACH_POSITION,
                XmNrightPosition, 3,
                XmNnavigationType, XmTAB_GROUP,
                XmNfontList, fontlist1,
                NULL);

        button_cancel = XtVaCreateManagedWidget(langcode("UNIOP00003"),
                xmPushButtonGadgetClass, 
                form,
                XmNtopAttachment, XmATTACH_WIDGET,
                XmNtopWidget, locdata,
                XmNtopOffset,15,
                XmNbottomAttachment, XmATTACH_FORM,
                XmNbottomOffset,5,
                XmNleftAttachment, XmATTACH_POSITION,
                XmNleftPosition, 4,
                XmNrightAttachment, XmATTACH_POSITION,
                XmNrightPosition, 5,
                XmNrightOffset, 3,
                XmNnavigationType, XmTAB_GROUP,
                XmNfontList, fontlist1,
                NULL);

        XtAddCallback(button_cancel, XmNactivateCallback, location_destroy_shell, location_dialog);
        XtAddCallback(button_ok, XmNactivateCallback, location_view, NULL);
        XtAddCallback(button_add, XmNactivateCallback, location_add, location_name);
        XtAddCallback(button_delete, XmNactivateCallback, location_delete, NULL);

        pos_dialog(location_dialog);

        delw = XmInternAtom(XtDisplay(location_dialog),"WM_DELETE_WINDOW", FALSE);
        XmAddWMProtocolCallback(location_dialog, delw, location_destroy_shell, (XtPointer)location_dialog);

        XtManageChild(form);
        XtManageChild(location_list);
        XtVaSetValues(location_list, XmNbackground, colors[0x0f], NULL);
        XtManageChild(pane);

end_critical_section(&location_dialog_lock, "location_gui.c:location_destroy_shell" );

        XtPopup(location_dialog,XtGrabNone);
        fix_dialog_size(location_dialog);

        // Move focus to the Close button.  This appears to highlight the
        // button fine, but we're not able to hit the <Enter> key to
        // have that default function happen.  Note:  We _can_ hit the
        // <SPACE> key, and that activates the option.
//        XmUpdateDisplay(location_dialog);
        XmProcessTraversal(button_cancel, XmTRAVERSE_CURRENT);

    } else {
        XtPopup(location_dialog,XtGrabNone);
        (void)XRaiseWindow(XtDisplay(location_dialog), XtWindow(location_dialog));
    }
}