> Matthias Melcher schrieb:
> >
> > Use fl_transform_x() and fl_transform_y() to get the screen position for 
> > the drawing. These function transform drawing coordinates into screen 
> > coordinates. If you need to know the scale, use fl_transform_dx() and 
> > fl_transform_dy().
>
> Oh, yes, that was the missing part of the puzzle ;-P
>
> And here it is:
>
> static void drawQuit(Fl_Color c) {
>
>       static Fl_PNG_Image *i = 0;
>       if (!i) i = new Fl_PNG_Image("icon.png");
>
>       int x = (int)fl_transform_x(0,0) - i->w()/2;
>       int y = (int)fl_transform_y(0,0) - i->h()/2;
>
> #if DRAW_BG
>       fl_color(FL_WHITE);             // bg color
>       fl_rectf(x,y,i->w(),i->h());    // draw bg
> #endif
>       i->draw(x,y);   // draw image
>       fl_color(c);    // (re)set color
> }
>
> One thing to note is that the symbol's origin (0,0) is
> centered, thus the correction after fl_transform_*().
>
> Works nice. But can't rotate and scale the symbol, as all the
> other symbol drawings can do. ;-)
>
> Albrecht
Thank you all for your help :p. Another question though, what is use of

> #if DRAW_BG
>       fl_color(FL_WHITE);             // bg color
>       fl_rectf(x,y,i->w(),i->h());    // draw bg
> #endif

There is no difference when removing it.
thanks
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to