Which widget to use
garrigue at math.nagoya-u.ac.jp
Thu Mar 3 12:53:31 CET 2005
From: Robert Roessler <robertr at rftp.com>
> I have seen suggestions both on and off the list to use GObj.widget
> for inheritance purposes when creating OCaml-level [new] widgets...
> but there are other choices, and any insights into which of the widget
> classes is intended to be used under which circumstances would be
> helpful. :)
> So, we have GObj.widget, GObj.widget_impl, and GObj.widget_full.
> I note that all three are related, with the two others deriving from
> widget. I see widget_impl is a parameterized class (similar to a C++
> templated class?), while widget_full is not. So, using widget_impl,
> you get to nail down the constructor parameter type more explicitly?
> But widget_full has the whole "connect" grouping of signals, while
> widget_impl does not...
Widget and widget_impl are actually identical.
The only difference is that the private method #obj is hidden in
widget. This method is only necessary if you add some _props
classes generated by propcc. As it is private, this doesn't add any
functionality to the object itself. The reason widget_impl has a type
parameter is just to make it simpler to write interfaces. Note that
for implementations it doesn't change anything, as you can replace
all parameters by "_", the anonymous type variable.
Widget_full adds a connect method, with some signals common to all
In practice, if your new widget has some new signals, you should
create a mywidget_signals class, and inherit from widget, adding a
#connect method. If it has no extra signals, you can use widget_full.
As explained above, you only need widget_impl if you use propcc.
More information about the Lablgtk-list