staticvoid ButtonSelected (
Widget w,
XtPointer cld,
XtPointer cd)
{ Int i; Int * res = (int*) cld;
String name;
/* find name in <buttons> and set result */
XtVaGetValues( w, XtNlabel, (XtArgVal)&name, (String)NULL ); for ( i = 0; i < XtNumber(buttons); i++ ) if ( ! strcmp( buttons[i].name, name ) )
(*res) |= buttons[i].flag;
}
Int PopupDialog (
TypePopupDialog dialog,
String message,
String deflt,
String * result)
{
Display * display;
Position x1, y1, tmp;
Dimension w1, h1, bw;
Window root;
Window child; Int x2, y2, x3, y3;
UInt bt; Int i; Int textlen, deflen;
/* create font cursor */
display = XtDisplay(dialog->popupShell); if ( BlobCursor == 0 )
BlobCursor = XCreateFontCursor( display, XC_dot );
/* set message and default answer in dialog */ /* Changes by Max: 11.3.1999: XtVaSetValues(dialog->dialog, XtNlabel,"", XtNvalue,"",
0, 0 );*/
XtVaSetValues( dialog->dialog,
XtNlabel, (XtArgVal)message,
XtNvalue, (XtArgVal)deflt,
(String)NULL ); /* get size of popup dialog */
XtVaGetValues( dialog->popupShell,
XtNwidth, (XtArgVal)&w1,
(String)NULL );
textlen = strlen(message)*NormalFont->max_bounds.width + 80;
deflen = strlen(deflt)*NormalFont->max_bounds.width + 60; if (textlen > deflen) { if (textlen < w1)
textlen = w1;
} else { if (deflen < w1)
textlen = w1; else
textlen = deflen;
}
XtVaSetValues( dialog->dialog,
XtNwidth,textlen, 0,NULL ); /* End of changes by Max. */
XtRealizeWidget( dialog->popupShell );
/* get size of popup dialog */
XtVaGetValues( dialog->popupShell,
XtNwidth, (XtArgVal)&w1,
XtNheight, (XtArgVal)&h1,
XtNborderWidth, (XtArgVal)&bw,
(String)NULL );
/* get position of the mouse pointer */
XQueryPointer( display, XtWindow(dialog->popupShell),
&root, &child, &x2, &y2, &x3, &y3, &bt );
/* find a nice position for the dialog */
tmp = DisplayWidth( display, DefaultScreen(display) );
x1 = x2 - (bw+w1)/2; if ( tmp-w1-2*bw < x1 ) x1 = tmp-w1-2*bw; if ( x1 < 0 ) x1 = 0;
tmp = DisplayHeight( display, DefaultScreen(display) );
y1 = y2 - (bw+h1)/2; if ( tmp-h1-2*bw < y1 ) y1 = tmp-h1-2*bw; if ( y1 < 0 ) y1 = 0;
/* move the popup dialog to this position */
XtVaSetValues( dialog->popupShell,
XtNx, (XtArgVal)x1,
XtNy, (XtArgVal)y1,
(String)NULL );
/* pop up shell */
XtPopup( dialog->popupShell, XtGrabExclusive ); for ( i = 0; i < XtNumber(buttons); i++ ) if ( dialog->buttons[i] )
XDefineCursor( display,
XtWindow(dialog->buttons[i]), BlobCursor );
/* wait until at least one button is selected */
dialog->result = 0; while ( ( dialog->result & dialog->button ) == 0 )
{
XEvent event; char str[128];
KeySym keysym; Int len;
/* get next application event */
XtAppNextEvent(dialog->context, &event);
/* is the event a key event */ if ( event.type == KeyPress )
{ if ( dialog->defaultButton != 0 )
{
/* convert key event into text string and check for return */
len = XLookupString((XKeyEvent*)&event,str,128,&keysym,0); if ( len != 0 && ( str[0] == '\n' || str[0] == '\r' ) )
{
dialog->result |= dialog->defaultButton; continue;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.