I'll just chime in with a note about performance.
The correct way to do an event loop is something like.

 while(1) {

    expose = FALSE;

    while(XPending(display)) {
        XNextEvent(display, &event);
        switch(event.type) {
        case Expose:  expose = TRUE;
                      break;
        [...]
        }
    }

    if(expose) {
        HandleExpose();
    }

 }

 You will get many expose, move, etc... events in a row.  If there are
several pending, you do not want to redraw many times, but only once.
Also, note that you get an expose event for each rectangle exposed.
If you're not optimizing on an individual rect by rect basis (most
people don't) you want to throw away all XExposeEvent with non-zero
counts.  eg:

      case Expose:  if(!event.xexpose.count)
                        expose = TRUE;
                    break;

   As for determining if the mouse is over the widget, tracking
motion events is usually not a good idea.  Since a widget is a
window (or at least it should be), you just want to get XCrossingEvent
events (ie, EnterNotify and LeaveNotify).

   Also, if you have static artwork (stuff that doesn't change) you
might want to consider setting it as the window background rather
than getting expose events and having to redraw it.  If a pixmap
is set as a window background, the server will automatically expose
the area with the contents of the pixmap.

                        Mark.


On Wed, 9 Jul 2003, [iso-8859-1] anonymous wrote:

> Hi, I'm trying to develop a widget, which is a
> Textfield, a c++ class with label and textbox, you can
> see a simple screenshot here:
> 
> http://www10.brinkster.com/repos/screenshot.jpg
> 
> My question is, instead to do this:
> 
>       while(1)
>         {
>                 XNextEvent(display, &event);
>                 switch(event.type)
>                 {
>                       case Expose:
>                               gui.TextBox(display, ve
> 
> This is, a loop, because, for every widget I sould
> have a bounding box for every one working over
> MotionNotify Event, in order to see if mouse is or not
> over my widget, same for ButtonPress for if you click
> over the widget, how is done this usually?, does know
> any one a little example I'm trying to do?, I've been
> looking into gtk sources (too much difficult for me),
> also I've downloaded EZ widgets (a toolkit developed
> in c) sited here:
> 
> http://www.ma.utexas.edu/~mzou/EZWGL/
> 
> But I can't understand how he do it, so, could anyone
> tell me somthing about? thanks,
> 
> Regards,
> 
> 
> ___________________________________________________
> Yahoo! Messenger - Nueva versión GRATIS
> Super Webcam, voz, caritas animadas, y más...
> http://messenger.yahoo.es
> _______________________________________________
> Devel mailing list
> [EMAIL PROTECTED]
> http://XFree86.Org/mailman/listinfo/devel
> 


_______________________________________________
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel

Reply via email to