
Yes, the Shoes reference refers to the method-based API (which is the standard), but you can just use the object-based API if you'd prefer, which is actually modelled on FXRuby (I originally copied the FXRuby stuff that seemed to make sense and the class names are the same as FXRuby for the most part). Of course, there should be no reason to actually use the objects directly, so maybe I should forget about that (yes, the intention is to give Shoes API (terse and makes assumptions) along with FXRuby complexity if you need it (lots of complex controls and options))
# shoesish
pack :vertical do
button text: "hello" do
# handle event
end
end
# FXRubyish
VerticalPacker.new(container) do |packer|
button = Button.new(packer, text: "hello")
button.subscribe :clicked_left_mouse_button do
# handle event
end
end
Well, the idea is that generally you want to just mess with the options (I haven't implemented :border_width or :background_image yet, since I don't personally need them, but they do fit in with my plan). If you want to override, there is nothing stopping you and you have the option of completely overriding #draw OR overriding #draw_background, #draw_border and/or #draw_foreground to have more fine control (#draw just calls those three protected methods).
Yes, you'd have to monkey-patch the original Fidgit class, but since Container#combo_box(options, &block) just calls ComboBox.new(parent, options, &block) you could also either monkey-patch ComboBox#initialize or the Container#combo_box methods. Three options, then, but all monkey-patch based, so I can see they aren't ideal...
What I had considered, however, was that you could have an Element.container_method(type) that you'd call in your overriding class so that it would automatically add (or replace) the Shoesie methods. Avoids the requirement of monkey-patching, which is a good thing, though not sure it is the best way:
# Overriding the defaults.
class MyComboBox < Fidgit::ComboBox
container_method :combo_box # Replaces the default Container#combo_box.
end
# Creating new methods.
class MyComboBox < Fidgit::ComboBox
container_method :my_combo_box # Adds Container#my_combo_box, so you can still have access to the original type.
end
Thoughts on that?