[Mono-list] Using glade[sharp] in a mono project
Miguel de Icaza
miguel at ximian.com
Sat Dec 17 02:17:34 EST 2005
Hello,
> Usually when we build a new form using winforms, we would subclass a
> general form and add it some new features and initializations.
> In Glade on the contrary we have some "hardcoded" group of Gtk classes
> an we cannot modify them for our purposes...(written in c). That way
> suppse we want to build a special TreeView that will attach a popup menu
> to each of it's nodes - and we just can't do it, without creating a new
> instance of a class that inherits TreeView and copying the Glade given
> values(size, color...) into it.
There are a number of things that you can do:
* You can create the actual TreeView in your code and add it to
a container that you designate in your GUI.
This is a common pattern for custom widgets, something like:
[Widget] Box some_box;
...
MyCoolWidget w = new MyCoolWidget ();
some_box.Add (w);
In your case, you can do:
class MyTreeView : TreeView {
...
}
And override methods at will.
* Use the signal connect mechanism. If you only need to do
some minor changes to the behavior of a widget, you can
connect to the signals (for every method you could override
in the OO-way of doing things, you have a signal you can just
hook up to).
For example, if you want a Button to do something specific
with Gtk# you do not write a special button subclass, say
"PrintHelloWorldButton", instead you use a regular button
and hook up to the signal "Clicked" where you print Hello
World.
Miguel.
More information about the Mono-list
mailing list