Date: Thu, 03 Mar 2005 20:53:31 +0900 (JST) Message-Id: <20050303.205331.126115697.garrigue at math.nagoya-u.ac.jp> To: robertr at rftp.com Cc: lablgtk at math.nagoya-u.ac.jp Subject: Re: Which widget to use From: Jacques Garrigue In-Reply-To: <4226747F.6080607 at rftp.com> References: <4226747F.6080607 at rftp.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: Robert Roessler > 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 widgets. 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. Jacques