[fxruby-users] composite widgets

Jacob Hanson jacdx at jacobhanson.com
Thu May 12 11:25:03 EDT 2005


Thursday, May 12, 2005, 3:32:42 AM, you wrote:
> When adding/removing items before the parent widget is created you won't
> have to call
> create on them. The creation of the parent widget does that 
> automatically. But when
> adding/removing items after the parent's creation you will have to call
> .create on each new
> item and call .recalc of the parent widget.

> The two ways:

>     class YourWidget < FXVerticalFrame
>        def initialize(parent, opts)
>           super
>        end

>        def create
>           super
>        end

>        def addLabel(text)
>           FXLabel.new(self, text) do |label|
>              label.create
>           end
>           self.recalc
>        end
>     end

Hi Jannis,

This makes sense. This is how my widget is laid out. But, is there a
way to make addLabel versatile enough so that I can call it before
the parent widget is fully created (not call .create) and also be able
to call it after the parent widget is created (do call create)? Or do
I need to have two separate methods?

The way I have it, if I remove .create from my addLabel method, it
will create the initial items I need to create. But, since .create is
gone, the items I add after everything is created (e.g. from user
input) won't draw.

If I leave .create in, I get a segfault. Is there some sort of
flag that tells me that .create has already been run?

Thanks,

Jacob



More information about the fxruby-users mailing list