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