iPodLinux

Stretching the iPod to its limits.
It is currently Sat Nov 21, 2009 12:50 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: pz_widget_set_timer
PostPosted: Wed Nov 04, 2009 8:43 pm 
Offline

Joined: Thu Dec 25, 2008 11:28 pm
Posts: 10
I finally got podzilla building, and now I've ran into yet another problem.
I'm probably missing something but pz_widget_set_timer() doesn't seem to work..

Here's some of my functions:
Code:
//Init window function
PzWindow *new_ifsg_window()
{
    g_moving_y = 25;

    window = pz_new_window ("FSG", PZ_WINDOW_FULLSCREEN);
    pz_widget_set_timer(pz_add_widget (window, draw_ifsg, event_ifsg), 100);
    return pz_finish_window (window);
}

//Draw window function
void draw_ifsg (PzWidget *wid, ttk_surface srf)
{
    ttk_fillrect (srf, 0, 20, ttk_screen->w, ttk_screen->h, ttk_makecol(BLACK));

    /*
    #define MSG "Press a button to quit."
    ttk_text (srf, ttk_menufont, wid->x + (wid->w - ttk_text_width (ttk_menufont, MSG)) / 2,
         wid->y + wid->h - ttk_text_height (ttk_menufont) - 5, ttk_makecol (WHITE), MSG);
    */

    ttk_line (srf, wid->x + 5, g_moving_y, wid->x + 5, g_moving_y, ttk_makecol (0, 255, 0));
   
    g_moving_y ++;
}

Is this supposed to make draw_ifsg loop once a second?


Top
 Profile E-mail  
 
 Post subject: Re: pz_widget_set_timer
PostPosted: Sun Nov 08, 2009 7:34 am 
Offline
User avatar

Joined: Wed Oct 08, 2008 3:59 pm
Posts: 39
Location: Australia
roadkillguy wrote:
Here's some of my functions:
Code:
[...]

Is this supposed to make draw_ifsg loop once a second?


All events aside from the draw event are delegated to the event function you specify in pz_add_widget. To request a redraw, simply set the PzWidget's dirty member to some non-zero value. For example:

Code:
static int g_moving_y;

int event_ifsg (PzEvent *ev)
{
    int ret = 0;
    switch(ev->type) {
        case PZ_EVENT_TIMER:
            g_moving_y++;
            /* mark widget as dirty to instigate a redraw */
            ev->wid->dirty = 1;
            break;

        /* other handlers go here */
        default:
            ret |= TTK_EV_UNUSED;
    }
    return ret;
}

void draw_ifsg (PzWidget *wid, ttk_surface srf)
{
    ttk_fillrect (srf, 0, 20, ttk_screen->w, ttk_screen->h, ttk_makecol(BLACK));

    /*
    #define MSG "Press a button to quit."
    ttk_text (srf, ttk_menufont, wid->x + (wid->w - ttk_text_width (ttk_menufont, MSG)) / 2,
         wid->y + wid->h - ttk_text_height (ttk_menufont) - 5, ttk_makecol (WHITE), MSG);
    */

    ttk_line (srf, wid->x + 5, g_moving_y, wid->x + 5, g_moving_y, ttk_makecol (0, 255, 0));
}

PzWindow *new_ifsg_window()
{
    g_moving_y = 25;

    window = pz_new_window ("FSG", PZ_WINDOW_FULLSCREEN);
    pz_widget_set_timer(pz_add_widget (window, &draw_ifsg, &event_ifsg), 100);
    return pz_finish_window (window);
}


Top
 Profile E-mail  
 
 Post subject: Re: pz_widget_set_timer
PostPosted: Mon Nov 09, 2009 8:52 pm 
Offline

Joined: Thu Dec 25, 2008 11:28 pm
Posts: 10
Oh ok, that makes sense.


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group