1 | /* |
---|
2 | * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC. |
---|
3 | * ALL RIGHTS RESERVED |
---|
4 | */ |
---|
5 | /* |
---|
6 | * Motif Release 1.2.3 |
---|
7 | */ |
---|
8 | #ifdef REV_INFO |
---|
9 | #ifndef lint |
---|
10 | static char rcsid[] = "$RCSfile: WmFeedback.c,v $ $Revision: 1.1.1.1 $ $Date: 1997-03-25 09:12:18 $" |
---|
11 | #endif |
---|
12 | #endif |
---|
13 | /* |
---|
14 | * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */ |
---|
15 | |
---|
16 | /* |
---|
17 | * Included Files: |
---|
18 | */ |
---|
19 | #include "WmGlobal.h" |
---|
20 | #include "WmResNames.h" |
---|
21 | |
---|
22 | #define MWM_NEED_TIME16 |
---|
23 | #include "WmBitmap.h" |
---|
24 | |
---|
25 | #include <Xm/Xm.h> |
---|
26 | #include <X11/Shell.h> |
---|
27 | #include <Xm/Label.h> |
---|
28 | #include <Xm/DialogS.h> |
---|
29 | #include <Xm/BulletinB.h> |
---|
30 | #include <Xm/MessageB.h> |
---|
31 | |
---|
32 | #define MOVE_OUTLINE_WIDTH 2 |
---|
33 | #define FEEDBACK_BEVEL 2 |
---|
34 | |
---|
35 | #define DEFAULT_POSITION_STRING "(0000x0000)" |
---|
36 | |
---|
37 | #define CB_HIGHLIGHT_THICKNESS 3 |
---|
38 | |
---|
39 | /* |
---|
40 | * include extern functions |
---|
41 | */ |
---|
42 | #include "WmFeedback.h" |
---|
43 | #include "WmFunction.h" |
---|
44 | #include "WmGraphics.h" |
---|
45 | #include "WmManage.h" |
---|
46 | #include "WmColormap.h" |
---|
47 | #include "stdio.h" |
---|
48 | |
---|
49 | |
---|
50 | /* |
---|
51 | * Global Variables: |
---|
52 | */ |
---|
53 | static Cursor waitCursor = (Cursor)0L; |
---|
54 | |
---|
55 | /* see WmGlobal.h for index defines: */ |
---|
56 | |
---|
57 | static char *confirm_mesg[4] = {"Toggle to Default Behavior?", |
---|
58 | "Toggle to Custom Behavior?", |
---|
59 | "Restart Mwm?", |
---|
60 | "QUIT Mwm?"}; |
---|
61 | |
---|
62 | static char *confirm_widget[4] = {"confirmDefaultBehavior", |
---|
63 | "confirmCustomBehavior", |
---|
64 | "confirmRestart", |
---|
65 | "confirmQuit"}; |
---|
66 | |
---|
67 | |
---|
68 | #ifdef _NO_PROTO |
---|
69 | typedef void (*ConfirmFunc)(); |
---|
70 | #else |
---|
71 | typedef void (*ConfirmFunc)(Boolean); |
---|
72 | #endif |
---|
73 | static ConfirmFunc confirm_func[4] = {Do_Set_Behavior, |
---|
74 | Do_Set_Behavior, |
---|
75 | Do_Restart, |
---|
76 | Do_Quit_Mwm}; |
---|
77 | |
---|
78 | |
---|
79 | /*************************************<->************************************* |
---|
80 | * |
---|
81 | * ShowFeedbackWindow(pSD, x, y, width, height, style) |
---|
82 | * |
---|
83 | * |
---|
84 | * Description: |
---|
85 | * ----------- |
---|
86 | * Pop up the window for moving and sizing feedback |
---|
87 | * |
---|
88 | * |
---|
89 | * Inputs: |
---|
90 | * ------ |
---|
91 | * pSD - pointer to screen data |
---|
92 | * x - initial x-value |
---|
93 | * y - initial y-value |
---|
94 | * width - initial width value |
---|
95 | * height - initial height value |
---|
96 | * style - show size, position, or both |
---|
97 | * |
---|
98 | * |
---|
99 | * Outputs: |
---|
100 | * ------- |
---|
101 | * |
---|
102 | * |
---|
103 | * Comments: |
---|
104 | * -------- |
---|
105 | *************************************<->***********************************/ |
---|
106 | #ifdef _NO_PROTO |
---|
107 | void ShowFeedbackWindow (pSD, x, y, width, height, style) |
---|
108 | |
---|
109 | WmScreenData *pSD; |
---|
110 | int x, y; |
---|
111 | unsigned int width, height; |
---|
112 | unsigned long style; |
---|
113 | #else /* _NO_PROTO */ |
---|
114 | void ShowFeedbackWindow (WmScreenData *pSD, int x, int y, unsigned int width, unsigned int height, unsigned long style) |
---|
115 | #endif /* _NO_PROTO */ |
---|
116 | { |
---|
117 | unsigned long mask = 0; |
---|
118 | XSetWindowAttributes win_attribs; |
---|
119 | XWindowChanges win_changes; |
---|
120 | int direction, ascent, descent; |
---|
121 | XCharStruct xcsLocation; |
---|
122 | int winX, winY; |
---|
123 | int tmpX, tmpY; |
---|
124 | |
---|
125 | if ( (pSD->fbStyle = style) == FB_OFF) |
---|
126 | return; |
---|
127 | |
---|
128 | pSD->fbLastX = x; |
---|
129 | pSD->fbLastY = y; |
---|
130 | pSD->fbLastWidth = width; |
---|
131 | pSD->fbLastHeight = height; |
---|
132 | |
---|
133 | /* |
---|
134 | * Derive the size and position of the window from the text extents |
---|
135 | * Set starting position of each string |
---|
136 | */ |
---|
137 | XTextExtents(pSD->feedbackAppearance.font, DEFAULT_POSITION_STRING, |
---|
138 | strlen(DEFAULT_POSITION_STRING), &direction, &ascent, |
---|
139 | &descent, &xcsLocation); |
---|
140 | |
---|
141 | pSD->fbWinWidth = xcsLocation.width + 4*FEEDBACK_BEVEL; |
---|
142 | |
---|
143 | switch (pSD->fbStyle) |
---|
144 | { |
---|
145 | case FB_SIZE: |
---|
146 | pSD->fbSizeY = 2*FEEDBACK_BEVEL + ascent; |
---|
147 | pSD->fbWinHeight = (ascent + descent) + 4*FEEDBACK_BEVEL; |
---|
148 | break; |
---|
149 | |
---|
150 | case FB_POSITION: |
---|
151 | pSD->fbLocY = 2*FEEDBACK_BEVEL + ascent; |
---|
152 | pSD->fbWinHeight = (ascent + descent) + 4*FEEDBACK_BEVEL; |
---|
153 | break; |
---|
154 | |
---|
155 | default: |
---|
156 | case (FB_SIZE | FB_POSITION): |
---|
157 | pSD->fbLocY = 2*FEEDBACK_BEVEL + ascent; |
---|
158 | pSD->fbSizeY = pSD->fbLocY + ascent + descent; |
---|
159 | pSD->fbWinHeight = 2*(ascent + descent) + 4*FEEDBACK_BEVEL; |
---|
160 | break; |
---|
161 | } |
---|
162 | |
---|
163 | if (pSD->feedbackGeometry) /* set by user */ |
---|
164 | { |
---|
165 | unsigned int junkWidth, junkHeight; |
---|
166 | |
---|
167 | mask = XParseGeometry(pSD->feedbackGeometry, &tmpX, &tmpY, |
---|
168 | &junkWidth, &junkHeight); |
---|
169 | } |
---|
170 | |
---|
171 | if (mask & (XValue|YValue)) |
---|
172 | { |
---|
173 | winX = (mask & XNegative) ? |
---|
174 | DisplayWidth(DISPLAY, pSD->screen) + tmpX - pSD->fbWinWidth : tmpX; |
---|
175 | winY = (mask & YNegative) ? |
---|
176 | DisplayHeight(DISPLAY, pSD->screen) + tmpY -pSD->fbWinHeight : tmpY; |
---|
177 | } |
---|
178 | else |
---|
179 | { |
---|
180 | winX = (DisplayWidth(DISPLAY, pSD->screen) - pSD->fbWinWidth)/2; |
---|
181 | winY = (DisplayHeight(DISPLAY, pSD->screen) -pSD->fbWinHeight)/2; |
---|
182 | } |
---|
183 | |
---|
184 | /* |
---|
185 | * Put new text into the feedback strings |
---|
186 | */ |
---|
187 | UpdateFeedbackText (pSD, x, y, width, height); |
---|
188 | |
---|
189 | /* |
---|
190 | * bevel the window border for a 3-D look |
---|
191 | */ |
---|
192 | if ( (pSD->fbTop && pSD->fbBottom) || |
---|
193 | ((pSD->fbTop = AllocateRList((unsigned)2*FEEDBACK_BEVEL)) && |
---|
194 | (pSD->fbBottom = AllocateRList((unsigned)2*FEEDBACK_BEVEL))) ) |
---|
195 | { |
---|
196 | pSD->fbTop->used = 0; |
---|
197 | pSD->fbBottom->used = 0; |
---|
198 | BevelRectangle (pSD->fbTop, |
---|
199 | pSD->fbBottom, |
---|
200 | 0, 0, |
---|
201 | pSD->fbWinWidth, pSD->fbWinHeight, |
---|
202 | FEEDBACK_BEVEL, FEEDBACK_BEVEL, |
---|
203 | FEEDBACK_BEVEL, FEEDBACK_BEVEL); |
---|
204 | } |
---|
205 | |
---|
206 | /* |
---|
207 | * Create window if not yet created, otherwise fix size and position |
---|
208 | */ |
---|
209 | |
---|
210 | if (!pSD->feedbackWin) |
---|
211 | { |
---|
212 | |
---|
213 | /* |
---|
214 | * Create the window |
---|
215 | */ |
---|
216 | |
---|
217 | mask = CWEventMask | CWOverrideRedirect | CWSaveUnder; |
---|
218 | win_attribs.event_mask = ExposureMask; |
---|
219 | win_attribs.override_redirect = TRUE; |
---|
220 | win_attribs.save_under = TRUE; |
---|
221 | |
---|
222 | /* |
---|
223 | * Use background pixmap if one is specified, otherwise set the |
---|
224 | * appropriate background color. |
---|
225 | */ |
---|
226 | |
---|
227 | if (pSD->feedbackAppearance.backgroundPixmap) |
---|
228 | { |
---|
229 | mask |= CWBackPixmap; |
---|
230 | win_attribs.background_pixmap = |
---|
231 | pSD->feedbackAppearance.backgroundPixmap; |
---|
232 | } |
---|
233 | else |
---|
234 | { |
---|
235 | mask |= CWBackPixel; |
---|
236 | win_attribs.background_pixel = |
---|
237 | pSD->feedbackAppearance.background; |
---|
238 | } |
---|
239 | |
---|
240 | pSD->feedbackWin = XCreateWindow (DISPLAY, pSD->rootWindow, |
---|
241 | winX, winY, |
---|
242 | pSD->fbWinWidth, |
---|
243 | pSD->fbWinHeight, |
---|
244 | 0, CopyFromParent, |
---|
245 | InputOutput, CopyFromParent, |
---|
246 | mask, &win_attribs); |
---|
247 | } |
---|
248 | else |
---|
249 | { |
---|
250 | win_changes.x = winX; |
---|
251 | win_changes.y = winY; |
---|
252 | win_changes.width = pSD->fbWinWidth; |
---|
253 | win_changes.height = pSD->fbWinHeight; |
---|
254 | win_changes.stack_mode = Above; |
---|
255 | |
---|
256 | mask = CWX | CWY | CWWidth | CWHeight | CWStackMode; |
---|
257 | |
---|
258 | XConfigureWindow(DISPLAY, pSD->feedbackWin, (unsigned int) mask, |
---|
259 | &win_changes); |
---|
260 | } |
---|
261 | |
---|
262 | |
---|
263 | /* |
---|
264 | * Make the feedback window visible (map it) |
---|
265 | */ |
---|
266 | |
---|
267 | if (pSD->feedbackWin) |
---|
268 | { |
---|
269 | /* Make sure the feedback window doesn't get buried */ |
---|
270 | XRaiseWindow(DISPLAY, pSD->feedbackWin); |
---|
271 | XMapWindow (DISPLAY, pSD->feedbackWin); |
---|
272 | PaintFeedbackWindow(pSD); |
---|
273 | } |
---|
274 | |
---|
275 | } /* END OF FUNCTION ShowFeedbackWindow */ |
---|
276 | |
---|
277 | |
---|
278 | |
---|
279 | /*************************************<->************************************* |
---|
280 | * |
---|
281 | * PaintFeedbackWindow(pSD) |
---|
282 | * |
---|
283 | * |
---|
284 | * Description: |
---|
285 | * ----------- |
---|
286 | * Repaints the feedback window in response to exposure events |
---|
287 | * |
---|
288 | * |
---|
289 | * Inputs: |
---|
290 | * ------ |
---|
291 | * pSD - pointer to screen data |
---|
292 | * |
---|
293 | * Outputs: |
---|
294 | * ------- |
---|
295 | * |
---|
296 | * |
---|
297 | * Comments: |
---|
298 | * -------- |
---|
299 | *************************************<->***********************************/ |
---|
300 | #ifdef _NO_PROTO |
---|
301 | void PaintFeedbackWindow (pSD) |
---|
302 | |
---|
303 | WmScreenData *pSD; |
---|
304 | #else /* _NO_PROTO */ |
---|
305 | void PaintFeedbackWindow (WmScreenData *pSD) |
---|
306 | #endif /* _NO_PROTO */ |
---|
307 | { |
---|
308 | if (pSD->feedbackWin) |
---|
309 | { |
---|
310 | /* |
---|
311 | * draw beveling |
---|
312 | */ |
---|
313 | if (pSD->fbTop->used > 0) |
---|
314 | { |
---|
315 | XFillRectangles (DISPLAY, pSD->feedbackWin, |
---|
316 | pSD->feedbackAppearance.inactiveTopShadowGC, |
---|
317 | pSD->fbTop->prect, pSD->fbTop->used); |
---|
318 | } |
---|
319 | if (pSD->fbBottom->used > 0) |
---|
320 | { |
---|
321 | XFillRectangles (DISPLAY, pSD->feedbackWin, |
---|
322 | pSD->feedbackAppearance.inactiveBottomShadowGC, |
---|
323 | pSD->fbBottom->prect, |
---|
324 | pSD->fbBottom->used); |
---|
325 | } |
---|
326 | |
---|
327 | /* |
---|
328 | * clear old text |
---|
329 | */ |
---|
330 | XClearArea (DISPLAY, pSD->feedbackWin, |
---|
331 | FEEDBACK_BEVEL, FEEDBACK_BEVEL, |
---|
332 | pSD->fbWinWidth-2*FEEDBACK_BEVEL, |
---|
333 | pSD->fbWinHeight-2*FEEDBACK_BEVEL, |
---|
334 | FALSE); |
---|
335 | |
---|
336 | /* |
---|
337 | * put up new text |
---|
338 | */ |
---|
339 | if (pSD->fbStyle & FB_POSITION) |
---|
340 | { |
---|
341 | WmDrawString (DISPLAY, pSD->feedbackWin, |
---|
342 | pSD->feedbackAppearance.inactiveGC, |
---|
343 | pSD->fbLocX, pSD->fbLocY, |
---|
344 | pSD->fbLocation, strlen(pSD->fbLocation)); |
---|
345 | } |
---|
346 | if (pSD->fbStyle & FB_SIZE) |
---|
347 | { |
---|
348 | WmDrawString (DISPLAY, pSD->feedbackWin, |
---|
349 | pSD->feedbackAppearance.inactiveGC, |
---|
350 | pSD->fbSizeX, pSD->fbSizeY, |
---|
351 | pSD->fbSize, strlen(pSD->fbSize)); |
---|
352 | } |
---|
353 | } |
---|
354 | } |
---|
355 | |
---|
356 | |
---|
357 | |
---|
358 | /*************************************<->************************************* |
---|
359 | * |
---|
360 | * HideFeedbackWindow (pSD) |
---|
361 | * |
---|
362 | * |
---|
363 | * Description: |
---|
364 | * ----------- |
---|
365 | * Hide the feedback window |
---|
366 | * |
---|
367 | * |
---|
368 | * Inputs: |
---|
369 | * ------ |
---|
370 | * pDS - pointer to screen data |
---|
371 | * |
---|
372 | * Outputs: |
---|
373 | * ------- |
---|
374 | * |
---|
375 | * |
---|
376 | * Comments: |
---|
377 | * -------- |
---|
378 | * |
---|
379 | *************************************<->***********************************/ |
---|
380 | #ifdef _NO_PROTO |
---|
381 | void HideFeedbackWindow (pSD) |
---|
382 | |
---|
383 | WmScreenData *pSD; |
---|
384 | #else /* _NO_PROTO */ |
---|
385 | void HideFeedbackWindow (WmScreenData *pSD) |
---|
386 | #endif /* _NO_PROTO */ |
---|
387 | { |
---|
388 | if (pSD->feedbackWin) |
---|
389 | { |
---|
390 | XUnmapWindow (DISPLAY, pSD->feedbackWin); |
---|
391 | #ifndef OLD_COLORMAP |
---|
392 | ForceColormapFocus (ACTIVE_PSD, ACTIVE_PSD->colormapFocus); |
---|
393 | #endif |
---|
394 | } |
---|
395 | pSD->fbStyle = FB_OFF; |
---|
396 | } |
---|
397 | |
---|
398 | |
---|
399 | |
---|
400 | |
---|
401 | /*************************************<->************************************* |
---|
402 | * |
---|
403 | * UpdateFeedbackInfo (pSD, x, y, width, height) |
---|
404 | * |
---|
405 | * |
---|
406 | * Description: |
---|
407 | * ----------- |
---|
408 | * Update the information in the feedback window |
---|
409 | * |
---|
410 | * |
---|
411 | * Inputs: |
---|
412 | * ------ |
---|
413 | * pSD - pointer to screen info |
---|
414 | * x - x-value |
---|
415 | * y - y-value |
---|
416 | * width - width value |
---|
417 | * height - height value |
---|
418 | * |
---|
419 | * |
---|
420 | * Outputs: |
---|
421 | * ------- |
---|
422 | * |
---|
423 | * |
---|
424 | * Comments: |
---|
425 | * -------- |
---|
426 | * |
---|
427 | *************************************<->***********************************/ |
---|
428 | #ifdef _NO_PROTO |
---|
429 | void UpdateFeedbackInfo (pSD, x, y, width, height) |
---|
430 | |
---|
431 | WmScreenData *pSD; |
---|
432 | int x, y; |
---|
433 | unsigned int width, height; |
---|
434 | #else /* _NO_PROTO */ |
---|
435 | void UpdateFeedbackInfo (WmScreenData *pSD, int x, int y, unsigned int width, unsigned int height) |
---|
436 | #endif /* _NO_PROTO */ |
---|
437 | { |
---|
438 | /* |
---|
439 | * Currently the feedback window must always be redrawn to (potentially) |
---|
440 | * repair damage done by moving the configuration outline. The feedback |
---|
441 | * repainting generally only needs to be done when the information |
---|
442 | * changes or the feedback window is actually overwritten by the |
---|
443 | * configuration outline. |
---|
444 | */ |
---|
445 | |
---|
446 | { |
---|
447 | pSD->fbLastX = x; |
---|
448 | pSD->fbLastY = y; |
---|
449 | pSD->fbLastWidth = width; |
---|
450 | pSD->fbLastHeight = height; |
---|
451 | |
---|
452 | UpdateFeedbackText (pSD, x, y, width, height); |
---|
453 | |
---|
454 | PaintFeedbackWindow(pSD); |
---|
455 | } |
---|
456 | } |
---|
457 | |
---|
458 | |
---|
459 | |
---|
460 | |
---|
461 | /*************************************<->************************************* |
---|
462 | * |
---|
463 | * UpdateFeedbackText (pSD, x, y, width, height) |
---|
464 | * |
---|
465 | * |
---|
466 | * Description: |
---|
467 | * ----------- |
---|
468 | * Update the information in the feedback strings |
---|
469 | * |
---|
470 | * |
---|
471 | * Inputs: |
---|
472 | * ------ |
---|
473 | * pSD - pointer to screen data |
---|
474 | * x - x-value |
---|
475 | * y - y-value |
---|
476 | * width - width value |
---|
477 | * height - height value |
---|
478 | * |
---|
479 | * |
---|
480 | * Outputs: |
---|
481 | * ------- |
---|
482 | * |
---|
483 | * |
---|
484 | * Comments: |
---|
485 | * -------- |
---|
486 | * |
---|
487 | *************************************<->***********************************/ |
---|
488 | #ifdef _NO_PROTO |
---|
489 | void UpdateFeedbackText (pSD, x, y, width, height) |
---|
490 | |
---|
491 | WmScreenData *pSD; |
---|
492 | int x, y; |
---|
493 | unsigned int width, height; |
---|
494 | #else /* _NO_PROTO */ |
---|
495 | void UpdateFeedbackText (WmScreenData *pSD, int x, int y, unsigned int width, unsigned int height) |
---|
496 | #endif /* _NO_PROTO */ |
---|
497 | { |
---|
498 | int direction, ascent, descent; |
---|
499 | XCharStruct xcs; |
---|
500 | |
---|
501 | if (pSD->fbStyle & FB_POSITION) |
---|
502 | { |
---|
503 | sprintf (pSD->fbLocation, "(%4d,%-4d)", x, y); |
---|
504 | XTextExtents(pSD->feedbackAppearance.font, pSD->fbLocation, |
---|
505 | strlen(pSD->fbLocation), &direction, &ascent, |
---|
506 | &descent, &xcs); |
---|
507 | pSD->fbLocX = (pSD->fbWinWidth - xcs.width)/2; |
---|
508 | } |
---|
509 | |
---|
510 | if (pSD->fbStyle & FB_SIZE) |
---|
511 | { |
---|
512 | sprintf (pSD->fbSize, "%4dx%-4d", width, height); |
---|
513 | XTextExtents(pSD->feedbackAppearance.font, pSD->fbSize, |
---|
514 | strlen(pSD->fbSize), &direction, &ascent, |
---|
515 | &descent, &xcs); |
---|
516 | pSD->fbSizeX = (pSD->fbWinWidth - xcs.width)/2; |
---|
517 | } |
---|
518 | } |
---|
519 | |
---|
520 | |
---|
521 | |
---|
522 | /*************************************<->************************************* |
---|
523 | * |
---|
524 | * static void |
---|
525 | * OkCB (w, client_data, call_data) |
---|
526 | * |
---|
527 | * |
---|
528 | * Description: |
---|
529 | * ----------- |
---|
530 | * QuestionBox Ok callback. |
---|
531 | * |
---|
532 | * |
---|
533 | * Inputs: |
---|
534 | * ------ |
---|
535 | * None. |
---|
536 | * |
---|
537 | * |
---|
538 | * Outputs: |
---|
539 | * ------- |
---|
540 | * None. |
---|
541 | * |
---|
542 | * |
---|
543 | * Comments: |
---|
544 | * -------- |
---|
545 | * None. |
---|
546 | * |
---|
547 | *************************************<->***********************************/ |
---|
548 | |
---|
549 | static void OkCB (w, client_data, call_data) |
---|
550 | |
---|
551 | Widget w; |
---|
552 | caddr_t client_data; |
---|
553 | caddr_t call_data; |
---|
554 | { |
---|
555 | WithdrawDialog (w); |
---|
556 | |
---|
557 | confirm_func[((WmScreenData *)client_data)->actionNbr] (False); |
---|
558 | |
---|
559 | wmGD.confirmDialogMapped = False; |
---|
560 | |
---|
561 | } /* END OF FUNCTION OkCB */ |
---|
562 | |
---|
563 | |
---|
564 | /*************************************<->************************************* |
---|
565 | * |
---|
566 | * static void |
---|
567 | * CancelCB (w, client_data, call_data) |
---|
568 | * |
---|
569 | * |
---|
570 | * Description: |
---|
571 | * ----------- |
---|
572 | * QuestionBox Cancel callback. |
---|
573 | * |
---|
574 | * |
---|
575 | * Inputs: |
---|
576 | * ------ |
---|
577 | * None. |
---|
578 | * |
---|
579 | * |
---|
580 | * Outputs: |
---|
581 | * ------- |
---|
582 | * None. |
---|
583 | * |
---|
584 | * |
---|
585 | * Comments: |
---|
586 | * -------- |
---|
587 | * None. |
---|
588 | * |
---|
589 | *************************************<->***********************************/ |
---|
590 | |
---|
591 | static void CancelCB (w, client_data, call_data) |
---|
592 | |
---|
593 | Widget w; |
---|
594 | caddr_t client_data; |
---|
595 | caddr_t call_data; |
---|
596 | { |
---|
597 | WithdrawDialog (w); |
---|
598 | |
---|
599 | wmGD.confirmDialogMapped = False; |
---|
600 | |
---|
601 | } /* END OF FUNCTION CancelCB */ |
---|
602 | |
---|
603 | |
---|
604 | |
---|
605 | /*************************************<->************************************* |
---|
606 | * |
---|
607 | * void |
---|
608 | * ConfirmAction (pSD,nbr) |
---|
609 | * |
---|
610 | * |
---|
611 | * Description: |
---|
612 | * ----------- |
---|
613 | * Post a QuestionBox and ask for confirmation. If so, executes the |
---|
614 | * appropriate action. |
---|
615 | * |
---|
616 | * |
---|
617 | * Inputs: |
---|
618 | * ------ |
---|
619 | * nbr = action number |
---|
620 | * pSD->screen |
---|
621 | * pSD->screenTopLevel |
---|
622 | * |
---|
623 | * |
---|
624 | * Outputs: |
---|
625 | * ------- |
---|
626 | * actionNbr = current QuestionBox widget index. |
---|
627 | * confirmW[actionNbr] = QuestionBox widget. |
---|
628 | * |
---|
629 | * |
---|
630 | * Comments: |
---|
631 | * -------- |
---|
632 | * |
---|
633 | *************************************<->***********************************/ |
---|
634 | |
---|
635 | #ifdef _NO_PROTO |
---|
636 | void ConfirmAction (pSD,nbr) |
---|
637 | |
---|
638 | WmScreenData *pSD; |
---|
639 | int nbr; |
---|
640 | #else /* _NO_PROTO */ |
---|
641 | void ConfirmAction (WmScreenData *pSD, int nbr) |
---|
642 | #endif /* _NO_PROTO */ |
---|
643 | { |
---|
644 | Arg args[8]; |
---|
645 | register int n; |
---|
646 | int x, y; |
---|
647 | Dimension width, height; |
---|
648 | Widget dialogShellW = NULL; |
---|
649 | XmString messageString; |
---|
650 | static XmString defaultMessageString = NULL; |
---|
651 | |
---|
652 | if (pSD->confirmboxW[nbr] == NULL) |
---|
653 | /* First time for this one */ |
---|
654 | { |
---|
655 | |
---|
656 | /* |
---|
657 | * Create a dialog popup shell with explicit keyboard policy. |
---|
658 | */ |
---|
659 | |
---|
660 | n = 0; |
---|
661 | XtSetArg(args[n], XmNx, (XtArgVal) |
---|
662 | (DisplayWidth (DISPLAY, pSD->screen)/2)); n++; |
---|
663 | XtSetArg(args[n], XmNy, (XtArgVal) |
---|
664 | (DisplayHeight (DISPLAY, pSD->screen)/2)); n++; |
---|
665 | XtSetArg(args[n], XtNallowShellResize, (XtArgVal) TRUE); n++; |
---|
666 | XtSetArg(args[n], XtNkeyboardFocusPolicy, (XtArgVal) XmEXPLICIT); n++; |
---|
667 | XtSetArg(args[n], XtNdepth, |
---|
668 | (XtArgVal) DefaultDepth(DISPLAY, pSD->screen)); n++; |
---|
669 | XtSetArg(args[n], XtNscreen, |
---|
670 | (XtArgVal) ScreenOfDisplay(DISPLAY, pSD->screen)); n++; |
---|
671 | |
---|
672 | dialogShellW = |
---|
673 | XtCreatePopupShell ((String) WmNfeedback, |
---|
674 | transientShellWidgetClass, |
---|
675 | pSD->screenTopLevelW, args, n); |
---|
676 | |
---|
677 | /* |
---|
678 | * Create a QuestionBox as a child of the popup shell. |
---|
679 | * Set traversalOn and add callbacks for the OK and CANCEL buttons. |
---|
680 | * Unmanage the HELP button. |
---|
681 | */ |
---|
682 | |
---|
683 | n = 0; |
---|
684 | XtSetArg(args[n], XmNdialogType, (XtArgVal) XmDIALOG_QUESTION); n++; |
---|
685 | XtSetArg(args[n], XmNmessageAlignment, (XtArgVal) XmALIGNMENT_CENTER); |
---|
686 | n++; |
---|
687 | XtSetArg(args[n], XmNtraversalOn, (XtArgVal) TRUE); n++; |
---|
688 | |
---|
689 | /* |
---|
690 | * In 1.2 confirmbox's widget name changed from the generic |
---|
691 | * WmNconfirmbox (ie. 'confirmbox') to a more descriptive name |
---|
692 | * so that each confirm dialog can be customized separately (e.g. |
---|
693 | * "Mwm*confirmRestart*messageString: restart it?"). |
---|
694 | */ |
---|
695 | |
---|
696 | pSD->confirmboxW[nbr] = |
---|
697 | XtCreateManagedWidget (confirm_widget[nbr], xmMessageBoxWidgetClass, |
---|
698 | dialogShellW, args, n); |
---|
699 | |
---|
700 | n = 0; |
---|
701 | XtSetArg(args[n], XmNmessageString, &messageString); n++; |
---|
702 | XtGetValues(pSD->confirmboxW[nbr], (ArgList) args, n); |
---|
703 | |
---|
704 | if (defaultMessageString == NULL) |
---|
705 | { |
---|
706 | defaultMessageString = XmStringCreateLtoR ("", |
---|
707 | XmFONTLIST_DEFAULT_TAG); |
---|
708 | } |
---|
709 | |
---|
710 | n = 0; |
---|
711 | |
---|
712 | /* |
---|
713 | * If the message string is the default, then put something |
---|
714 | * 'reasonable' in instead. |
---|
715 | */ |
---|
716 | |
---|
717 | if (XmStringCompare( messageString, defaultMessageString )) |
---|
718 | { |
---|
719 | XtSetArg(args[n], XmNmessageString, (XtArgVal) |
---|
720 | XmStringCreate(confirm_mesg[nbr], |
---|
721 | XmFONTLIST_DEFAULT_TAG)); n++; |
---|
722 | XtSetValues(pSD->confirmboxW[nbr], (ArgList) args, n); |
---|
723 | } |
---|
724 | |
---|
725 | n = 0; |
---|
726 | XtSetArg (args[n], XmNtraversalOn, (XtArgVal) TRUE); n++; |
---|
727 | XtSetArg (args[n], XmNhighlightThickness, |
---|
728 | (XtArgVal) CB_HIGHLIGHT_THICKNESS); n++; |
---|
729 | XtSetValues ( XmMessageBoxGetChild (pSD->confirmboxW[nbr], |
---|
730 | XmDIALOG_OK_BUTTON), args, n); |
---|
731 | XtSetValues ( XmMessageBoxGetChild (pSD->confirmboxW[nbr], |
---|
732 | XmDIALOG_CANCEL_BUTTON), args, n); |
---|
733 | XtAddCallback (pSD->confirmboxW[nbr], XmNokCallback, |
---|
734 | (XtCallbackProc) OkCB, |
---|
735 | (caddr_t)pSD); |
---|
736 | XtAddCallback (pSD->confirmboxW[nbr], XmNcancelCallback, |
---|
737 | (XtCallbackProc)CancelCB, (caddr_t)NULL); |
---|
738 | |
---|
739 | XtUnmanageChild |
---|
740 | (XmMessageBoxGetChild (pSD->confirmboxW[nbr], |
---|
741 | XmDIALOG_HELP_BUTTON)); |
---|
742 | |
---|
743 | XtRealizeWidget (dialogShellW); |
---|
744 | |
---|
745 | /* |
---|
746 | * Center the DialogShell in the display. |
---|
747 | */ |
---|
748 | |
---|
749 | n = 0; |
---|
750 | XtSetArg(args[n], XmNheight, &height); n++; |
---|
751 | XtSetArg(args[n], XmNwidth, &width); n++; |
---|
752 | XtGetValues (dialogShellW, (ArgList) args, n); |
---|
753 | |
---|
754 | x = (DisplayWidth (DISPLAY, pSD->screen) - ((int) width))/2; |
---|
755 | y = (DisplayHeight (DISPLAY, pSD->screen) - ((int) height))/2; |
---|
756 | n = 0; |
---|
757 | XtSetArg(args[n], XmNx, (XtArgVal) x); n++; |
---|
758 | XtSetArg(args[n], XmNy, (XtArgVal) y); n++; |
---|
759 | XtSetValues (dialogShellW, (ArgList) args, n); |
---|
760 | |
---|
761 | ManageWindow (pSD, XtWindow(dialogShellW), MANAGEW_CONFIRM_BOX); |
---|
762 | } |
---|
763 | else |
---|
764 | { |
---|
765 | ReManageDialog (pSD, pSD->confirmboxW[nbr]); |
---|
766 | } |
---|
767 | |
---|
768 | pSD->actionNbr = nbr; |
---|
769 | |
---|
770 | XFlush(DISPLAY); |
---|
771 | |
---|
772 | wmGD.confirmDialogMapped = True; |
---|
773 | |
---|
774 | } /* END OF FUNCTION ConfirmAction */ |
---|
775 | |
---|
776 | |
---|
777 | |
---|
778 | /*************************************<->************************************* |
---|
779 | * |
---|
780 | * ShowWaitState (flag) |
---|
781 | * |
---|
782 | * |
---|
783 | * Description: |
---|
784 | * ----------- |
---|
785 | * Enter/Leave the wait state. |
---|
786 | * |
---|
787 | * |
---|
788 | * Inputs: |
---|
789 | * ------ |
---|
790 | * flag = TRUE for Enter, FALSE for Leave. |
---|
791 | * |
---|
792 | * |
---|
793 | * Outputs: |
---|
794 | * ------- |
---|
795 | * None. |
---|
796 | * |
---|
797 | * |
---|
798 | * Comments: |
---|
799 | * -------- |
---|
800 | * None. |
---|
801 | * |
---|
802 | *************************************<->***********************************/ |
---|
803 | |
---|
804 | #ifdef _NO_PROTO |
---|
805 | void ShowWaitState (flag) |
---|
806 | |
---|
807 | Boolean flag; |
---|
808 | #else /* _NO_PROTO */ |
---|
809 | void ShowWaitState (Boolean flag) |
---|
810 | #endif /* _NO_PROTO */ |
---|
811 | { |
---|
812 | char *bits; |
---|
813 | char *maskBits; |
---|
814 | unsigned int width; |
---|
815 | unsigned int height; |
---|
816 | unsigned int xHotspot; |
---|
817 | unsigned int yHotspot; |
---|
818 | Pixmap pixmap; |
---|
819 | Pixmap maskPixmap; |
---|
820 | XColor xcolors[2]; |
---|
821 | |
---|
822 | if (!waitCursor) |
---|
823 | { |
---|
824 | #ifdef LARGECURSORS |
---|
825 | if (wmGD.useLargeCursors) |
---|
826 | { |
---|
827 | width = time32_width; |
---|
828 | height = time32_height; |
---|
829 | bits = (char *)time32_bits; |
---|
830 | maskBits = (char *)time32m_bits; |
---|
831 | xHotspot = time32_x_hot; |
---|
832 | yHotspot = time32_y_hot; |
---|
833 | } |
---|
834 | else |
---|
835 | #endif /* LARGECURSORS */ |
---|
836 | |
---|
837 | { |
---|
838 | width = time16_width; |
---|
839 | height = time16_height; |
---|
840 | bits = (char *)time16_bits; |
---|
841 | maskBits = (char *)time16m_bits; |
---|
842 | xHotspot = time16_x_hot; |
---|
843 | yHotspot = time16_y_hot; |
---|
844 | } |
---|
845 | |
---|
846 | pixmap = XCreateBitmapFromData (DISPLAY, |
---|
847 | DefaultRootWindow(DISPLAY), bits, |
---|
848 | width, height); |
---|
849 | |
---|
850 | maskPixmap = XCreateBitmapFromData (DISPLAY, |
---|
851 | DefaultRootWindow(DISPLAY), maskBits, |
---|
852 | width, height); |
---|
853 | |
---|
854 | xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(DISPLAY)); |
---|
855 | xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(DISPLAY)); |
---|
856 | |
---|
857 | XQueryColors (DISPLAY, |
---|
858 | DefaultColormapOfScreen(DefaultScreenOfDisplay |
---|
859 | (DISPLAY)), |
---|
860 | xcolors, 2); |
---|
861 | waitCursor = XCreatePixmapCursor (DISPLAY, pixmap, maskPixmap, |
---|
862 | &(xcolors[0]), &(xcolors[1]), |
---|
863 | xHotspot, yHotspot); |
---|
864 | XFreePixmap (DISPLAY, pixmap); |
---|
865 | XFreePixmap (DISPLAY, maskPixmap); |
---|
866 | } |
---|
867 | |
---|
868 | if (flag) |
---|
869 | { |
---|
870 | XGrabPointer (DISPLAY, DefaultRootWindow(DISPLAY), FALSE, |
---|
871 | 0, GrabModeAsync, GrabModeAsync, None, |
---|
872 | waitCursor, CurrentTime); |
---|
873 | XGrabKeyboard (DISPLAY, DefaultRootWindow(DISPLAY), FALSE, |
---|
874 | GrabModeAsync, GrabModeAsync, CurrentTime); |
---|
875 | } |
---|
876 | else |
---|
877 | { |
---|
878 | XUngrabPointer (DISPLAY, CurrentTime); |
---|
879 | XUngrabKeyboard (DISPLAY, CurrentTime); |
---|
880 | } |
---|
881 | |
---|
882 | } /* END OF FUNCTION ShowWaitState */ |
---|
883 | |
---|
884 | |
---|
885 | |
---|
886 | /*************************************<->************************************* |
---|
887 | * |
---|
888 | * InitCursorInfo () |
---|
889 | * |
---|
890 | * |
---|
891 | * Description: |
---|
892 | * ----------- |
---|
893 | * This function determines whether a server supports large cursors. It it |
---|
894 | * does large feedback cursors are used in some cases (wait state and |
---|
895 | * system modal state); otherwise smaller (16x16) standard cursors are used. |
---|
896 | * |
---|
897 | * Outputs: |
---|
898 | * ------- |
---|
899 | * wmGD.useLargeCusors = set to True if larger cursors are supported. |
---|
900 | * |
---|
901 | *************************************<->***********************************/ |
---|
902 | |
---|
903 | #ifdef _NO_PROTO |
---|
904 | void InitCursorInfo () |
---|
905 | |
---|
906 | #else /* _NO_PROTO */ |
---|
907 | void InitCursorInfo (void) |
---|
908 | #endif /* _NO_PROTO */ |
---|
909 | { |
---|
910 | unsigned int cWidth; |
---|
911 | unsigned int cHeight; |
---|
912 | |
---|
913 | wmGD.useLargeCursors = False; |
---|
914 | |
---|
915 | if (XQueryBestCursor (DISPLAY, DefaultRootWindow(DISPLAY), |
---|
916 | 32, 32, &cWidth, &cHeight)) |
---|
917 | { |
---|
918 | if ((cWidth >= 32) && (cHeight >= 32)) |
---|
919 | { |
---|
920 | wmGD.useLargeCursors = True; |
---|
921 | } |
---|
922 | } |
---|
923 | |
---|
924 | } /* END OF FUNCTION InitCursorInfo */ |
---|
925 | |
---|
926 | |
---|
927 | |
---|
928 | |
---|
929 | |
---|
930 | |
---|