11 #include <sys/types.h> 15 #include <X11/Intrinsic.h> 16 #include <X11/StringDefs.h> 17 #include <X11/Xaw/AsciiText.h> 18 #include <X11/Xaw/Paned.h> 19 #include <X11/Xaw/Label.h> 20 #include <X11/Xaw/Viewport.h> 21 #include <X11/Xaw/Command.h> 22 #include <X11/Xaw/Box.h> 23 #include <X11/Shell.h> 28 static void ToTop(Widget, XtPointer, XEvent*, Boolean*);
34 "<Key>Return: cr_action()\n<Key>Delete: delete-next-character()";
36 static char *
wmTranslations =
"<Message>WM_PROTOCOLS: quit_action()";
40 PopUpInput(initial_str, action_str, action_callback,
w)
42 String initial_str, action_str;
43 void (*action_callback)();
50 Dimension width, b_width,
d;
53 w->
popup = XtVaCreatePopupShell(
"popup", transientShellWidgetClass,
56 XtAddEventHandler(w->
popup, VisibilityChangeMask,
57 False, ToTop, (XtPointer)w);
59 form = XtVaCreateManagedWidget(
"form", formWidgetClass, w->
popup,
62 label = XtVaCreateManagedWidget(
"label", labelWidgetClass,
64 XtNlabel,
"Enter filename: ",
66 XtNright, XtChainLeft,
71 w->
popup_text = XtVaCreateManagedWidget(
"text", asciiTextWidgetClass,
75 XtNright, XtChainRight,
76 XtNeditType, XawtextEdit,
78 XtNresize, XawtextResizeWidth,
79 XtNstring, initial_str,
84 action = XtVaCreateManagedWidget(
"action", commandWidgetClass,
89 XtNright, XtChainLeft,
91 XtAddCallback(action, XtNcallback, action_callback, (XtPointer)w);
92 XtOverrideTranslations(action, XtParseTranslationTable(
butTranslations));
94 cancel = XtVaCreateManagedWidget(
"cancel", commandWidgetClass,
100 XtNright, XtChainLeft,
102 XtAddCallback(cancel, XtNcallback,
PopDownInput, (XtPointer)w);
104 XtRealizeWidget(w->
popup);
110 XtNborderWidth, &b_width,
111 XtNdefaultDistance, &d,
113 width -= 2*(b_width + d + 1);
116 XtPopup(w->
popup, XtGrabNone);
120 XtSetSensitive(XtNameToWidget(w->
butbox, *p),
False);
129 XtPointer client_data, call_data;
134 XtSetKeyboardFocus(w->
shell, None);
137 XtSetSensitive(XtNameToWidget(w->
butbox, *p),
True);
152 XColor visualcolor, exactcolor;
154 popup = XtVaCreatePopupShell(
"popup_m", transientShellWidgetClass,
156 XtOverrideTranslations(popup, XtParseTranslationTable(
wmTranslations));
157 XtAddEventHandler(popup, VisibilityChangeMask,
158 False, ToTop, (XtPointer)w);
160 form = XtVaCreateManagedWidget(
"form_m", formWidgetClass, popup,
163 cancel = XtVaCreateManagedWidget(
"cancel_m", commandWidgetClass,
166 XtNleft, XtChainLeft,
167 XtNright, XtChainLeft,
172 "red", &exactcolor, &visualcolor);
173 label = XtVaCreateManagedWidget(
"label_m", labelWidgetClass,
175 XtNlabel, message_str,
176 XtNleft, XtChainLeft,
177 XtNright, XtChainLeft,
178 XtNfromHoriz, cancel,
181 XtNborderColor, visualcolor.pixel,
186 XtAddEventHandler(form, KeyPressMask,
False,
188 XtRealizeWidget(popup);
194 XtSetKeyboardFocus(w->
shell, form);
195 XtPopup(popup, XtGrabExclusive);
204 XtPointer client_data, call_data;
214 XtSetKeyboardFocus(w->
shell, None);
231 XColor visualcolor, exactcolor;
233 popup = XtVaCreatePopupShell(
"popup_e", transientShellWidgetClass,
235 XtOverrideTranslations(popup, XtParseTranslationTable(
wmTranslations));
236 XtAddEventHandler(popup, VisibilityChangeMask,
237 False, ToTop, (XtPointer)w);
239 form = XtVaCreateManagedWidget(
"form_e", formWidgetClass, popup,
242 cancel = XtVaCreateManagedWidget(
"cancel_e", commandWidgetClass,
245 XtNleft, XtChainLeft,
246 XtNright, XtChainLeft,
251 "red", &exactcolor, &visualcolor);
252 label = XtVaCreateManagedWidget(
"text_e", asciiTextWidgetClass,
254 XtNstring, message_str,
255 XtNleft, XtChainLeft,
256 XtNright, XtChainRight,
257 XtNbottom, XtChainBottom,
258 XtNscrollHorizontal, XawtextScrollWhenNeeded,
259 XtNscrollVertical, XawtextScrollWhenNeeded,
262 XtNfromHoriz, cancel,
263 XtNdisplayCaret,
False,
265 XtNborderColor, visualcolor.pixel,
268 XtAddCallback(cancel, XtNcallback,
PopDownErr, (XtPointer)popup);
269 XtAddEventHandler(form, KeyPressMask,
False, (XtEventHandler)
PopDownErr,
271 XtRealizeWidget(popup);
274 XtPopup(popup, XtGrabNone);
283 XtPointer client_data, call_data;
285 XtPopdown((Widget)client_data);
294 Dimension width, height, b_width;
295 Position x, y, max_x, max_y;
297 XtVaGetValues(master,
302 XtNborderWidth, &b_width,
308 x += (Position)width/2;
309 y += (Position)height/2;
314 XtNborderWidth, &b_width,
319 x -= (Position)width/2;
321 y -= (Position)height/2;
323 if (y > (max_y = (Position) (XtScreen(sub)->height - height))) y = max_y;
325 XtVaSetValues(sub, XtNx, x, XtNy, y,
NULL);
339 char *msg =
"Error: can't %s file %s";
342 if (!fname)
return (
NOGO);
343 while (isspace(*fname)) fname++;
344 if (!*fname)
return (
NOGO);
346 if (!
access(fname, F_OK)) {
348 if (stat(fname, &st))
351 if ((st.st_mode&S_IFMT) != S_IFLNK &&
352 (st.st_mode&S_IFMT) != S_IFREG)
goto bad;
360 if (!
access(fname,F_OK))
goto bad;
367 if (!
access(fname,F_OK))
goto bad;
368 fp = fopen(fname,
"w");
375 sprintf(buf, msg, (mode == R_OK) ?
"read" :
"write", fname);
383 ToTop(caller, clientdata, event, ctd)
386 XtPointer clientdata;
393 XVisibilityEvent *vev = (XVisibilityEvent*)event;
396 if (vev->state == VisibilityFullyObscured) {
397 xv.sibling = XtWindow(w->
shell);
398 xv.stack_mode = Above;
399 XReconfigureWMWindow(vev->display, vev->window,
400 DefaultScreen(vev->display), CWSibling|CWStackMode, &xv);
static char buf[MAXPROMPT]
static char * butTranslations
int access(char *pth, int m)
static char * oneLineTranslations
static char * wmTranslations
void CenterWidgetOnWidget()