[gtkmm] Creating and setting pixmaps with strings



Hi all,

I'm currently working on a group project using Gtkmm 1.2 that uses pixmaps. According to the Gtk-- Reference, you should be able to create a pixmap from an .xpm file by passing a string, or more specifically, an nstring a a parameter (as long as you include the pixmap file of course). Now, I have gotten something like this to work:

pixmapGnim01->set(gnim01lrg_xpm);
Gtk::Pixmap *pix = new Gtk::Pixmap(gnim01lrg_xpm);

where it uses the string in the pixmap header file "gnim01lrg_xpm". However, I have not been able to so this:

pixmapGnim01->set("gnim01lrg_xpm");
or
string pixName = "gnim01lrg_xpm";
pixmapGnim01->set(pixName);
or
Gtk::nstring *pixName = new Gtk::nstring(currPixmapName);
Gtk::Pixmap *pix = new Gtk::Pixmap(*pixName);
or
Gtk::nstring *pixName = new Gtk::nstring(currPixmapName);
pixmapGnim01->set(pixName);

and so on...

As you can see, a string or nstring variable won't work, not even a real string of "gnim01lrg_xpm" won't work. But put in gnim01lrg_xpm by itself without quotation marks and it does work fine. I can't figure out what I am doing wrong. We really need to store the strings and pass them into the set or constructor methods so we can change a pixmap dynamically. I know you can change a pixmap at runtime, but we need to store the information so when we load a saved program, all of the pixmaps will initialize to whatever string they are assigned to. BTW, I know Gtkmm 1.2 is a bit old, but we have no choice in the matter and cannot upgrade at all. We MUST use Gtkmm 1.2 . Any help here would be appreciated a lot. Thanks.

Chris David





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