Re: How to "extend" a widget?



On 12/16/2011 03:03 PM, Michael Cronenworth wrote:
jacky wrote:
What I was looking into would be more taking an existing widget, and
modifying it a little, as in changing its behavior on some aspect, or
adding a feature, something like that.

My question is: what would be the best/standard/recommanded way to do
such a thing?

Widgets are not plugins. They are whole objects. There is no extensible 
feature to them.

Not true.  You can inherit from like you would any other class.  And
override virtual methods, add you own.  If this were not possible GTK
would have been abandoned as a serious platform long ago.

You will have two choices:

1. Copy an entire GTK widget and give it a unique name.
    Example: GtkButton becomes GtkMyButton

You really could Create a GtkMyButton by inheriting from GtkButton and
adding your own code.  However, just as in C++, the ability to override
specific methods depends on whether they were made as virtual or static
methods.  static methods can't be overridden, but you could just shadow
them with your own methods and use them instead.



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