Hi,
this does not work because the window does not exist yet; it is only created once you start the event loop.

A possible solution is to do your drawing right after initialization.
First, you must include a single-shot callback handler with a timeout of zero:
    lite_enqueue_window_timeout( 0, timeoutfunc, lite_box, 0);

Then, in the callback handler, you can do the drawing like so:
DFBResult timeoutfunc(void *data)
{
    LiteBox *lite_box = data;
    IDirectFBSurface *test=lite_box->surface;
    test->SetColor(test,155,155,155,255);
    test->FillRectangle(test,10,10,260,160);
    lite_draw_box(lite_box, 0, true);
    return DFB_OK;
}

And then you can call the event loop:
    lite_window_event_loop( window, 0 );

note that will not be permanent, since the box will simply CLEAR itself on any redraw.
The correct solution is to overrule the box->Draw function like so:
    lite_box->Draw = drawfunc;

and then have a drawfunc like this:
DFBResult drawfunc( struct _LiteBox *lite_box, const DFBRegion *region, DFBBoolean clear)
{
    IDirectFBSurface *test=lite_box->surface;
    test->SetColor(test,155,155,155,255);
    test->FillRectangle(test,10,10,260,160);
    return DFB_OK;
}

hth,
Niels

Tu Duong Manh wrote:
Hi,
i have changed the code of checktest.c . I have got one LiteWindow,LiteBox and 
just
want  to display the LiteBox in LiteWindow with another color. But it does not 
work.
I can only see the empty LiteWindow. For help, i would be grateful.

Regards Tu

#include <config.h>
#include <stddef.h>
#include <lite/lite.h>
#include <lite/window.h>
#include <lite/util.h>
#include <leck/textbutton.h>
#include <leck/check.h>

int main (int argc, char *argv[])
{
LiteWindow     *window;
DFBRectangle    rect;
DFBResult       res;
LiteBox *lite_box;

if (lite_open( &argc, &argv ))
return 1;

/* create a window */
rect.x = LITE_CENTER_HORIZONTALLY;
rect.y = LITE_CENTER_VERTICALLY;
rect.w = 260;
rect.h = 160;

lite_new_window( NULL,&rect,DWCAPS_ALPHACHANNEL,liteDefaultWindowTheme,"Check 
Test",&window );
lite_new_box(&lite_box,LITE_BOX(window), 0,0,50,50);
IDirectFBSurface *test=lite_box->surface;

test->SetColor(test,155,155,155,255);
test->FillRectangle(test,10,10,260,160);
test->Flip(test,NULL,0);

lite_set_window_opacity( window, liteFullWindowOpacity );
lite_window_event_loop( window, 0 );

return 0;
}

____________________________________________________________
Text: GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de

_______________________________________________
LiTE mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/lite



--

.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/                 |
"------------------------------------------"
_______________________________________________
LiTE mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/lite

Reply via email to