Beispiel #1
0
int  MessageAvertissementAux(char *message, int typeMessage, Widget widgetMessage, Widget widgetParent)
{
   Widget avrtWidgetParent;
   XEvent avrtEvent;
   Arg args[2];
   XmString label;

   label = XmStringCreateLtoR(message, XmSTRING_DEFAULT_CHARSET);
   XtSetArg(args[0], XmNmessageString, label);
   
   XtSetValues(widgetMessage, args, 1);
   widgetCourant = widgetMessage;

   XmStringFree(label);

   avrtSelectionTerminee = False;
   
   AjusterPositionForme(widgetCourant, widgetParent);

   XtManageChild(widgetCourant);
   FlusherTousLesEvenements();
   CheckColormap(widgetCourant);

   while (!avrtSelectionTerminee)
      {
      XtAppPeekEvent(SuperWidget.contexte, &(avrtEvent));
      switch(avrtEvent.type)
         {
         case ButtonPress:
         avrtWidgetParent =(Widget) TrouverWidgetParent(avrtEvent.xbutton.window);
         if (avrtWidgetParent == widgetParent)
            {
            XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
            XtDispatchEvent(&(avrtEvent));
            }
         else
            {
            XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
            }
         break;
         
         default:
         XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
         XtDispatchEvent(&(avrtEvent));
         break;
         }

      }
   return okCancel;
   }
Beispiel #2
0
/*
** PopDownBugPatch
**
** Under some circumstances, popping down a dialog and its parent in
** rapid succession causes a crash.  This routine delays and
** processs events until receiving a ReparentNotify event.
** (I have no idea why a ReparentNotify event occurs at all, but it does
** mark the point where it is safe to destroy or pop down the parent, and
** it might have something to do with the bug.)  There is a failsafe in
** the form of a ~1.5 second timeout in case no ReparentNotify arrives.
** Use this sparingly, only when real crashes are observed, and periodically
** check to make sure that it is still necessary.
*/
void PopDownBugPatch(Widget w)
{
    time_t stopTime;

    stopTime = time(NULL) + 1;
    while (time(NULL) <= stopTime) {
    	XEvent event;
    	XtAppContext context = XtWidgetToApplicationContext(w);
    	XtAppPeekEvent(context, &event);
    	if (event.xany.type == ReparentNotify)
    	    return;
    	XtAppProcessEvent(context, XtIMAll);
    }
}
Beispiel #3
0
int MessageAvertissement(char *message, int typeMessage)
{   XEvent avrtEvent;
   Arg args[2];
   XmString label;
   Widget avrtWidgetParent;

   label = XmStringCreateLtoR(message, XmSTRING_DEFAULT_CHARSET);
   XtSetArg(args[0], XmNmessageString, label);
   
   switch(typeMessage)
      {
      case INFO:
      XtSetValues(infoWidget, args, 1);
      widgetCourant = infoWidget;
      break;
      
      case AVERTISSEMENT:
      XtSetValues(avrtWidget, args, 1);
      widgetCourant = avrtWidget;
      break;
      
      case OK_CANCEL:
      XtSetValues(okCancelWidget, args, 1);
      widgetCourant = okCancelWidget;
      break;
      }
   
   XmStringFree(label);
   
   avrtSelectionTerminee = False;
   
   DesactiverWidgetsControle();
   AjusterPositionForme(widgetCourant, xc.topLevel);
   
   XtManageChild(widgetCourant);
   FlusherTousLesEvenements();

   CheckColormap(widgetCourant);

   while (!avrtSelectionTerminee)
      {
      XtAppPeekEvent(SuperWidget.contexte, &(avrtEvent));
      switch(avrtEvent.type)
         {
         case ButtonPress:
         avrtWidgetParent =(Widget) TrouverWidgetParent(avrtEvent.xbutton.window);
         if (avrtWidgetParent == xc.topLevel)
            {
            XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
            XtDispatchEvent(&(avrtEvent));
            }
         else
            {
            XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
            }
         break;
         
         default:
         XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
         XtDispatchEvent(&(avrtEvent));
         break;
         }
      
      }
   ActiverWidgetsControle();
   return okCancel;
 
  }