Module: WxExtensions::SemiModalDialog
- Defined in:
- lib/reactive-wx/wx_ext/semi_modal.rb
Overview
Extension for the Dialog class to allow semi-modal dialogs
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #end_modal_with_semi_handling(code) ⇒ Object
- #is_modal_with_semi_handling ⇒ Object
-
#show_semi_modal(destroy_on_close = true, &block) ⇒ Object
shows the dialog semi-modally.
Class Method Details
.included(base) ⇒ Object
:nodoc:
179 180 181 182 |
# File 'lib/reactive-wx/wx_ext/semi_modal.rb', line 179 def self.included(base) #:nodoc: base.send :alias_method_chain, :end_modal, :semi_handling base.send :alias_method_chain, :is_modal, :semi_handling end |
Instance Method Details
#end_modal_with_semi_handling(code) ⇒ Object
222 223 224 225 226 227 228 229 230 |
# File 'lib/reactive-wx/wx_ext/semi_modal.rb', line 222 def end_modal_with_semi_handling(code) return end_modal_without_semi_handling(code) unless @showing_semi_modal @root_panel.enable_children @semi_modal_block.call(code) if @semi_modal_block @showing_semi_modal = false @destroy_on_close ? destroy : hide end |
#is_modal_with_semi_handling ⇒ Object
218 219 220 |
# File 'lib/reactive-wx/wx_ext/semi_modal.rb', line 218 def is_modal_with_semi_handling @showing_semi_modal || is_modal_without_semi_handling end |
#show_semi_modal(destroy_on_close = true, &block) ⇒ Object
shows the dialog semi-modally. This method will return immediately, you should pass a block to allow processing when the dialog is dismissed. The block will be passed the returned ID Example:
dlg.show_semi_modal do |id|
case id
when Wx::ID_OK
...
when Wx::ID_CANCEL
...
end
end
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/reactive-wx/wx_ext/semi_modal.rb', line 196 def show_semi_modal(destroy_on_close = true, &block) @root_panel = RootPanel.find_root_panel(@parent || self) # @parent may be set by MessageDialog @semi_modal_block = block @showing_semi_modal = true @destroy_on_close = destroy_on_close # FIXME: Until wxRuby 2.0.0 fix the issue #, we have to handle the dismiss ourselves evt_close { end_modal_with_semi_handling(Wx::ID_CANCEL) } (Wx::ID_CANCEL) { end_modal_with_semi_handling(Wx::ID_CANCEL) } # END OF FIXME @root_panel.on_visible {|visible| show(visible); bring_to_front if visible } @root_panel.on_resize { set_size(get_rect.centre_in(@root_panel.get_screen_rect)) } @root_panel.on_close { !close } @root_panel.disable_children # Show dialog centre_on_parent show end |