示例#1
0
文件: SetWin.c 项目: aosm/X11
static Widget
FindToplevel(Widget widget)
{
    while (XtParent(widget) != NULL && !XtIsTopLevelShell(widget))
	widget = XtParent(widget);

    return widget;
}
示例#2
0
/* This is a trick/kludge.  To make shared libraries happier (linking
 * against Xmu but not linking against Xt, and apparently even work
 * as we desire on SVR4, we need to avoid an explicit data reference
 * to applicationShellWidgetClass.  XtIsTopLevelShell is known
 * (implementation dependent assumption!) to use a bit flag.  So we
 * go that far.  Then, we test whether it is an applicationShellWidget
 * class by looking for an explicit class name.  Seems pretty safe.
 */
static Bool
isApplicationShell(Widget w)
{
    register WidgetClass c;

    if (!XtIsTopLevelShell(w))
        return False;
    for (c = XtClass(w); c; c = c->core_class.superclass) {
        if (!strcmp(c->core_class.class_name, "ApplicationShell"))
            return True;
    }
    return False;
}
示例#3
0
文件: YesNo.c 项目: idunham/dtextra
Boolean XltYesNo(Widget w, String Question)
{
static Widget Dialog = NULL;
static int Result;
Boolean Return;
XmString string;

	if (Dialog == NULL)
	{
	Widget shell = w;

		while (XtParent(shell) && !XtIsTopLevelShell(shell)) shell = XtParent(shell);
		Dialog = XmCreateQuestionDialog(shell, "YesNo", NULL, 0);
		XtUnmanageChild(XmMessageBoxGetChild(Dialog, XmDIALOG_HELP_BUTTON));
		XtAddCallback(Dialog, XmNokCallback, (XtCallbackProc)callback, &Result);
		XtAddCallback(Dialog, XmNcancelCallback, (XtCallbackProc)callback, &Result);
		XtAddCallback(Dialog, XmNunmapCallback, (XtCallbackProc)callback, &Result);
	}
	string = XmStringCreateSimple(Question);
	XtVaSetValues(Dialog,
		XmNmessageString, string,
		NULL);
	XmStringFree(string);
	XtManageChild(Dialog);
	Result = XmCR_NONE;
	while (Result == XmCR_NONE)
	{
		XtAppProcessEvent(XtWidgetToApplicationContext(w), XtIMAll);
	}
	switch (Result)
	{
	case XmCR_OK:
		Return = True;
		break;
	case XmCR_CANCEL:
	case XmCR_UNMAP:
		Return = False;
		break;
	default:
		fprintf(stderr, "%s(%d):XltYesNo() - Unknown result code >%i<\n",
			__FILE__, __LINE__, Result);
		Return = False;
		break;
	}
	return(Return);
}
示例#4
0
文件: Host.c 项目: idunham/dtextra
void
XltHostSelect(Widget W, Widget w)
{
    while (!XtIsTopLevelShell(W))
	W = XtParent(W);
    /*
    fprintf(stderr, "%s:%s(%d) - %s %s %s\n", __FILE__, __FUNCTION__, __LINE__,
    	XtName(W), XtName(w),
    	Host_Dialog(w) ? XtName(Host_Dialog(w)) : "NULL");
    */
    if (Host_Dialog(w) == NULL)
    {
	Widget Form;
	Widget Form1;
	Widget Form2;
	Widget HostLabel;
	Widget HostText;
	Widget PortLabel;
	Widget PortText;
	String Name;

	Name = XtMalloc(strlen(XtName(w)) + 7);
	sprintf(Name, "%sSelect", XtName(w));
	Host_Dialog(w) = XmCreateMessageDialog(W, Name, NULL, 0);
	XtFree(Name);
	Form = XmCreateForm(Host_Dialog(w), "Form", NULL, 0);

	Form1 = XmCreateForm(Form, "HostForm", NULL, 0);
	XtVaSetValues(Form1,
		      XmNtopAttachment, XmATTACH_FORM,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNrightAttachment, XmATTACH_FORM,
		      NULL);
	HostLabel = XmCreateLabel(Form1, "Host", NULL, 0);
	HostText = XmCreateTextField(Form1, "HostText", NULL, 0);
	XtVaSetValues(HostLabel,
		      XmNtopAttachment, XmATTACH_FORM,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNbottomAttachment, XmATTACH_FORM,
		      NULL);
	XtVaSetValues(HostText,
		      XmNtopAttachment, XmATTACH_FORM,
		      XmNbottomAttachment, XmATTACH_FORM,
		      XmNleftAttachment, XmATTACH_WIDGET,
		      XmNleftWidget, HostLabel,
		      XmNrightAttachment, XmATTACH_FORM,
		      NULL);
	XtManageChild(HostLabel);
	XtManageChild(HostText);
	XtManageChild(Form1);

	Form2 = XmCreateForm(Form, "PortForm", NULL, 0);
	XtVaSetValues(Form2,
		      XmNtopAttachment, XmATTACH_WIDGET,
		      XmNtopWidget, Form1,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNrightAttachment, XmATTACH_FORM,
		      NULL);
	PortLabel = XmCreateLabel(Form2, "Port", NULL, 0);
	PortText = XmCreateTextField(Form2, "PortText", NULL, 0);
	XtVaSetValues(PortLabel,
		      XmNtopAttachment, XmATTACH_FORM,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNbottomAttachment, XmATTACH_FORM,
		      NULL);
	XtVaSetValues(PortText,
		      XmNtopAttachment, XmATTACH_FORM,
		      XmNbottomAttachment, XmATTACH_FORM,
		      XmNleftAttachment, XmATTACH_WIDGET,
		      XmNleftWidget, PortLabel,
		      XmNrightAttachment, XmATTACH_FORM,
		      NULL);
	XtManageChild(PortLabel);
	XtManageChild(PortText);
	XtManageChild(Form2);

	XtManageChild(Form);
	XtAddCallback(Host_Dialog(w), XmNokCallback, (XtCallbackProc)OpenHost, w);
	XtAddCallback(Host_Dialog(w), XmNhelpCallback, (XtCallbackProc)XltHelpOnHostSelect, w);
    }
    XmTextFieldSetString(XtNameToWidget(Host_Dialog(w), "*HostText"), Host_Name(w));
    XmTextFieldSetString(XtNameToWidget(Host_Dialog(w), "*PortText"), Host_Port(w));
    XtManageChild(Host_Dialog(w));
}
示例#5
0
static void
PostModelessDialog(Widget w, XtPointer client_data, XtPointer call_data)
{

    Widget	parent, spawnButton, okButton, cancelButton;
    int 	n;
    Arg 	args[MAX_ARGS];
    XmString tcs;
	char	title[NAME_LEN + 1];
	int		DialogCount;

	title[0] = '\0';

	if (ModelessDialogCount >= MAX_DIALOGS) {
		fprintf(stderr, "Too many modeless dialogs\n");
		return;
	}

	for (DialogCount = 0; DialogCount < MAX_DIALOGS; DialogCount++)
		if (ModelessDia[DialogCount].DialogIndex == -1)
			break;
	if (DialogCount == MAX_DIALOGS) {
		fprintf(stderr, "No more modeless dialogs\n");
		return;
	}
	sprintf(title, "Modeless%d", DialogCount);
    parent = (Widget) client_data;

#ifndef MOTIF1_1
	if (Test1_2) 
		{ 
		while (!XtIsTopLevelShell(parent))
			parent = XtParent(parent);
		}
#endif

    n = 0;
    /* message box resources */
    XtSetArg (args[n], XmNmessageString, 
			  XmStringCreateSimple (ModelessMsg)); n++;
    XtSetArg (args[n], XmNhelpLabelString, 
			  XmStringCreateSimple ("Spawn Dialog Child")); n++;

    /* dialog shell resources */
    XtSetArg (args[n], XmNtitle, title); n++;
    XtSetArg (args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++;

	/* VendorShell resources */
#ifndef MOTIF1_1

	if (Test1_2 == True) {
		XtSetArg(args[n], XmNmwmMenu, MeuStrDia2); n++;
	}
	else {
		XtSetArg(args[n], XmNmwmMenu, MenuStrDia1); n++;
	}

#else

	XtSetArg(args[n], XmNmwmMenu, MenuStrDia1); n++;

#endif /* MOTIF1_1 */

    ModelessDia[DialogCount].Dialog= XmCreateMessageDialog(parent, title, 
															 args, n);

/* make HELP button spawn a child */
    spawnButton = XmMessageBoxGetChild (ModelessDia[DialogCount].Dialog, 
										XmDIALOG_HELP_BUTTON);
    XtAddCallback (spawnButton, XmNactivateCallback, 
				   PostModelessDialog, ModelessDia[DialogCount].Dialog);

    okButton = XmMessageBoxGetChild (ModelessDia[DialogCount].Dialog, 
									 XmDIALOG_OK_BUTTON);
    cancelButton = XmMessageBoxGetChild (ModelessDia[DialogCount].Dialog, 
									 	 XmDIALOG_CANCEL_BUTTON);
    XtAddCallback (okButton, XmNactivateCallback, 
				   DestroyModelessDialog, 
				   (XtPointer) &ModelessDia[DialogCount]);
#if 1
    XtAddCallback (cancelButton, XmNactivateCallback, 
				   DestroyModelessDialog, 
				   (XtPointer) &ModelessDia[DialogCount]);
#endif

    XtManageChild (ModelessDia[DialogCount].Dialog);
	ModelessDia[DialogCount].DialogIndex = DialogCount;
	ModelessDia[DialogCount].Parent = parent;
	ModelessDialogCount++;

}