[cairo] looking for critic/advice

First Last begre1929 at yahoo.com
Wed May 22 16:16:10 PDT 2013


Hi guys,
I try to writte a small clock application in C. I have 3 files yet, functions.h, functions.c, main.c. I'm using a structure wich contains a cairo_tand a cairo_surface_tthat I need to update during the running of the application. For having this I'm using a structure defined in function.h, I'm a little suspicious about how I use this structure, I do some cast ( (*_mc)) but I'm not sure that's well written, (I never written something so funky...), could you just take a look and told me if it's correct. gcc doesn't complains, and I don't get any runtime error, so I'm just looking for a critic or an advice.

functions.hhas :

<...>
typedef struct clockStruc{
        cairo_t                 *c;
        cairo_surface_t         *s;

}CLOCKSTRUC;

<...>

functions.c has :

<...>
#include<cairo.h>
#include<cairo-xlib.h>
#include<time.h>

#include"functions.h"
<...>

void cairoClock(CLOCKSTRUC *_mc, <...> , int _x, int _y, int _sizex, int _sizey){
        <...>

        (* _mc).s=cairo_xlib_surface_create(_dpy, wpnl, DefaultVisual(_dpy, 0), _sizex, _sizey);
        (* _mc).c=cairo_create((*_mc).s);

        cairo_rectangle((*_mc).c,0,0,_sizex,_sizey);
        cairo_set_source_rgba((*_mc).c, 0.5, 0., 0., 1.); // nicoo : rouge, temporaire....
        cairo_fill((*_mc).c);
}

<...>

main.c has :

<...>

#include"functions.h"
<...>

int main(int argc, char *argv[]){
        <...>

        CLOCKSTRUC myClock;

        <...>

        cairoClock(&myClock, dpy,scr,panelv,5,5,BAR2X-10,34);
        <...>
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130522/b8fcd5d1/attachment.html>


More information about the cairo mailing list