Ejemplo n.º 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;
   }
Ejemplo n.º 2
0
x_wglwtwrsz()
{
   Dimension largeurMax, hauteurMax;
   Dimension largeurCourante, hauteurCourante;
   
   XGetWindowAttributes(wglDisp, wglWin, &wglWinAttr);
   w = wglWinAttr.width;
   h = wglWinAttr.height;
   largeurCourante = w;
   hauteurCourante = h;

   if (largeurCourante < hauteurCourante)
      largeurMax = hauteurCourante;
   else
      largeurMax = largeurCourante;

   if (hauteurCourante < largeurCourante)
      hauteurMax = largeurCourante;
   else
      hauteurMax = hauteurCourante;

   largeurMax = 150;
   hauteurMax = 150;
   while (w <= largeurMax && h <= hauteurMax)
      {
      x_wglmesagr(messageAgrandir[lng]);
      XtAppNextEvent(SuperWidget.contexte, &wglEvent); 
      XtDispatchEvent(&wglEvent);

      XGetWindowAttributes(wglDisp, wglWin, &wglWinAttr);
      w = wglWinAttr.width;
      h = wglWinAttr.height;
      } 
   }
Ejemplo n.º 3
0
/*
** Getting the current selection by making the request, and then blocking
** (processing events) while waiting for a reply.  On failure (timeout or
** bad format) returns NULL, otherwise returns the contents of the selection.
*/
char *GetAnySelection(WindowInfo *window)
{
    static char waitingMarker[1] = "";
    char *selText = waitingMarker;
    XEvent nextEvent;	 
    
    /* If the selection is in the window's own buffer get it from there,
       but substitute null characters as if it were an external selection */
    if (window->buffer->primary.selected) {
	selText = BufGetSelectionText(window->buffer);
	BufUnsubstituteNullChars(selText, window->buffer);
	return selText;
    }
    
    /* Request the selection value to be delivered to getAnySelectionCB */
    XtGetSelectionValue(window->textArea, XA_PRIMARY, XA_STRING,
	    (XtSelectionCallbackProc)getAnySelectionCB, &selText, 
	    XtLastTimestampProcessed(XtDisplay(window->textArea)));

    /* Wait for the value to appear */
    while (selText == waitingMarker) {
	XtAppNextEvent(XtWidgetToApplicationContext(window->textArea), 
		&nextEvent);
	ServerDispatchEvent(&nextEvent);
    }
    return selText;
}
Ejemplo n.º 4
0
void XETrapAppMainLoop(XtAppContext app, XETC *tc)
{
    XEvent event;
    XtInputMask imask;

    while (1)
    {
        imask = XETrapAppPending(app);
        /* Check to see what's going on so that we don't block
         * in either NextEvent or ProcessEvent since neither
         * of these routines can correctly deal with XTrap Events
         */
        if (imask & XtIMXEvent)
        {
            (void)XtAppNextEvent(app,&event);
            (void)XETrapDispatchEvent(&event,tc);
        }
        else if (imask & (XtIMTimer | XtIMAlternateInput))
        {
            XtAppProcessEvent(app, (XtIMTimer | XtIMAlternateInput));
        }
        else
        {   /* Nothing going on, so we need to block */
            (void)XETrapWaitForSomething(app);
        }
    }
}
Ejemplo n.º 5
0
// Wait until W is mapped
void wait_until_mapped(Widget w, Widget shell)
{
    XSync(XtDisplay(w), False);
    XmUpdateDisplay(w);

    if (shell == 0)
	shell = find_shell(w);

    if (XtIsRealized(w) && XtIsRealized(shell))
    {
  	XWindowAttributes attr;
	while (XGetWindowAttributes(XtDisplay(w), XtWindow(w), &attr)
	       && attr.map_state != IsViewable)
	{
	    if (XGetWindowAttributes(XtDisplay(shell), XtWindow(shell), &attr)
		&& attr.map_state != IsViewable)
		break;		// Shell is withdrawn or iconic

	    // Wait for exposure event
	    XEvent event;
	    XtAppNextEvent(XtWidgetToApplicationContext(w), &event);
	    XtDispatchEvent(&event);
	}
    }

    XSync(XtDisplay(w), False);
    XmUpdateDisplay(w);
}
Ejemplo n.º 6
0
int MwAlertBox(Widget pw, char *text, char *buttons[], int nbuttons)
{
	Widget topbox, buttonbox, label, command;
	int i;
	XtAppContext app_context = XtWidgetToApplicationContext(pw);

	alert = XtVaCreatePopupShell("alert",
		transientShellWidgetClass, pw,
		XtNtitle, _("Alert"),
		(char *)0);
	topbox = XtVaCreateManagedWidget("topbox",
		boxWidgetClass, alert, (char *)0);
	label = XtVaCreateManagedWidget("label",
		labelWidgetClass, topbox,
		(char *)0);
	MwLabelSet(label, text);
	buttonbox = XtVaCreateManagedWidget("buttonbox",
		boxWidgetClass, topbox, (char *)0);
	for (i = 0; i < nbuttons; i++) {
		command = add_button(buttonbox, "command", buttons[i],
			alert_clicked, (XtPointer)i);
	}
	status = MW_WAITING;
	MwCenter(alert);
	XtPopup(alert, XtGrabNonexclusive);
	wm_del(alert);
	while (status == MW_WAITING) {
		XEvent event_return;
		XtAppNextEvent(app_context, &event_return);
		XtDispatchEvent(&event_return);
	}
	XtDestroyWidget(alert);
	return status;
}
Ejemplo n.º 7
0
/*
 *	bXAUERelaxCallback
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	Callback to redisplay the UNIT every step of a minimization.
 *	Return TRUE to indicate that the minimization should continue.
 */
