Class: RETerm::Components::DropDownMenu
Overview
CDK Drop Down Menu Component
Constant Summary
Constants included
from LogHelpers
LogHelpers::LOG_FILE
Instance Attribute Summary
#activatable, #activate_focus, #highlight_focus, #window
Instance Method Summary
collapse
#activatable?, #bind_key, #cdk?, #colors=, #component, #deactivate!, #early_exit?, #erase, #escape_hit?, #init?, #init_cdk, #normal_exit?, #strip_formatting, #title_attrib=, #value
#activatable?, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #reactivate!, #resize, #sync!, #sync_getch
#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?
Methods included from LogHelpers
#logger
#dispatch, #handle
Constructor Details
#initialize(args = {}) ⇒ DropDownMenu
Initialize the Menu component
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/reterm/components/drop_down_menu.rb', line 18
def initialize(args={})
super
@menus = args[:menus] || []
@locs = args[:locs] || 0.upto(size-1).collect { :left }
@pos = args[:pos] || :top
@color = args[:color]
@background = args[:background]
@prev = nil
end
|
Instance Method Details
#activate!(*input) ⇒ Object
87
88
89
90
91
92
93
94
|
# File 'lib/reterm/components/drop_down_menu.rb', line 87
def activate!(*input)
r = super
return nil if early_exit?
m = r / 100
i = r % 100
@menus[m][@menus[m].keys[i+1]]
end
|
#background? ⇒ Boolean
29
30
31
|
# File 'lib/reterm/components/drop_down_menu.rb', line 29
def background?
!!@background
end
|
41
42
43
44
|
# File 'lib/reterm/components/drop_down_menu.rb', line 41
def
return unless !!@color
.collect { |ms| ms.collect { |m| "#{@color.cdk_fmt}#{m}" }}
end
|
#draw! ⇒ Object
58
59
60
61
|
# File 'lib/reterm/components/drop_down_menu.rb', line 58
def draw!
super
@bgwin.mvaddstr(0, 0, ' ' * requested_cols) if background?
end
|
#finalize! ⇒ Object
33
34
35
|
# File 'lib/reterm/components/drop_down_menu.rb', line 33
def finalize!
@bgwin.finalize! if background?
end
|
#highlight_focus? ⇒ Boolean
96
97
98
|
# File 'lib/reterm/components/drop_down_menu.rb', line 96
def highlight_focus?
false
end
|
37
38
39
|
# File 'lib/reterm/components/drop_down_menu.rb', line 37
def
@menus.collect { |m| m.keys }
end
|
#requested_cols ⇒ Object
50
51
52
|
# File 'lib/reterm/components/drop_down_menu.rb', line 50
def requested_cols
total_cols + total_sp + 3
end
|
#requested_rows ⇒ Object
54
55
56
|
# File 'lib/reterm/components/drop_down_menu.rb', line 54
def requested_rows
max_items + 2
end
|
#selected ⇒ Object
83
84
85
|
# File 'lib/reterm/components/drop_down_menu.rb', line 83
def selected
@menus[component.current_title][@menus[component.current_title].keys[component.current_subtitle+1]]
end
|
#size ⇒ Object
46
47
48
|
# File 'lib/reterm/components/drop_down_menu.rb', line 46
def size
@menus.size
end
|
79
80
81
|
# File 'lib/reterm/components/drop_down_menu.rb', line 79
def
@menus.collect { |m| m.size }
end
|
#window=(w) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/reterm/components/drop_down_menu.rb', line 63
def window=(w)
win = super(w)
if background?
c = win.create_child :x => 0,
:y => 0,
:rows => 1,
:cols => requested_cols - 2
c.colors = @background
@bgwin = c
end
win
end
|