Re: [gtk-list] [gtkmm] signal handlers vs. virtual functions
- From: Tero Pulkkinen <terop students cc tut fi>
- To: davide rossetti roma1 infn it
- Cc: gtk mailing list <gtk-list redhat com>
- Subject: Re: [gtk-list] [gtkmm] signal handlers vs. virtual functions
- Date: 18 Sep 1998 14:30:44 +0300
Davide Rossetti <rossetti@apemaia.roma1.infn.it> writes:
> hi gtk-- users,
> I have a mothodological question:
> when is "good" to override X_impl() virtual functions in gtk-- widgets ?
>
> 2) for personalised widget classes, subclassed from stock gtk-- widget
> classes, there are two options available:
> 2.1) use connect_to_method(X, this, handle_X_method);
> 2.2) override X_impl().
I'd prefer X_impl() most times when you've already derived from some
widget. Then for widgets that you just *use*, you need to use
connect_to_* technique.
=> virtual functions are better and easier to use, but sometimes you must
use connect's to communicate between two widgets.
for example,
class mywindow : public Gtk_Window {
public:
gint destroy_event_impl(GdkEventAny*) { ... }
};
Doing this with connect_to_* functions would be silly.
but the following:
class mywindow : public Gtk_Window {
Gtk_Button b;
public:
mywindow() : b("test") { connect_to_method(b.clicked, this, &foomethod); }
void foomethod() { ... }
}
Here, its obvious to use connect_to_method, since that way you dont need
to derive from Gtk_Button just for catching events..
> (2.2) can give problems: either it is a do nothing function [is it
> true?] or there is 'meat' inside and you have to call the
> Super::X_impl() right inside your X_impl() [and you have to
> remember/know when to call it before or after your processing]
Yes, when you override virtual functions in gtk--, usually its good
to call the default implementation. I dont see it as a problem, just
a common use of virtual functions.
--
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]