static BOOL
bXAUERelaxCallback( Widget wTank )
{
    XEvent		xeEvent;
    BOOL		bContinue;

    /* Redisplay the UNIT in the TANK */


    TankFastRedisplayUnit((TANK) wTank );

    /* If there is an event pending then handle it */

    bContinue = TRUE;
    while ( XtAppPending( SxtacApp ) ) {
        MESSAGE(( "There is an event pending\n" ));
        XtAppNextEvent( SxtacApp, &xeEvent );
        if ( bBasicsInterrupt() ) {
            bContinue = FALSE;
            BasicsResetInterrupt();
        }
        XtDispatchEvent( &xeEvent );
    }

    return(bContinue);
}
Ejemplo n.º 8
0
void XSilChessWindow::DoPainting()
{
	XEvent e;
	char * data;
	XImage * img;
	int i,y,msk;

	if (IsPainting) return;
	if (!ViewWin) return;
	IsPainting=true;
	y=0;
	while (NeedPainting) {
		NeedPainting=false;
		RT.SetWorld(Machine);
		data=(char*)malloc(PixelSize*ViewWidth+1000000);
		img=XCreateImage(Disp,Vsl,VslDepth,ZPixmap,0,data,
		                 ViewWidth,1,8*PixelSize,0);
		for (msk=0x3ff; msk<ViewHeight-1; msk=(msk<<1)|1);
		for (i=0, y%=ViewHeight; i<ViewHeight; i++) {
			while (XtAppPending(App)!=0) {
				XtAppNextEvent(App,&e);
				XtDispatchEvent(&e);
			}
			if (NeedPainting) break;
			RT.RenderScanline(y,data,PixelSize,RedMask,GreenMask,BlueMask);
			XPutImage(Disp,ViewWin,ViewGC,img,0,0,0,y,ViewWidth,1);
			if (i==ViewHeight-1 || (i&7)==0) PaintSel();
			do { y=(y+269779)&msk; } while (y>=ViewHeight);
		}
		PaintSel();
		XFree(img);
		free(data);
	}
	IsPainting=false;
}
Ejemplo n.º 9
0
int EZX_WaitForButtonIn(XtAppContext app_context,
			Widget widget, int *xp, int *yp)
{
  XEvent event;
  int button_was_pressed = FALSE;

  XtAddEventHandler(widget, ButtonPressMask, FALSE,
		    (XtEventHandler) do_nothing, NULL); 
  
  do {
    XtAppNextEvent(app_context, &event);
    if (event.type == ButtonPress) {
      button_was_pressed = TRUE;   
      theButtonEvent=event.xbutton;
    }
  } while (!button_was_pressed);
  
  /* Disable being able to press the mouse button over the bitmap */
  XtRemoveEventHandler(widget, ButtonPressMask, FALSE,
		       (XtEventHandler) do_nothing, NULL); 
  *xp = theButtonEvent.x;
  *yp = theButtonEvent.y;
  
  if (theButtonEvent.button == Button1) return(LEFT_BUTTON);
  else if (theButtonEvent.button == Button2) return(MIDDLE_BUTTON);
  else if (theButtonEvent.button == Button3) return(RIGHT_BUTTON);
  else return(OTHER_BUTTON);
}
Ejemplo n.º 10
0
void MessageErreur(char message[])
{
   XEvent avrtEvent;
   Arg args[2];
   XmString label;
   
   Xinit("xrec");
   if (errorWidget  == NULL)
      {
      errorWidget = (Widget) CreateErrorDialog(SuperWidget.topLevel);
      }
   
   label = XmStringCreateLtoR(message, XmSTRING_DEFAULT_CHARSET);
   XtSetArg(args[0], XmNmessageString, label);
   
   XtSetValues(errorWidget, args, 1);
   widgetCourant = errorWidget;
   
   XmStringFree(label);
   
   XtManageChild(errorWidget);
   FlusherTousLesEvenements();

   avrtSelectionTerminee = False;
   while (0 == 0)
      {
      XtAppNextEvent(SuperWidget.contexte, &(avrtEvent));
      XtDispatchEvent(&(avrtEvent));
      }
   }
