Re: Threads ?:(



Message: 3
Date: Sat, 19 Nov 2005 17:36:48 +0100 (CET)
From: congo imafexbb sk
Subject: Threads ?:(
To: gtkmm-list gnome org
Message-ID: <45583 192 168 1 220 1132418208 squirrel mail imafexbb sk>
Content-Type: text/plain;charset=iso-8859-2

Hi,
  i had problems with images.Now it's fine . But now i got the problem.I
have myDrawingArea :) but when i want to display images in sequence and
each after a second  i can't. It is true that i tried it wrong but how
to do it ? I tried the sleep() function but it it definitelly wrong :)
How does it work in gtkmm please.
        Jan Vongrej

I don't know how you implemented it, but if I were to try to get it to work quick and dirty:

Create an integer in the private area of the class, set it to 0 in the constructor. Use a switch in the on_expose_event(GdkEventExpose* /* event */) function to determine which image to load. Incriment the integer. Do a sleep(1) for a 1 second sleep and then run queue_draw() to force a run of on_expose_event() again. I don't know what the outcome would be of an expose event occuring during the sleep(). You could use a boolean value to control whether or not the integer incriments as a safety against the integer incrimenting when you don't want it to.

Ex:

int count=0;
bool up=true;

on_expose_event()
{
    switch(count)
    {
         case 1:
         {
               . . .
         }
         .
         .
         .
         default:
    }

    if(up)
    {
         up=false;
         sleep(1);
         up=true;
         queue_draw();
    }
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]