Class: QDA::GUI::DocumentList
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Subscriber
#notify, #subscribe
#data, #delete_item_data, #index, #push_item_data, #unshift_item_data
Methods included from ItemData
#get_item_data, #set_item_data, #value_to_ident
Constructor Details
#initialize(weft_client, *args) ⇒ DocumentList
Returns a new instance of DocumentList.
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 7
def initialize(weft_client, *args)
@client = weft_client
super(*args)
evt_left_dclick() { | event | on_double_click(event) }
evt_key_down() { | e | on_key_down(e) }
evt_listbox( self.get_id ) { | e | on_item_selected(e) }
subscribe(@client, :document_added, :document_deleted, :document_changed)
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5
6
7
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 5
def client
@client
end
|
Instance Method Details
#app ⇒ Object
21
22
23
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 21
def app()
@client.app
end
|
#append_item(doc) ⇒ Object
add the document to the end of the list.
25
26
27
28
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 25
def append_item(doc)
push_item_data(doc)
append(doc.title)
end
|
#delete_selection ⇒ Object
48
49
50
51
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 48
def delete_selection()
client.on_delete_document()
end
|
#get_selection_data ⇒ Object
44
45
46
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 44
def get_selection_data()
get_item_data( get_selection )
end
|
58
59
60
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 58
def (e)
(@menu, e.get_x, e.get_y)
end
|
#on_double_click(e) ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 62
def on_double_click(e)
if string_selection.empty?
@client.import_document()
else
@client.on_document_open( selected_document() )
end
end
|
#on_item_selected(e) ⇒ Object
53
54
55
56
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 53
def on_item_selected(e)
@client.current_document = selected_document
e.skip()
end
|
#on_key_down(evt) ⇒ Object
88
89
90
91
92
93
94
95
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 88
def on_key_down(evt)
case evt.key_code()
when 127 delete_selection()
else
evt.skip()
end
end
|
#receive_document_added(doc) ⇒ Object
84
85
86
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 84
def receive_document_added(doc)
append_item(doc)
end
|
#receive_document_changed(doc) ⇒ Object
80
81
82
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 80
def receive_document_changed(doc)
update_item(doc)
end
|
#receive_document_deleted(doc) ⇒ Object
76
77
78
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 76
def receive_document_deleted(doc)
remove_item(doc)
end
|
#remove_item(item) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 30
def remove_item(item)
if i = value_to_ident(item)
data.delete_at(i)
delete(i)
end
end
|
#selected_document ⇒ Object
70
71
72
73
74
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 70
def selected_document()
sel = get_selection()
return nil unless sel and sel != -1
get_item_data( sel )
end
|
#update_item(doc) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/weft/wxgui/controls/document_list.rb', line 37
def update_item(doc)
if i = value_to_ident(doc)
set_item_data(i, doc)
set_string( value_to_ident(doc), doc.title )
end
end
|