On Fri, 2005-03-25 at 10:45 +0000, Chris Vine wrote: > On Friday 25 March 2005 06:03, John Taber wrote: > > Chris, > > > > On Thursday 24 March 2005 16:01, you wrote: > > > What more do you want to know? > > > > Please realize some of us are application developers coming from other non > > programming disciplines so for me, a couple of code lines are worth a > > thousand words - here is the example of where I was working from > > > > > > > gtkhtml *cview; > > > > > Gtk::Frame *mmview = new Gtk::Frame(); > > > > > mmview->wrap(cview); > > > > > mmview->...... // whatever gtkhtml method > > > > > > Pass a pointer to the GTK+ object to be wrapped as the argument to > > > Glib::wrap(), and Glib::wrap() returns a pointer to the resulting wrapped > > > gtkmm object. > > > > so trying to apply what you indicate here I come up with this: > > gtkhtml *cview; > > Gtk::Frame *mmview = Glib::wrap(cview); > > mmview->...... // whatever gtkhtml method > > > > does this look right ? I just picked out Frame - not sure how to pick a > > gtkmm object to wrap into. Also, I wonder if I first have to instantiate > > the gtkmm object like: > > Gtk::Frame *mmview = new Gtk::Frame(); > > mmview = Glib::wrap(cview); > > > > thks John > > John, > > This will not work. You can only wrap a GTK+ object to provide the > corresponding gtkmm object. Thus a GtkFrame object wraps to a Gtk::Frame > object, a GtkLable object wraps to a Gtk::Label object, and so on, so your > code above won't work (it should fail to compile).
It would compile, but it would obviously forget the first mmview instance. That should be obvious C++. > An example is this: > #include <gtk/gtkframe.h> > #include <gtkmm/frame.h> > GtkWidget* frame = gtk_frame_new(0); > Gtk::Frame* wrapped_frame = Glib::wrap(GTK_FRAME(frame)); > > wrapped_frame is now pointing to a standard Gtk::Frame object. You can get > back to the underlying C object from it (as with any other gtkmm object) with > wrapped_frame->gobj(); > > I do not really know anything about gtkhtml, but I do not think there is a > corresponding gtkmm-compatible C++ class wrapping it, so your approach will > not work. It will create the most-derived base class that it knows about, and you'll have to use GTK+ C function calls, with gobj(), for the rest. Or wrap it using gmmproc. > If you need to put a gtkhtml object in a gtkmm container, the best > bet would probably be to put it in the equivalent GTK+ container first > (assuming that that is possible with gtkhtml and GTK+), and wrap the GTK+ > container to form the equivalent gtkmm container. You can put the gtkmm > container anywhere in gtkmm which excepts that container type. > > The disadvantage is that you will have to learn some GTK+ coding to do it > (but > that will come in handy anyway). -- Murray Cumming [EMAIL PROTECTED] www.murrayc.com www.openismus.com _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
