Re: [gtkmm] Creating GTK+ widgets with GTKmm? Is this possible?



>Hello! I have to say I love gtkmm, and use it in all my projects.
>But i'm asked to write some specific widgets that can be used from
>regular
>GTK+. I dont know how to write widgets in plain gtk, but do you people
>think it's possible to create them in gtkmm and then using a normal
>C++ -> C
>wrapping have a common GTK widget? I'd be glad to hear if this has
>been done before, 
>or maybe my idea is too crazy. :)

its really, really easy. the only drawback is that the results can
only be used within gtkmm - they cannot be used by GTK+ users, or
users of other language bindings.

the process is easy:

class MyWidget : public Gtk::Widget // or some more suitable type,
                                    // Gtk::DrawingArea is common

{
	public:
	   MyWidget() {
	       ...
	       // set the events you want to receive
           }	       

	protected:
	   // override the virtual functions for the widget
	   // that matter to you. the names differ in gtkmm 2
	   // but in gtkmm 1.2, you'd use things like:
	   
	   gint button_press_event_impl (GdkEventButton*);
	   gint button_release_event_impl (GdkEventButton*);
};

and that's it :) deriving a moderately simple widget like this takes
minutes, not even hours. 

--p



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