[Fxruby-users] fxruby message tester
Status: Inactive
Brought to you by:
lyle
From: meinrad r. <mei...@gm...> - 2004-05-14 15:34:29
|
moin! many people including myself have asked on this list for a method to find out what messages a widget handles. i have written a simple script that does the job. the script is not perfect and i can not guarantee that the result is exact, but it seems fairly ok to me. a handful of messages cause segfaults or typeerrors (maybe because the handler expects specific message data instead of nil) so they were excluded. as soon as i have time to continue work on my gui builder, i will test all fox widgets and make the results publicly available. until then the attached script should help you to test any fox widget. have fun! - henon here comes the script: #fxruby message tester by henon require "fox" include Fox $stdout.sync=true $messages=Fox.constants.grep( /SEL_/).sort-[ "SEL_ENTER", # segfault "SEL_LAST", # segfault "SEL_LEAVE", # segfault "SEL_NONE", # segfault "SEL_PAINT", # segfault "SEL_SIGNAL", # type error - expects integer "SEL_VERIFY", # type error - expects string ] def test_widget( w) raise TypeError unless w.kind_of? FXWindow # or even FXObject ? # provide a receive callback for each message $messages.each{|c| const = Object.const_get(c) w.connect(const) { puts "received message: #{c}" } } # send all messages puts "Testing #{w.class}:" $messages.each{|c| #~ puts "sending: #{c}" w.handle(w, MKUINT(0, Object.const_get(c)), nil) } puts "finished!!" # remove the callbacks $messages.each{|c| const = Object.const_get(c) next if c=="SEL_UPDATE" w.connect(const) { 0 } } end application = FXApp.new("Hello", "FoxTest") main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL) w=FXButton.new(main, "the widget to be tested") application.create() test_widget(w) #main.show(PLACEMENT_SCREEN) #application.run() |