Ejemplo n.º 11
0
/*******************************************************************************
          Name:        XclipsGetc
          Description: Get a character input from user
          Arguments:   log_name -
          Returns:       
*******************************************************************************/
int XclipsGetc(
  void *theEnv,
  char *log_name)
  {
   int quit = False;
   char ch[2];
   String str_list[1];
   int num = 1;
  
   ch[1] = 0;

   /* if unget_buf is not empty return the last character in the buf */

   if (char_counter > 0)
     { return(unget_buf[--char_counter]); }
     
   if (LogLookup(log_name) == NULL)
     { return(EOS); }
 
   while (! quit)
     {
      /* Get an event and if it is a legalimate (cahracter)key press */ 
      /* event print it to the main window, return the character     */
      /* (out of the while loop).                                    */
      /* else, dispatch the event and get another event              */

      XtAppNextEvent(app_con, &TheEvent); /* Get an event */
      XLookupString(&TheEvent.xkey, ch, 1, &TheKeysym, &compose_status);
      if ((TheEvent.type == KeyPress) &&
          (TheEvent.xproperty.window == dialog_text->core.window))
        {
         if ((TheKeysym >= XK_space) && (TheKeysym <= XK_asciitilde))
           {
            str_list[0] = ch;
            InsertClipsString(dialog_text, &TheEvent, str_list,(Cardinal *) &num);
            quit = True;
           }
         else if ((TheKeysym != XK_Linefeed) ? (TheKeysym == XK_Return) : TRUE)
           {
            ch[0] = NEWLINE;
            quit = True;
            XtDispatchEvent(&TheEvent);
           }
         else if ((TheKeysym != XK_Delete) ? (TheKeysym == XK_BackSpace) :TRUE)
           {
            if (RouterData(theEnv)->CommandBufferInputCount != 0)
              {
               ch[0] = BACKSPACE;
               quit = True;
               XtDispatchEvent(&TheEvent);
              }
           }
        }
      else
        { XtDispatchEvent(&TheEvent); }
     }
     
   return((int)ch[0]);
  }
