Adding to FXRuby classes

Hi,

I'm a newcomer to ruby so please bear with me!

I'm using the FXRuby module to interface with the FOX
toolkit. I want to overide the default appearance of a
couple of the widgets, and I've been trying to do it
by replacing the initialize method of the widget with
my own version. Here's how I tried to do it for
FXScrollbar:

class FXScrollbar
alias orig_initialize initialize
  def initialize(*args)
    orig_initialize(*args)
    self.borderColor=FXColor::Green
    self.hiliteColor=FXColor::Green
    self.shadowColor=FXColor::Black
    self.backColor=FXColor::Black
    puts "End of my version of FXScrollbar initialize"
  end
end

I can now create a instance of FXScrollbar, and it
displays with the expected colour change, and the puts
statement from my initialize method prints to the
terminal. However, when I subsequently create an
instance of FXList (which has a scrollbar), the
scrollbar is created without my replacement initialize
method being called at all (at least the puts is not
being printed to the terminal) and so the scrollbar
appears as normal. Does this seem like incorrect
behaviour, or am I missing something?

I'm using FXRuby-1.0.29, fox-1.2.9, ruby 1.6.8 on Mac
OS X 10.3

Thanks for any help!

Brian

···

__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

I'm using the FXRuby module to interface with the FOX
toolkit. I want to overide the default appearance of a
couple of the widgets, and I've been trying to do it
by replacing the initialize method of the widget with
my own version. Here's how I tried to do it for
FXScrollbar:

<snip>

I can now create a instance of FXScrollbar, and it
displays with the expected colour change, and the puts
statement from my initialize method prints to the
terminal. However, when I subsequently create an
instance of FXList (which has a scrollbar), the
scrollbar is created without my replacement initialize
method being called at all (at least the puts is not
being printed to the terminal) and so the scrollbar
appears as normal. Does this seem like incorrect
behaviour, or am I missing something?

As you may have deduced, the FXList class uses the stock version of
FXScrollbar (from the C++ library) and doesn't know about any changes
you've made to the Ruby version's initialize() method. However, you
may still be able to get the effect you're after by first constructing
the FXList instance:

    aList = FXList.new(...)

and then accessing its horizontalScrollbar and verticalScrollbar
members to make the desired changes, e.g.

    aList.horizontalScrollbar.borderColor=FXColor::Green
    aList.horizontalScrollbar.hiliteColor=FXColor::Green
    aList.horizontalScrollbar.shadowColor=FXColor::Black
    aList.horizontalScrollbar.backColor=FXColor::Black

I'm using FXRuby-1.0.29, fox-1.2.9, ruby 1.6.8 on Mac
OS X 10.3.

I hope this is a typo, but you should be using one of the fox-1.0.x
version libraries with FXRuby-1.0.29. fox-1.2.9 is definitely
incompatible with FXRuby-1.0.29.

Hope this helps,

Lyle

···

On Tue, 24 Aug 2004 04:44:09 +0900, Brian Sheehan <rbsheehan@yahoo.com> wrote:

Does this seem like incorrect

> behaviour, or am I missing something?

As you may have deduced, the FXList class uses the
stock version of
FXScrollbar (from the C++ library) and doesn't know
about any changes
you've made to the Ruby version's initialize()
method.

that's pity! At least I know now that it's working as
it should though.

> I'm using FXRuby-1.0.29, fox-1.2.9, ruby 1.6.8 on
Mac
> OS X 10.3.

I hope this is a typo, but you should be using one
of the fox-1.0.x
version libraries with FXRuby-1.0.29. fox-1.2.9 is
definitely
incompatible with FXRuby-1.0.29.

Yep, it was a typo!

thanks,
brian

···

--- Lyle Johnson <lyle.johnson@gmail.com> wrote:

__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail