Re: Gtk::Button set_image()



Hi,

Am Donnerstag, den 28.05.2009, 12:30 -0400 schrieb Caroline Kierstead:

> Is this example-pixbuf.cc? I'm on a Mac, so finding the files that were 
> installed takes quite a bit of digging. I may be better off just dowloading the 
> tar ball to unpack the examples, I guess.

The standalone version is in pixbuf-demo.cc.

> >> 	const Glib::RefPtr<Gdk::Pixbuf> getCardImage( Faces f, Suits s );
> > 
> > It isn't wrong to return a const value, but pointless in most cases.
> 
> Ok. I wasn't sure how restrictive the assignment was, so erred on the side of 
> keeping the const.

Which assignment?  The only reason to make a return value const is to
force an error on code like foo().bar(), where bar is a non-const method
of the object returned by foo().  Other than that, a return value is a
temporary and treated as such.

> Is there a spot with good documentation on the memory manager? There's not much 
> in the reference manual. How does this interact with using the remove() call on 
> a container?

If you remove a managed widget from a container and nobody else holds a
reference, it will be destroyed.  If you need to avoid that, either
don't use Gtk::manage(), or use reparent() to immediately move the
widget to another container.  You could also increase the reference
count temporarily, but doing so with gtkmm is currently very clumsy and
unsafe.

Regarding documentation, I don't know off-hand.  Maybe someone else on
the list knows a good source.

> Is there a good way to clear out the contents of box, such as a 
> Gtk::HBox?

Well, I don't think there is a ready-made method for it.  Most of the
time, you'd just destroy the HBox.

Generally, rearranging widgets is sometimes necessary, but overall it's
definitely one of the rarer operations an application usually performs.
I think that in your case, you probably shouldn't change the Gtk::Image
widgets at all, but instead just set a different pixbuf to display.

> Mostly because I'm doing this tangentially based off of someone else's code 
> (undocumented, and in Gtk+), when the course is now in C++, so gtkmm seemed more 
> appropriate. Anyways, the old course project used these card pixmaps for the 
> images so they're easily available.

Ah OK.  That makes sense.

> What would be a more appropriate format to be using?

For raster images, .png is the default these days.  But you can use .xpm
if you like.  It's just that XPM is a stupid file format. :-)

> Ok. Thanks for all of your help!

You're welcome!

--Daniel




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