Ejemplo n.º 12
0
/*
** Special event loop for NEdit servers.  Processes PropertyNotify events on
** the root window (this would not be necessary if it were possible to
** register an Xt event-handler for a window, rather than only a widget).
** Invokes server routines when a server-request property appears,
** re-establishes server-exists property when another server exits and
** this server is still alive to take over.
*/
void ServerMainLoop(XtAppContext context)
{
    while (TRUE) {
        XEvent event;
        XtAppNextEvent(context, &event);
        ServerDispatchEvent(&event);
    }
}
Ejemplo n.º 13
0
void xtwitter_xaw_loop(){
    //XtAppMainLoop(context);
    XEvent event;
    while(1){
        XtAppNextEvent(context, &event);
        XtDispatchEvent(&event);
    }
}
Ejemplo n.º 14
0
void
xevents(void)
{
	XEvent event;
	XtInputMask input_mask;
	register TScreen *screen = &term->screen;

	if(screen->scroll_amt)
		FlushScroll(screen);
	/*
	 * process timeouts, relying on the fact that XtAppProcessEvent
	 * will process the timeout and return without blockng on the
	 * XEvent queue.  Other sources i.e. the pty are handled elsewhere
	 * with select().
	 */
	while ((input_mask = XtAppPending(app_con)) & XtIMTimer)
		XtAppProcessEvent(app_con, XtIMTimer);
	/*
	 * If there's no XEvents, don't wait around...
	 */
	if ((input_mask & XtIMXEvent) != XtIMXEvent)
	    return;
	do {
		if (waitingForTrackInfo)
			return;
		XtAppNextEvent (app_con, &event);
		/*
		 * Hack to get around problems with the toolkit throwing away
		 * eventing during the exclusive grab of the menu popup.  By
		 * looking at the event ourselves we make sure that we can
		 * do the right thing.
		 */
		if(OUR_EVENT(event, EnterNotify))
		  DoSpecialEnterNotify (&event.xcrossing);
		else
		if(OUR_EVENT(event, LeaveNotify))
		  DoSpecialLeaveNotify (&event.xcrossing);
		else if ((screen->send_mouse_pos == ANY_EVENT_MOUSE
#if OPT_DEC_LOCATOR
			|| screen->send_mouse_pos == DEC_LOCATOR
#endif	/* OPT_DEC_LOCATOR */
								)
		 && event.xany.type == MotionNotify
		 && event.xcrossing.window == XtWindow(term)) {
		    SendMousePosition((Widget)term, &event);
		    continue;
		}

		if (!event.xany.send_event ||
		    screen->allowSendEvents ||
		    ((event.xany.type != KeyPress) &&
		     (event.xany.type != KeyRelease) &&
		     (event.xany.type != ButtonPress) &&
		     (event.xany.type != ButtonRelease)))
		    XtDispatchEvent(&event);
	} while ((input_mask = XtAppPending(app_con)) & XtIMXEvent);
}
Ejemplo n.º 15
0
void WNavMotif::message_dialog( char *title, char *text)
{
    Widget 	dialog;
    XmString	text_str;
    XmString	title_str;
    Arg		args[9];
    int		i;
    XEvent 	Event;

    text_str = XmStringCreateLocalized( wnav_dialog_convert_text(text));
    title_str = XmStringCreateLocalized( title);
    i = 0;
    XtSetArg( args[i], XmNmessageString, text_str);
    i++;
    XtSetArg( args[i], XmNdialogTitle, title_str);
    i++;
    XtSetArg( args[i], XmNdialogType, XmDIALOG_MESSAGE);
    i++;
    if ( dialog_width && dialog_height)
    {
        XtSetArg( args[i], XmNwidth, dialog_width);
        i++;
        XtSetArg( args[i], XmNheight, dialog_height);
        i++;
        XtSetArg( args[i], XmNx, dialog_x);
        i++;
        XtSetArg( args[i], XmNy, dialog_y);
        i++;
    }

    dialog = XmCreateInformationDialog( parent_wid, (char*) "Info", args, i);
    XmStringFree( text_str);
    XmStringFree( title_str);

    XtUnmanageChild( XmMessageBoxGetChild( dialog, XmDIALOG_HELP_BUTTON));
    XtUnmanageChild( XmMessageBoxGetChild( dialog, XmDIALOG_CANCEL_BUTTON));

    XtAddCallback( dialog, XmNokCallback, wnav_message_dialog_ok, this);

    // Connect the window manager close-button to exit
    flow_AddCloseVMProtocolCb( XtParent(dialog),
                               (XtCallbackProc)wnav_message_dialog_ok, this);

    XtManageChild( dialog);
    XtPopup( XtParent(dialog), XtGrabNone);

    dialog_ok = 0;

    for (;;)
    {
        XtAppNextEvent( XtWidgetToApplicationContext( dialog), &Event);
        XtDispatchEvent( &Event);
        if ( dialog_ok)
            return;
    }
}
Ejemplo n.º 16
0
Archivo: server.c Proyecto: rtoy/cmucl
void serve_client(int socket)
{
    XEvent event;

    XtToolkitInitialize();
    app_context = XtCreateApplicationContext();

    LispAction.string = "Lisp";
    LispAction.proc   = LispActionProc;
    XtAppAddActions(app_context, &LispAction, 1);

    string_token_tag = find_type_entry(ExtRStringToken);
    string_tag = find_type_entry(XtRString);
    xm_string_tag = find_type_entry(XmRXmString);
    enum_tag = find_type_entry(XtREnum);
    int_tag = find_type_entry(XtRInt);
    window_tag = find_type_entry(XtRWindow);
    boolean_tag = find_type_entry(XtRBoolean);
    widget_tag = find_type_entry(XtRWidget);
    function_tag = find_type_entry(XtRFunction);
    callback_reason_tag = find_type_entry(ExtRCallbackReason);
    event_tag = find_type_entry(ExtREvent);
    resource_list_tag = find_type_entry(ExtRResourceList);
    translation_table_tag = find_type_entry(XtRTranslationTable);
    accelerator_table_tag = find_type_entry(XtRAcceleratorTable);
    atom_tag = find_type_entry(XtRAtom);
    font_list_tag = find_type_entry(XmRFontList);
    string_table_tag = find_type_entry(XtRStringTable);
    xm_string_table_tag = find_type_entry(XmRXmStringTable);
    int_list_tag = find_type_entry(ExtRIntList);
    cursor_tag = find_type_entry(XtRCursor);

    client_socket = socket;
    greet_client(socket);

    XtAppAddInput(app_context, socket, (XtPointer)XtInputReadMask,
                  (XtInputCallbackProc)get_input, (XtPointer)NULL);

    XtAppSetErrorHandler(app_context, MyErrorHandler);
    XtAppSetWarningHandler(app_context, MyWarningHandler);

    /* Here is where we want to return on errors */
    if( setjmp(env) ) {
        printf("Attempting to recover from error.\n");
        fflush(stdout);
    }
    while( !terminate_server ) {
        XtAppNextEvent(app_context, &event);
        XtDispatchEvent(&event);
    }

    close(socket);
    XtDestroyApplicationContext(app_context);

    exit(0);
}
Ejemplo n.º 17
0
void InitGraphics(int argc, char *argv[])
{
    Dimension width, height;
    XEvent event;
    static String fallback_resources[] = {
        "*xcheck*background: #e0e0e0",
        "*xcheck*fontList: -*-helvetica-bold-r-normal--14-*-*-*-*-*-*-*",
        "*xcheck*font: -*-helvetica-bold-r-normal--14-*-*-*-*-*-*-*",
        "*xcheck*XmText.background:  #b0e0c0",
        NULL,
    };

    XtSetLanguageProc(NULL,NULL,NULL);
    toplevel = XtVaAppInitialize(
        &app,"App-Class",
        NULL,0,
        &argc,argv,
        fallback_resources,
        NULL);
    mainWidget = XtVaCreateManagedWidget("mw", xmMainWindowWidgetClass, toplevel, NULL);
    dpy = XtDisplay(mainWidget);
    gc = XCreateGC(dpy,DefaultRootWindow(dpy),(int)NULL,NULL);
    XSetLineAttributes(dpy,gc,2,LineSolid,CapButt,JoinMiter);
    colormap = CreateColorMap(mainWidget);
    menubar = CreateMenuBar(mainWidget);
    workwin = CreateWorkWin(mainWidget);
    message = CreateMessage(mainWidget);
    XtVaSetValues(mainWidget,
        XmNcolormap,colormap,
        XmNmenuBar,menubar,
        XmNworkWindow,workwin,
        XmNmessageWindow,message,
        NULL);
    XtRealizeWidget(toplevel);
    do {
        XtAppNextEvent(app,&event);
        XtDispatchEvent(&event);
    }
    while(event.type != Expose);

    XtVaGetValues(toplevel,XmNheight,&height,XmNwidth,&width,NULL);
    XtVaSetValues(toplevel,
        XmNwidth, width,
        XmNheight, height,
        XmNmaxWidth, width,
        XmNmaxHeight, height,
        XmNminWidth, width,
        XmNminHeight, height,
        XmNallowShellResize, False,
        NULL);
    HandleEvents();

    strcpy(xval[0],"human");
    strcpy(xval[1],"computer");
    strcpy(xval[2],"10.0");
}
Ejemplo n.º 18
0
void VkHypViewer::eventHandler(XEvent *event) {
  // may need to drain away events which occurred while HypView was busy
  int tossEvents = hv->getTossEvents();
  if (tossEvents) {
#ifdef HYPVK
    XtAppContext app = theApplication->appContext();
#else
    XtAppContext app = XtWidgetToApplicationContext (glxarea);
#endif
    XEvent e;
    while (XtAppPending(app)) {
      XtAppNextEvent(app, &e);     // just throw it away
      XtDispatchEvent(&e);
    }
    hv->setTossEvents(0);
    // if one of these ignored events was the rightmouse then 
    // Motif has already handed us input focus. must give it back! 
    XUngrabPointer(XtDisplay(glxarea), CurrentTime);
  }

  switch (event->type) {
  case ButtonPress:
  case ButtonRelease:
    hv->mouse(event->xbutton.button-1, 
	      event->xmotion.state&(Button1Mask|Button2Mask|Button3Mask),
	      event->xmotion.x, event->xmotion.y, 
	      event->xmotion.state&(ShiftMask), 
	      event->xmotion.state&(ControlMask)
	      );
    break;
  case MotionNotify:
    if (event->xmotion.state&(Button1Mask|Button2Mask|Button3Mask)) {
      hv->motion(event->xmotion.x, event->xmotion.y,
		 event->xmotion.state&(ShiftMask), 
		 event->xmotion.state&(ControlMask)
		 );
    } else {
      hv->passive(event->xmotion.x, event->xmotion.y,
		  event->xmotion.state&(ShiftMask), 
		  event->xmotion.state&(ControlMask)
		  );
    }
    break;
  case ConfigureNotify:
    hv->reshape(event->xconfigure.width, event->xconfigure.height);
    break;
  case Expose:
    hv->idle(1);
    hv->drawFrame();
    break;
  }
  // make the idle work right
  if (XtPending()) {
    hv->idle(0);
  }
}
Ejemplo n.º 19
0
void HandleEvents(void)
{
#ifdef GRAPHICS
    XEvent event;
    while(XtAppPending(app)) {
        XtAppNextEvent (app, &event); 
        XtDispatchEvent (&event);
    }
#endif
}
Ejemplo n.º 20
0
/* ---
Display a logo, a text and an OK button.
*/
void MwAboutBox(Widget pw, char *pixmap, char *message)
{
	Pixel color;
	Pixmap pm;
	Widget topbox, label, command, image;
	XtAppContext app_context = XtWidgetToApplicationContext(pw);

	XtVaGetValues(pw, XtNbackground, &color, (char *)0);
	pm = MwLoadPixmap(XtDisplay(pw), color, pixmap);
	alert = XtVaCreatePopupShell("about",
		transientShellWidgetClass, pw,
		XtNtitle, _("About"),
		XtNwidth, 400,
		XtNheight, 200,
		(char *)0);
	topbox = XtVaCreateManagedWidget("topbox",
		mwRudegridWidgetClass, alert,
		XtNxLayout, "4 80 4 50% 80 50% 4 80 4",
		XtNyLayout, "4 50% 80 50% 4 22 4",
		(char *)0);
	image = XtVaCreateManagedWidget("image",
		mwImageWidgetClass, topbox,
		XtNbitmap, pm,
		XtNgridx, 1,
		XtNgridy, 2,
		(char *)0);
	label = XtVaCreateManagedWidget("label",
		labelWidgetClass, topbox,
		XtNgridx, 3,
		XtNgridy, 1,
		XtNgridWidth, 7,
		XtNgridHeight, 3,
		(char *)0);
	MwLabelSet(label, message);

	command = XtVaCreateManagedWidget("command",
		commandWidgetClass, topbox,
		XtNgridx, 4,
		XtNgridy, 5,
		XtNlabel, "OK",
		XtNwidth, 80,
		(char *)0);
	XtAddCallback(command, XtNcallback, alert_clicked, 0);

	status = MW_WAITING;
	MwCenter(alert);
	XtPopup(alert, XtGrabNonexclusive);
	wm_del(alert);
	while (status == MW_WAITING) {
		XEvent event_return;
		XtAppNextEvent(app_context, &event_return);
		XtDispatchEvent(&event_return);
	}
	XtDestroyWidget(alert);
}
Ejemplo n.º 21
0
int GXDialog(Widget parent, char *msg, char *deft, char *buttons[],
	     int buttcnt, int DialType)
