Dear Ian,
thanks for your help!
Concerning the irregular clipping: I've seen that with xlib is possible to 
define clipping based on a Region of any shape.
Do you think it is possible to directly use xlib clipping? And how to build up 
a Region?
Thank you!

Alessio

>


> > 1 - Is there any way to fill complex polygons with image=20
> > patterns? (or, as an alternative, is there any way to define=20
> > non rectangular clipping?)
>
> Not as such - you can easily fill a rectangular area using the
> Fl_Tiled_Image() class, but irregular polygons we don't really support,
> either as a surface or as clipping.
>
> Though there have been patches in the past to support it, I do not think
> there is anything in any of the current main-line versions.
>
> What I'd do is render the fill into an offscreen then use a barn-door
> mask to get the polygon, but that's a bit of work, so may not suit your
> needs.
>
> Others may have more practical solutions!
>
>
> > 2 - How can I resize only the width of fonts characters?
>
> Hmm, this was asked a while back, maybe June of last year? It's not
> something we really support, though at the time I posted a hack demo of
> how it can be done, albeit a bit crude.
>
> OK, found it, here's the example.
> You can maybe take some ideas from this then do a better job!
>
> ---------
> // fltk-config --compile text-scale.cxx
> #include <stdlib.h>
> #include <stdio.h>
>
> #include <FL/Fl.H>
> #include <FL/x.H>
> #include <FL/Fl_Double_Window.H>
> #include <FL/Fl_Box.H>
> #include <FL/Fl_Shared_Image.H>
> #include <FL/fl_draw.H>
>
> #include <FL/math.h>
>
> void draw_offscreen();
>
> static Fl_Offscreen offscreen_cxt =3D NULL;
> static Fl_Double_Window *main_win =3D NULL;
> static char message[64];
> static int scale =3D 1;
>
> class scope_view: public Fl_Box
> {
>   void draw();
> public:
>   scope_view(int x, int y,int w,int h, const char *l=3D0) :
> Fl_Box(x,y,w,h,l) {}
> };
>
> void scope_view::draw()
> {
>   int wd =3D w();
>   int ht =3D h();
>   int xo =3D x();
>   int yo =3D y();
>
>   if(offscreen_cxt){
>     fl_copy_offscreen(xo, yo, wd, ht, offscreen_cxt, 0, 0);
>   }
>   else {
>     fl_color(FL_GRAY);
>     fl_rectf(xo, yo, wd, ht);
>     draw_offscreen();
>   }
>
> } /* end of draw() method */
>
> static scope_view *scope =3D 0;
>
> class text_view: public Fl_Box
> {
>   void draw();
> public:
>   text_view(int x, int y,int w,int h, const char *l=3D0) :
> Fl_Box(x,y,w,h,l) {}
> };
>
> static uchar *data_p =3D NULL;
> static Fl_Image *img_tmp =3D NULL;
>
> void text_view::draw()
> {
>   int wd =3D scope->w();
>   int ht =3D scope->h();
>   int xo =3D 0;
>   int yo =3D 0;
>
>   if(offscreen_cxt) { // offscreen exists, grab something
>   if(data_p){
>     delete[] data_p;
>     data_p =3D NULL;
>   }
>   fl_begin_offscreen(offscreen_cxt); /* Open the offscreen context for
> reading */
>
>   data_p =3D fl_read_image(data_p, 0, 0, wd, ht, 0);
>
>   fl_end_offscreen(); // close the offscreen context
>
>   Fl_RGB_Image rgb(data_p, wd, ht);
>   if(img_tmp){
>     delete img_tmp; // free the previous image before copying the new
> one
>   }
>   img_tmp =3D rgb.copy(wd * scale, ht); // scale the image in the width
> direction
>   img_tmp->draw(x(), y(), wd, ht, 0, 0);
>   }
> } /* end of draw() method */
>
> static text_view *zoom =3D 0;
>
> void draw_offscreen()
> {
>   int wd =3D scope->w();
>   int ht =3D scope->h();
>   int xo =3D 0;
>   int yo =3D 0;
>
>   if (!offscreen_cxt) offscreen_cxt =3D fl_create_offscreen(wd, ht);
>   if (!offscreen_cxt) {puts("Bad Offscreen"); exit(-1);}
>
>   fl_begin_offscreen(offscreen_cxt);
>
>   fl_color(FL_WHITE);
>   fl_rectf(xo, yo, wd, ht);
>
>   fl_color(FL_BLACK);
>
>   fl_font(FL_HELVETICA, 24);
>   int tw, th;
>   tw =3D th =3D 0;
>   fl_measure(message, tw, th);
>   fl_draw(message, xo + 10, yo + 10 + th);
>
>   fl_end_offscreen();
> //  scope->redraw();
> //  zoom->redraw();
>   main_win->redraw();
> } /* end of draw() method */
>
> void update_zoom(void *)
> {
>   static int d =3D 1;
>   scale =3D scale + d;
>   if(scale > 4) {
>     d =3D -1;
>   }
>   if(scale < 2) {
>     d =3D +1;
>   }
>   sprintf(message, "Scaled by %d", scale);
>   draw_offscreen();
>   Fl::repeat_timeout(1.0, update_zoom);
> } // update_offscreen
>
> int main(int argc, char **argv)
> {
>   sprintf(message, "Scaled by %d", scale);
>   main_win =3D new Fl_Double_Window(522, 500, "Zoom Text Window");
>   main_win->begin();
>   scope =3D new scope_view(5, 5, 512, 200);
>   zoom  =3D new text_view(5, 210, 512, 200);
>   main_win->end();
>   main_win->show(argc, argv);
>
>   Fl::add_timeout(0.1, update_zoom);
>
>   return Fl::run();
> }
>
> /* end of file */
>
> ----------
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS=
> 14 3EL
> A company registered in England & Wales.  Company no. 02426132
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************
>

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to