> I want to do free hand drawing on a box widget > so i inherited the Fl_Box class,and i modified > Fl_Box::handle(int event) > and Fl_Box::draw() functions > created object of this type and added to the main window > now i can do free hand drawing on the box, > at this point after drawing i am adding a new window to the > main window to > cover the box. > now when i close this new window, what ever the drawing that was there > previously on the box is > vanishing ... please help me how to get back that drawing > when i close the > new window > (i had one solution for it i am saving the drawing as BMP > image and calling > the Fl_Widget::image(bmp) function so set the image the > only problem is > every time i need to access the bmp file which cost some time ) > please give me some better idea
It sounds (and I may be wrong!) like what you are doing is simply drawing onto the box widget, but not actually storing the points you have drawn - so the only place the drawing is "stored" is as the coloured pixels on the screen. But the screen has no "memory", so if you "damage" the widget on the screen, those pixels are gone... So, instead, what you need to do is store all the drawing information somewhere else: 1) One way is, as you have done, to write the whole image to a pixelmap of some sort, but (as you have noticed) this can be slow. (A lot of this slowness comes from file access though, so if you can create your "BMP file" in RAM, it might be substantially quicker.) 2) Another way is to have your ::handle() method store *all* the mouse actions in a structure of some sort (e.g. a linked list) and then have your draw method iterate through that list and redraw the screen, if the screen is "damaged". 3) A third way is to draw your image to an off-screen pixmap, then copy that off-screen version onto the on-screen version when it needs updating. Since the off-screen version should not be overlayed by other windows, it should not get damaged by the other windows. I'd probably opt for (2), even though it is probably more work, since it allows for an "undo" function (simply by rewinding the list). Or perhaps a combination of (2) and (3) together. However, all these treatments are pretty simplistic, if you want to make a full-blown drawing tool, you'll need to get into much more sophisticated window updating techniques, I think. -- Ian SELEX Sensors and Airborne Systems Limited Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 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 mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