/*- 
  create and display a dialog, and wait for a response.  Implements its
  own event loop and does not return until there's a response or cancel.
 -*/
{
  Widget dial, DefaultButton;

  DialogDone = FALSE;

  dial = CreateDialog(parent, msg, deft, buttons, buttcnt, 
		      (XtCallbackProc)DialogCB, DialType); 
  /* display the dialog & wait for answer */
  /* moving the pointer to the window and back */
  {
    Window root, child;
    int root_x, root_y;
    int win_x, win_y;
    Dimension x, y, width, height;
    unsigned int mask;

    XQueryPointer(XtDisplay(toplevel), XtWindow(toplevel),
		  &root, &child,
		  &root_x, &root_y,
		  &win_x, &win_y,
		  &mask);
    XtVaGetValues(dial,
		  XmNdefaultButton, &DefaultButton,
		  NULL);
    if (DefaultButton) {

      XtVaGetValues(DefaultButton,
		    XmNwidth, &width,
		    XmNheight, &height,
		    XmNx, &x,
		    XmNy, &y,
		    NULL);

      XWarpPointer(XtDisplay(toplevel), 0, XtWindow(dial), 0, 0, 0, 0, x, y);
      while (DialogDone == FALSE) {
	static XEvent event;
	/*
	  XtAppProcessEvent(app_context, XtIMAll);
	  */
	XtAppNextEvent(app_context, &event);
	XtDispatchEvent(&event);
      }
      XWarpPointer(XtDisplay(toplevel), 0, XtWindow(toplevel), 0, 0,
		   0, 0, win_x, win_y); 
    }
    XtUnmanageChild(dial);
    return (DialogReturn);
  }
}
Ejemplo n.º 22
0
void XttMotif::xtt_mainloop (XtAppContext AppCtx)
{
  XEvent Event;

  for (;;) {
    XtAppNextEvent( AppCtx, &Event);
    if (Event.type != KeyPress || 
        TkSUCCESS != hotkey_Process( HotkeyHandle, &Event)) 
      XtDispatchEvent( &Event);
  }
}
Ejemplo n.º 23
0
void imagesc(void *data, int x, int y, const char* type,
             double (*transf)(double), const char **colormap, char *title)
{
  static XtAppContext context;
  Widget drawing_area;
  Widget toplevel;
  Atom wm_delete;
  XEvent event;
  XpmImage *xpmImage;
  Boolean exitFlag = False;
  static Display *display = NULL;
  Arg al[10];
  int ac;
  int argc = 0;

  xpmImage = CreateXpmImage(data, x, y, type, transf, colormap);

  /* create the toplevel shell */
  XtToolkitInitialize();
  if (display == NULL) {
    context = XtCreateApplicationContext();
    display = XtOpenDisplay(context, NULL, NULL, "", NULL, 0, &argc, NULL);
  }
  toplevel =XtAppCreateShell(title, "", applicationShellWidgetClass, display, NULL, 0);

  /* set window size. */
  ac=0;
  XtSetArg(al[ac],XmNmaxWidth,  x); ac++;
  XtSetArg(al[ac],XmNmaxHeight, y); ac++;
  XtSetArg(al[ac],XmNminWidth,  x); ac++;
  XtSetArg(al[ac],XmNminHeight, y); ac++;
  XtSetArg(al[ac],XmNdeleteResponse, XmDO_NOTHING); ac++;
  XtSetValues(toplevel,al,ac);

  ac=0;
  drawing_area=XmCreateDrawingArea(toplevel,"drawing_area",al,ac);
  XtManageChild(drawing_area);
  XtAddCallback(drawing_area,XmNexposeCallback,draw_pixmap,(XtPointer) xpmImage);
  XtAddEventHandler(drawing_area, KeyReleaseMask, false, KeyAction, (XtPointer) &exitFlag);
  XtRealizeWidget(toplevel);
  wm_delete = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False);
  XmAddWMProtocolCallback(toplevel, wm_delete, quitCB, (XtPointer) &exitFlag);
  XmActivateWMProtocol(toplevel, wm_delete);

  while (!exitFlag) {
    XtAppNextEvent(context, &event);
    XtDispatchEvent(&event);
  }

  XtDestroyWidget(drawing_area);
  XtDestroyWidget(toplevel);
  free(xpmImage);
}
Ejemplo n.º 24
0
int UIInquireVector(Widget widget, XEvent *event, int x0, int y0, int *x1, int *y1) {
    XSetWindowAttributes xswa;
    XGCValues xgcv;
    static GC gc = (GC) NULL;
    static Cursor cursor[2] = {(Cursor) NULL, (Cursor) NULL};
    static int inLoop, cont, ret;

    if (cursor[0] == (Cursor) NULL) cursor[0] = XCreateFontCursor(XtDisplay(widget), XC_hand2);
    if (cursor[1] == (Cursor) NULL) cursor[1] = XCreateFontCursor(XtDisplay(widget), XC_top_left_arrow);
    if (gc == (GC) NULL) {
        xgcv.function = GXinvert;
        gc = XtGetGC(widget, GCFunction, &xgcv);
    }
    if (inLoop == false) {
        if (event->type != ButtonPress) return (false);
        inLoop = cont = true;
        ret = false;
        xswa.cursor = cursor[0];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        *x1 = event->xbutton.x;
        *y1 = event->xbutton.y;
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        do {
            XtAppNextEvent(UIApplicationContext(), event);
            XtDispatchEvent(event);
        } while (cont);
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        xswa.cursor = cursor[1];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        inLoop = false;
        return (ret);
    }
    else
        switch (event->type) {
            case ButtonRelease:
                xswa.cursor = cursor[1];
                XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
                ret = true;
                cont = false;
                break;
            case MotionNotify:
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                *x1 = event->xmotion.x;
                *y1 = event->xmotion.y;
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                break;
            case LeaveNotify:
                ret = false;
                cont = false;
                break;
        }
    return (false);
}
Ejemplo n.º 25
0
Archivo: flush.c Proyecto: armnlib/xrec
FlusherTousLesEvenements()
{
   XEvent theEvent;
   
   while (XtAppPending(SuperWidget.contexte))
      {
      XtAppNextEvent(SuperWidget.contexte, &(theEvent));
      XtDispatchEvent(&(theEvent));
      }

   XFlush(XtDisplay(SuperWidget.topLevel)); 
   XSync(XtDisplay(SuperWidget.topLevel), False);
   }
