Class: RETerm::Components::ButtonBox
- Inherits:
-
RETerm::Component
- Object
- RETerm::Component
- RETerm::Components::ButtonBox
- Includes:
- ButtonHelpers, RETerm::CDKComponent
- Defined in:
- lib/reterm/components/button_box.rb
Overview
CDK ButtonBox Component
Constant Summary
Constants included from LogHelpers
Instance Attribute Summary collapse
-
#widget ⇒ Object
Returns the value of attribute widget.
Attributes inherited from RETerm::Component
#activatable, #activate_focus, #highlight_focus, #window
Instance Method Summary collapse
- #activate!(*input) ⇒ Object
- #close! ⇒ Object
-
#initialize(args = {}) ⇒ ButtonBox
constructor
Initialize the ButtonBox component.
- #requested_cols ⇒ Object
- #requested_rows ⇒ Object
- #selected ⇒ Object
- #window=(win) ⇒ Object
Methods included from ButtonHelpers
Methods included from RETerm::CDKComponent
#activatable?, #bind_key, #cdk?, #colors=, #component, #deactivate!, #draw!, #early_exit?, #erase, #escape_hit?, #init?, #init_cdk, #normal_exit?, #strip_formatting, #title_attrib=, #value
Methods inherited from RETerm::Component
#activatable?, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #sync!, #sync_getch
Methods included from KeyBindings
#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?
Methods included from LogHelpers
Methods included from EventDispatcher
Constructor Details
permalink #initialize(args = {}) ⇒ ButtonBox
Initialize the ButtonBox component
20 21 22 23 24 25 26 27 |
# File 'lib/reterm/components/button_box.rb', line 20 def initialize(args={}) super @widget = args[:widget] @title = args[:title] || "" @buttons = [args[:buttons]].flatten.compact @buttons = ["OK", "Cancel"] if @buttons.empty? end |
Instance Attribute Details
permalink #widget ⇒ Object
Returns the value of attribute widget.
8 9 10 |
# File 'lib/reterm/components/button_box.rb', line 8 def @widget end |
Instance Method Details
permalink #activate!(*input) ⇒ Object
[View source]
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/reterm/components/button_box.rb', line 53 def activate!(*input) .draw! component.draw(true) if .activatable? .activate!(*input) else super end @buttons[component.] end |
permalink #close! ⇒ Object
[View source]
37 38 39 40 41 42 43 |
# File 'lib/reterm/components/button_box.rb', line 37 def close! .erase .finalize! window.erase window.finalize! end |
permalink #requested_cols ⇒ Object
[View source]
33 34 35 |
# File 'lib/reterm/components/button_box.rb', line 33 def requested_cols [@title.size, , @widget.requested_cols].max end |
permalink #requested_rows ⇒ Object
[View source]
29 30 31 |
# File 'lib/reterm/components/button_box.rb', line 29 def requested_rows @widget.requested_rows end |
permalink #selected ⇒ Object
[View source]
66 67 68 |
# File 'lib/reterm/components/button_box.rb', line 66 def selected @buttons[component.] end |
permalink #window=(win) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/reterm/components/button_box.rb', line 45 def window=(win) super(win) cw = win.create_child :rows => .requested_rows, :cols => [.requested_cols, requested_cols].max raise ArgumentError, "could not create child" if cw.win.nil? cw.component = end |