Hi Thomas,

Gtk 3 uses Cairo for its drawing backend, so one option would be to subclass
Gtk::DrawingArea, and then load a .png or so with Cairo, and copy that to
the cairo surface (& hence the Gtk::DrawingArea), after which you can
display the DrawingArea as a normal widget.

Another option is to use Gdk::Pixbuf and friends. This might be the easier
option, but provides less flexibility.

This link provides up to date (ie: Gtk3) info on both:
See this link:
http://developer.gnome.org/gtkmm-tutorial/3.0/sec-draw-images.html.en

Good luck! -Harry



On Tue, Aug 2, 2011 at 6:49 PM, Thomas Harty <[email protected]>wrote:

> Thanks. It looks like these won't work in gtkmm3. E.g. the "Changes in
> gtkmm 3" notes:
>
> 9. Gdk::Pixmap and Gdk::Bitmap were removed in favour of Gdk::Pixbuf.
>
> I had a look in the Gdk::window api (
> http://developer.gnome.org/gtkmm/stable/classGdk_1_1Window.html), but
> couldn't see a draw_drawable method.
>
> Any idea how to do this in gtkmm3?
>
> Tom
> ________________________________________
> From: [email protected] [[email protected]] on
> behalf of Yann LEYDIER [[email protected]]
> Sent: 02 August 2011 18:19
> To: [email protected]
> Subject: Re: Images in GTKmm
>
> I'm not using Gtkmm 3, but you might have to use cairomm to do that.
>
> In Gtkmm 2, I render the Pixbuf to a Pixmap and then use
> Gdk::Window::draw_drawable on the DrawingArea's Gdk window. Perhaps it
> still works in API 3…
>
>
> yann
>
> On 02/08/11 19:05, Thomas Harty wrote:
> > Thank you for the reply.
> >
> > I tried following the example here:
> http://developer.gnome.org/gtkmm-tutorial/3.0/sec-draw-images.html.en to
> test out using a Pixbuf in a Drawing area, but got a few compile-time errors
> (n.b. I'm using gtkmm 3.0):
> >
> > error: ‘class Gdk::Pixbuf’ has no member named ‘render_to_drawable’
> > error: ‘get_style’ was not declared in this scope
> > error: ‘RGB_DITHER_NONE’ is not a member of ‘Gdk’
> >
> > I had a look in the class reference (
> http://developer.gnome.org/gtkmm/3.1/classGdk_1_1Pixbuf.html) and couldn't
> see render_to_drawable. Has this been depreciated in gtkmm 3? If so, what's
> the appropriate way to do this now?
> >
> > Tom
> >
> >
> >
> > ________________________________________
> > From: [email protected] [[email protected]] on
> behalf of Yann LEYDIER [[email protected]]
> > Sent: 02 August 2011 16:29
> > To: [email protected]
> > Subject: Re: Images in GTKmm
> >
> > I would do this with a DrawingArea. It is possible to resize a Pixbuf to
> > the size of the DrawingArea and render it in a callback plugged to the
> > expose_event signal.
> >
> > But I don't known if it is the best way! ;)
> > yann
> >
> > On 02/08/11 12:51, Thomas Harty wrote:
> >> I want to put an image into a box in such a way that the image will
> >> shrink to fit into empty space in the box, whilst preserving its aspect
> >> ratio. Thus, the dimensions of the image should be determined by the
> >> dimensions of the objects around it. The image needs to shrink and
> >> expand with the box (e.g. if the user re-sizes the main window).
> >>
> >> For example, I want to put a few items in a VBox and have these items
> >> determine the width of the VBox. I then want to be able to add the image
> >> to the VBox in such a way that it doesn't resize the box, but rather
> >> fits into the space. If there is space left above/below the widget (due
> >> to the constraint of preserving it's aspect ratio), this should be
> >> filled with padding, rather than the image expanding to fill the space.
> >>
> >> What's the best way of accomplishing this in Gtkmm?
> >>
> >> Tom
> >>
> >>
> >>
> >> _______________________________________________
> >> gtkmm-list mailing list
> >> [email protected]
> >> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> >
> > _______________________________________________
> > gtkmm-list mailing list
> > [email protected]
> > http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
> _______________________________________________
> gtkmm-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> _______________________________________________
> gtkmm-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to