Ejemplo n.º 26
0
void WNavMotif::wge_subwindow_loop( WGe *wge)
{
    XEvent 	Event;

    for (;;) {
        XtAppNextEvent( XtWidgetToApplicationContext( parent_wid), &Event);
        XtDispatchEvent( &Event);

        if ( wge->subwindow_release) {
            wge->subwindow_release = 0;
            break;
        }
    }
}
Ejemplo n.º 27
0
static void
mf_events ()
{
  XEvent event;

  if (XtAppPending (mf_app) != 0)
    {
      while (XtAppPending (mf_app) != 0)
	{
	  XtAppNextEvent (mf_app, &event);
	  XtDispatchEvent (&event);
	}
    }
}
Ejemplo n.º 28
0
void TutorApplication::handleEvents()
{
    XEvent event;


    //
    // Process events while the application is running.
    //
    while (TRUE)
    {
	XtAppNextEvent(this->applicationContext, &event);
	this->handleEvent(&event);
    }
}
Ejemplo n.º 29
0
Archivo: ssX.c Proyecto: q3k/ski
void cmdLoopX(void)
{
    /* eclipse - replace XtAppMainLoop so that we can temporarily    */
    /* disable event processing (when we return from emulated code), */
    /* and reenable the ui when we enter emulated code again         */
    /* XtAppMainLoop(app_context); */

    XEvent Event;
    while( keepXLoopAlive || !getExited() ) {
	// Get event
	XtAppNextEvent(app_context, &Event);
	// Send non-intercepted events to their respective widgets.
	XtDispatchEvent(&Event);
    }
}
Ejemplo n.º 30
0
void WNavMotif::wge_modal_loop( WGe *wge)
{
    XEvent 	Event;

    for (;;) {
        XtAppNextEvent( XtWidgetToApplicationContext( parent_wid), &Event);
        XtDispatchEvent( &Event);

        if ( wge->terminated) {
            appl.remove( (void *)wge);
            delete wge;
            break;
        }
    }
}