Re: GdkDrawable from GtkDrawingArea and it's cairo surface



thank you all, I now like this mailing list officially.

I had it working before with Marteen's help but now it seems like I
got an idea for some extra features  :)

2011/7/25 richard boaz <ivor boaz gmail com>:
> hi,
> i do this same sort of thing in my stuff, but written before cairo was.  i
> plan on converting all my drawing to cairo one day, thus must eventually
> solve this problem myself.  so i took your original sample/example and
> expanded on it to demonstrate pixmap backing stores and how to use/reference
> them when wanting to "undo" things relating to drawing areas.
> attached is the same sample, but with the following mods/additions:
>
> configure and expose events added to handle drawing area
> Draw and Undo buttons added
> drawing on the canvas can only happen when clicking the Draw button first
> (doable multiple times)
> Undo button will loop back (undo) over each drawing command initiated by the
> event-motion signal
> Resize will clear all saved pixmaps and clear the canvas
>
> but i deliver this with a huge caveat: i do not like the solution, something
> about the design is wrong (i can "feel" it).  so, this reference is intended
> for demonstration purposes only!  i will eventually come back to this and
> find the proper architecture, but don't have time at the moment.
> it does, however, "work", so it's not completely worthless; the best answer
> is in there somewhere.
> and just for the record, there really is many, many ways to solve this
> problem; you must strive to find the most appropriate solution that
> satisfies all the specific requirements of your particular problem, and
> sometimes this simply comes down to solving it over and over until the best
> solution becomes obvious.
> cheers,
> richard
>
> 2011/7/24 Carlos López Camey <c lopez kmels net>
>>
>> Hello again,
>>
>> Let's say I'd like to save a GtkDrawingArea 'screenshot' to a file.
>> I'm able to do
>>
>> cairo_t *cr = gtkDrawingAreaWidget->window;
>> cairo_surface_t *screenshot = cairo_get_target(cr);
>> cairo_surface_write_to_png(screenshot,"screenshot.png");
>>
>> but what this code does is save a screenshot for the *entire window*,
>> including other widgets in it (e.g. toolbar). I can't get a cairo
>> context for a GtkDrawingArea since it's not GdkDrawable, and it's not
>> possible to have child GtkWindow. I've seen
>> gtk_widget_set_has_window() but it didn't work, I think because it
>> says "This function should only be called by widget implementations".
>> Is there a work-around?
>>
>> What I'm really trying to do: Save my drawing area surface everytime
>> it's modified (drawn on it), so I can later do "undos" and set the
>> surface source to a previous one.
>>
>> Thanks,
>> Carlos
>> _______________________________________________
>> gtk-list mailing list
>> gtk-list gnome org
>> http://mail.gnome.org/mailman/listinfo/gtk-list
>
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]