RE: [gtkmm] How to copy Gtk::Widgets?



Thanks for your reply.


>> How could I make a copy of a Gtk::Widget?
>> It seems that both the copy constructor and operator= are declared 
>> private.

>That means that you cannot copy Gtk::Widget instances. Why would you
want to do it, and 
>what would it mean for you? What would you expect to happen?

I would expect to have another identical instance.

In my application I have a sort of library (a collection) of media
elements (bitmaps, text labels, and in the future video clips -
hopefully). I am planning to use Gtk::Widgets to display them on screen.
(the "library" idea is inspired by the "library" in Macromedia Flash)

I might want to have more than one "instance" of the same element -say
photo- on screen.
To go on with the image example, to make to identical Gtk::Images from a
Glib::RefPtr<Gdk::Pixbuf> what I have to do is:

Glib::RefPtr<Gdk::Pixbuf> im = Gdk::PixBuf::create_from...() ;
Gtk::Image *image1 = manage( new Gtk::Image(im) );
Gtk::Image *image2 = manage( new Gtk::Image(im) );

While what I would like to do (for the last line) is (something like):
Gtk::Image *image2 = manage( new Gtk::Image( *image1 ) );
or: 
Gtk::Image *image2 = manage( new Gtk::Image() );
*image2 = *image1;

Does this make any sense?

I might just keep a collection of Gdk::PixBuf and create my Gtk::Images
from there, but in this way I cannot use polymorphism when I deal with
different kind of widgets. 
What I have in mind is (something like):

Gtk::Widget aWidget = myCollectionOfWidgets[n];

Where myCollectionOfWidgets is some STL container and n is an integer.
In this way I would not have to worry about the kind of widget that I am
working with..

I hope I have given an idea of what I am trying to do. (I am not trying
to do a clone of Macromedia Flash, though!!!)
Can you suggest a way of implementing that?

Thank you in advance,
Enrico




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