Class: MasterDetail
- Inherits:
-
Widget
- Object
- Widget
- MasterDetail
- Extended by:
- Forwardable
- Defined in:
- lib/rbcurse/experimental/widgets/masterdetail.rb
Overview
that could take place.
Instance Attribute Summary collapse
-
#vim ⇒ Object
readonly
the vimsplit for any further configuration such as min_weight etc.
Instance Method Summary collapse
- #focus(comp) ⇒ Object
-
#init_vars ⇒ Object
:nodoc:.
-
#initialize(form, config = {}, &block) ⇒ MasterDetail
constructor
A new instance of MasterDetail.
- #repaint ⇒ Object
-
#set_left_component(comp, weight = nil) ⇒ Widget
set the single component on the left side/pane, typically a
Listbox
. -
#set_right_bottom_component(comp, weight = nil) ⇒ Widget
set the second component on the right side/pane, typically a
TextView
. -
#set_right_top_component(comp, weight = 0.5) ⇒ Widget
set the first component on the right side/pane, typically a
Listbox
.
Constructor Details
#initialize(form, config = {}, &block) ⇒ MasterDetail
Returns a new instance of MasterDetail.
15 16 17 18 19 20 21 22 |
# File 'lib/rbcurse/experimental/widgets/masterdetail.rb', line 15 def initialize form, config={}, &block @focusable = true @height = Ncurses.LINES-2 @weight = 0.25 super _create_vimsplit init_vars end |
Instance Attribute Details
#vim ⇒ Object (readonly)
the vimsplit for any further configuration such as min_weight etc
12 13 14 |
# File 'lib/rbcurse/experimental/widgets/masterdetail.rb', line 12 def vim @vim end |
Instance Method Details
#focus(comp) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rbcurse/experimental/widgets/masterdetail.rb', line 68 def focus comp case comp when :left @vim.goto_component @left when :top_right @vim.goto_component @right1 when :bottom_right @vim.goto_component @right2 else @vim.goto_component comp end end |
#init_vars ⇒ Object
:nodoc:
23 24 25 26 |
# File 'lib/rbcurse/experimental/widgets/masterdetail.rb', line 23 def init_vars #:nodoc: @first_time = true @repaint_required = true end |
#repaint ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/rbcurse/experimental/widgets/masterdetail.rb', line 27 def repaint if @first_time @first_time = nil [@vim, @left, @right1, @right2].each { |e| e.set_buffering(:target_window => @target_window || @form.window, :form => @form) # removed on 2011-09-29 } end @vim.repaint end |
#set_left_component(comp, weight = nil) ⇒ Widget
set the single component on the left side/pane, typically a Listbox
. If an array is passed, the Listbox created is returned for further manipulation.
41 42 43 44 45 |
# File 'lib/rbcurse/experimental/widgets/masterdetail.rb', line 41 def set_left_component comp, weight=nil @left = @vim.add comp, :FIRST, weight _add_component comp @left end |
#set_right_bottom_component(comp, weight = nil) ⇒ Widget
set the second component on the right side/pane, typically a TextView
59 60 61 62 63 64 65 66 67 |
# File 'lib/rbcurse/experimental/widgets/masterdetail.rb', line 59 def set_right_bottom_component comp, weight=nil raise "Please add top component first!" unless @added_top # what if user gives in wrong order !! @gb = @vim.add :divider, :SECOND, 0 @right2 = @vim.add comp, :SECOND, weight @gb.next_component(@right2) _add_component comp @right2 end |
#set_right_top_component(comp, weight = 0.5) ⇒ Widget
set the first component on the right side/pane, typically a Listbox
.
49 50 51 52 53 54 |
# File 'lib/rbcurse/experimental/widgets/masterdetail.rb', line 49 def set_right_top_component comp, weight=0.5 @added_top = true @right1 = @vim.add comp, :SECOND, weight _add_component comp @right1 end |