weft-qda 0.9.6 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/weft.rb +16 -1
- data/lib/weft/WEFT-VERSION-STRING.rb +1 -1
- data/lib/weft/application.rb +17 -74
- data/lib/weft/backend.rb +6 -32
- data/lib/weft/backend/sqlite.rb +222 -164
- data/lib/weft/backend/sqlite/category_tree.rb +52 -48
- data/lib/weft/backend/sqlite/database.rb +57 -0
- data/lib/weft/backend/sqlite/upgradeable.rb +7 -0
- data/lib/weft/broadcaster.rb +90 -0
- data/lib/weft/category.rb +139 -47
- data/lib/weft/codereview.rb +160 -0
- data/lib/weft/coding.rb +74 -23
- data/lib/weft/document.rb +23 -10
- data/lib/weft/exceptions.rb +10 -0
- data/lib/weft/filters.rb +47 -224
- data/lib/weft/filters/indexers.rb +137 -0
- data/lib/weft/filters/input.rb +118 -0
- data/lib/weft/filters/output.rb +101 -0
- data/lib/weft/filters/templates.rb +80 -0
- data/lib/weft/filters/win32backtick.rb +246 -0
- data/lib/weft/query.rb +169 -0
- data/lib/weft/wxgui.rb +349 -294
- data/lib/weft/wxgui/constants.rb +43 -0
- data/lib/weft/wxgui/controls.rb +6 -0
- data/lib/weft/wxgui/controls/category_dropdown.rb +192 -0
- data/lib/weft/wxgui/controls/category_tree.rb +314 -0
- data/lib/weft/wxgui/controls/document_list.rb +97 -0
- data/lib/weft/wxgui/controls/multitype_control.rb +37 -0
- data/lib/weft/wxgui/{inspectors → controls}/textcontrols.rb +235 -64
- data/lib/weft/wxgui/dialogs.rb +144 -41
- data/lib/weft/wxgui/error_handler.rb +116 -36
- data/lib/weft/wxgui/exceptions.rb +7 -0
- data/lib/weft/wxgui/inspectors.rb +61 -208
- data/lib/weft/wxgui/inspectors/category.rb +19 -16
- data/lib/weft/wxgui/inspectors/codereview.rb +90 -132
- data/lib/weft/wxgui/inspectors/document.rb +12 -8
- data/lib/weft/wxgui/inspectors/imagedocument.rb +56 -56
- data/lib/weft/wxgui/inspectors/query.rb +284 -0
- data/lib/weft/wxgui/inspectors/script.rb +147 -23
- data/lib/weft/wxgui/lang/en.rb +69 -0
- data/lib/weft/wxgui/sidebar.rb +90 -432
- data/lib/weft/wxgui/utilities.rb +70 -91
- data/lib/weft/wxgui/workarea.rb +150 -43
- data/share/icons/category.ico +0 -0
- data/share/icons/category.xpm +109 -0
- data/share/icons/codereview.ico +0 -0
- data/share/icons/codereview.xpm +54 -0
- data/share/icons/d_and_c.xpm +126 -0
- data/share/icons/document.ico +0 -0
- data/share/icons/document.xpm +70 -0
- data/share/icons/project.ico +0 -0
- data/share/icons/query.ico +0 -0
- data/share/icons/query.xpm +56 -0
- data/{lib/weft/wxgui → share/icons}/search.xpm +0 -0
- data/share/icons/weft.ico +0 -0
- data/share/icons/weft.xpm +62 -0
- data/share/icons/weft16.ico +0 -0
- data/share/icons/weft32.ico +0 -0
- data/share/templates/category_plain.html +18 -0
- data/share/templates/codereview_plain.html +18 -0
- data/share/templates/document_plain.html +13 -0
- data/share/templates/document_plain.txt +7 -0
- data/test/001-document.rb +55 -36
- data/test/002-category.rb +81 -6
- data/test/003-code.rb +8 -4
- data/test/004-application.rb +13 -34
- data/test/005-query_review.rb +139 -0
- data/test/006-filters.rb +54 -42
- data/test/007-output_filters.rb +113 -0
- data/test/009a-backend_sqlite_basic.rb +95 -24
- data/test/009b-backend_sqlite_complex.rb +43 -62
- data/test/009c_backend_sqlite_bench.rb +5 -10
- data/test/053-doc_inspector.rb +46 -0
- data/test/055-query_window.rb +50 -0
- data/test/all-tests.rb +1 -0
- data/test/test-common.rb +19 -0
- data/test/testdata/empty.qdp +0 -0
- data/test/testdata/simple with space.pdf +0 -0
- data/test/testdata/simple.pdf +0 -0
- data/weft-qda.rb +40 -7
- metadata +74 -14
- data/lib/weft/wxgui/category.xpm +0 -26
- data/lib/weft/wxgui/document.xpm +0 -25
- data/lib/weft/wxgui/inspectors/search.rb +0 -265
- data/lib/weft/wxgui/mondrian.xpm +0 -44
- data/lib/weft/wxgui/weft16.xpm +0 -31
@@ -3,18 +3,18 @@ module QDA
|
|
3
3
|
class CategoryWindow < InspectorWindow
|
4
4
|
include Subscriber
|
5
5
|
|
6
|
-
def initialize(cat,
|
6
|
+
def initialize(cat, client, workarea, layout)
|
7
7
|
@cat = cat
|
8
|
-
@
|
8
|
+
@client = client
|
9
9
|
|
10
10
|
super(workarea, @cat.name, layout) do | parent |
|
11
|
-
text_box = CompositeText.new(parent, '', 0, @
|
12
|
-
text_box.populate( @
|
11
|
+
text_box = CompositeText.new(parent, '', 0, @client)
|
12
|
+
text_box.populate( @client.app.get_text_at_category(@cat) )
|
13
13
|
text_box
|
14
14
|
end
|
15
15
|
|
16
16
|
construct_details_panel()
|
17
|
-
if ! @cat.children.empty?
|
17
|
+
if false # ! @cat.children.empty?
|
18
18
|
construct_explore_panel()
|
19
19
|
end
|
20
20
|
|
@@ -22,11 +22,16 @@ module QDA
|
|
22
22
|
on_change_page(e)
|
23
23
|
end
|
24
24
|
|
25
|
-
set_icon(
|
25
|
+
set_icon( client.fetch_icon("category") )
|
26
26
|
|
27
|
-
subscribe(
|
27
|
+
subscribe(@client,
|
28
|
+
:document_deleted, :category_changed, :category_deleted)
|
28
29
|
end
|
29
|
-
|
30
|
+
|
31
|
+
def object()
|
32
|
+
@cat
|
33
|
+
end
|
34
|
+
|
30
35
|
# just a mucky method to reduce the length of the initializer -
|
31
36
|
# ideally i guess this would be done using XRC
|
32
37
|
def construct_details_panel()
|
@@ -35,13 +40,12 @@ module QDA
|
|
35
40
|
|
36
41
|
# the text entry box for the category's name
|
37
42
|
name_box_label = Wx::StaticBox.new(panel2, -1, 'Name')
|
38
|
-
name_box_sizer = Wx::StaticBoxSizer.new(name_box_label,
|
39
|
-
Wx::VERTICAL)
|
43
|
+
name_box_sizer = Wx::StaticBoxSizer.new(name_box_label, Wx::VERTICAL)
|
40
44
|
@name_field = Wx::TextCtrl.new(panel2, -1, @cat.name)
|
41
45
|
name_box_sizer.add(@name_field, 0,
|
42
46
|
Wx::ADJUST_MINSIZE|Wx::ALL|Wx::GROW, 4)
|
43
47
|
sizer2.add(name_box_sizer,0, Wx::ADJUST_MINSIZE|Wx::ALL|Wx::GROW, 4)
|
44
|
-
|
48
|
+
|
45
49
|
# Create the statistics panel
|
46
50
|
info_panel = Wx::Panel.new(panel2, -1)
|
47
51
|
info_box_label = Wx::StaticBox.new(info_panel, -1, 'Statistics')
|
@@ -100,10 +104,9 @@ module QDA
|
|
100
104
|
# cf construct_details_panel
|
101
105
|
def construct_explore_panel()
|
102
106
|
panel = Wx::Panel.new(@notebook, -1)
|
103
|
-
# panel.set_font(GLOBAL_FONT)
|
104
107
|
sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
105
108
|
# create a local locked copy
|
106
|
-
@tree_list = CategoryTree.new(@
|
109
|
+
@tree_list = CategoryTree.new(@client, panel, true)
|
107
110
|
@tree_list.populate([@cat])
|
108
111
|
sizer.add(@tree_list, 10, Wx::GROW|Wx::ALL, 4)
|
109
112
|
panel.set_sizer( sizer )
|
@@ -113,8 +116,7 @@ module QDA
|
|
113
116
|
def on_save_memo(e)
|
114
117
|
@cat.memo = @memo_box.value
|
115
118
|
@cat.name = @name_field.value
|
116
|
-
Wx::BusyCursor.busy { @
|
117
|
-
$wxapp.broadcast(:category_changed, @cat)
|
119
|
+
Wx::BusyCursor.busy { @client.app.save_category( @cat ) }
|
118
120
|
end
|
119
121
|
|
120
122
|
def on_change_page(e)
|
@@ -138,8 +140,9 @@ module QDA
|
|
138
140
|
def refresh()
|
139
141
|
set_title( @cat.name )
|
140
142
|
@text_box.value = ''
|
141
|
-
@text_box.populate( @
|
143
|
+
@text_box.populate( @client.app.get_text_at_category(@cat) )
|
142
144
|
@name_field.value = @cat.name
|
145
|
+
@memo_box.value = @cat.memo
|
143
146
|
if curr_category = @drop_down.current_category()
|
144
147
|
@text_box.highlight_codingtable(curr_category.codes)
|
145
148
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
module QDA::GUI
|
2
2
|
class CodeReviewWindow < WorkAreaWindow
|
3
|
-
include Subscriber
|
3
|
+
include QDA::Subscriber
|
4
4
|
|
5
5
|
W_WINDOW_DEF_SIZE = [ 0.8, 0.6 ]
|
6
6
|
BASE_COLOUR = Wx::Colour.new(255, 255, 255)
|
7
7
|
HIGHLIGHT_COLOUR = Wx::Colour.new(255, 0, 0)
|
8
8
|
GRID_COLOUR = Wx::Colour.new(223, 223, 233)
|
9
|
-
|
10
|
-
def initialize(obj,
|
9
|
+
attr_reader :client
|
10
|
+
def initialize(obj, weft_client, workarea, layout)
|
11
11
|
super(workarea, "Code Review #{obj.dbid}", nil)
|
12
|
-
@
|
13
|
-
@
|
12
|
+
@client = weft_client
|
13
|
+
@cr = obj
|
14
|
+
@cr.count_method = @count_method = :num_of_docs
|
14
15
|
|
15
16
|
main_sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
16
17
|
panel = Wx::Panel.new(self)
|
@@ -24,7 +25,7 @@ module QDA::GUI
|
|
24
25
|
0.upto(11) { | i | @grid.set_row_label_value(i, '') }
|
25
26
|
|
26
27
|
evt_grid_label_left_click() { | evt | on_label_clicked(evt) }
|
27
|
-
|
28
|
+
evt_grid_cell_left_dclick() { | evt | on_cell_dclicked(evt) }
|
28
29
|
# the controls panel
|
29
30
|
main_sizer.add(@grid, 1, Wx::GROW|Wx::ALL, 4)
|
30
31
|
# butt_panel = Wx::Panel.new(panel, -1)
|
@@ -32,7 +33,7 @@ module QDA::GUI
|
|
32
33
|
bott_sizer = Wx::StaticBoxSizer.new(butt_box_label,
|
33
34
|
Wx::HORIZONTAL)
|
34
35
|
|
35
|
-
@drop_down = CategoryDropDown.new(
|
36
|
+
@drop_down = CategoryDropDown.new(@client, panel)
|
36
37
|
bott_sizer.add(@drop_down, 3, Wx::ALL, 4)
|
37
38
|
|
38
39
|
button = Wx::Button.new(panel, -1, 'Add as row')
|
@@ -79,9 +80,14 @@ module QDA::GUI
|
|
79
80
|
panel.set_sizer(main_sizer)
|
80
81
|
main_sizer.set_size_hints(panel)
|
81
82
|
|
82
|
-
|
83
|
+
self.icon = client.fetch_icon("codereview")
|
84
|
+
subscribe(client, :category_deleted, :category_changed)
|
83
85
|
end
|
84
|
-
|
86
|
+
|
87
|
+
def object()
|
88
|
+
@cr
|
89
|
+
end
|
90
|
+
|
85
91
|
def associated_subscribers()
|
86
92
|
[ @drop_down ]
|
87
93
|
end
|
@@ -89,11 +95,11 @@ module QDA::GUI
|
|
89
95
|
# set the currently highlighted row or column as the current item
|
90
96
|
# in the dropdown
|
91
97
|
def on_label_clicked(e)
|
92
|
-
if row = e.row and row >= 0 and @rows[row]
|
93
|
-
@drop_down.receive_focus_category( @rows[row] )
|
98
|
+
if row = e.row and row >= 0 and @cr.rows[row]
|
99
|
+
@drop_down.receive_focus_category( @cr.rows[row] )
|
94
100
|
end
|
95
|
-
if col = e.col and col >= 0 and @cols[col]
|
96
|
-
@drop_down.receive_focus_category( @cols[col] )
|
101
|
+
if col = e.col and col >= 0 and @cr.cols[col]
|
102
|
+
@drop_down.receive_focus_category( @cr.cols[col] )
|
97
103
|
end
|
98
104
|
end
|
99
105
|
|
@@ -111,165 +117,117 @@ module QDA::GUI
|
|
111
117
|
self.count_method = method
|
112
118
|
end
|
113
119
|
|
114
|
-
def count_method=(
|
115
|
-
if
|
116
|
-
@count_method =
|
117
|
-
|
118
|
-
|
120
|
+
def count_method=(new_method)
|
121
|
+
if new_method != @count_method
|
122
|
+
@cr.count_method = new_method
|
123
|
+
@count_method = new_method
|
124
|
+
refresh()
|
119
125
|
end
|
120
126
|
end
|
121
127
|
|
122
128
|
def on_add_col(e)
|
123
129
|
category = @drop_down.current_category
|
124
|
-
return
|
125
|
-
|
126
|
-
|
127
|
-
@cols.push(category)
|
128
|
-
@grid.append_cols(1) if @cols.length > @grid.number_cols
|
129
|
-
col = @cols.length - 1
|
130
|
-
|
131
|
-
@grid.set_col_label_value( col, category.name )
|
132
|
-
# @grid.set_col_format_number( col )
|
133
|
-
calculate_col(col)
|
134
|
-
recolour_table()
|
135
|
-
end
|
136
|
-
|
137
|
-
def calculate_col(i)
|
138
|
-
col = @cols[i]
|
139
|
-
@rows.each_with_index do | row_cat, j |
|
140
|
-
@contents[j][i] = row_cat.codes.dup.join(col.codes)
|
141
|
-
update_cell(j, i)
|
142
|
-
end
|
130
|
+
return unless @cr.add_col(category)
|
131
|
+
@grid.append_cols(1) if @cr.number_cols >= @grid.number_cols
|
132
|
+
refresh()
|
143
133
|
end
|
144
134
|
|
135
|
+
# add an item to the CodeReview
|
145
136
|
def on_add_row(e)
|
146
137
|
category = @drop_down.current_category
|
147
|
-
return
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
@rows.push(category)
|
152
|
-
@grid.append_rows(1) if @rows.length > @grid.number_rows
|
153
|
-
row = @rows.length - 1
|
154
|
-
|
155
|
-
@grid.set_row_label_value( row, category.name )
|
156
|
-
@contents[row] = []
|
157
|
-
# @grid.set_row_format_number( row )
|
158
|
-
calculate_row(row)
|
159
|
-
recolour_table()
|
138
|
+
return unless @cr.add_row(category)
|
139
|
+
@grid.append_rows(1) if @cr.number_rows >= @grid.number_rows
|
140
|
+
refresh()
|
160
141
|
end
|
161
142
|
|
162
|
-
def calculate_row(i)
|
163
|
-
row = @rows[i]
|
164
|
-
@cols.each_with_index do | col_cat, j |
|
165
|
-
@contents[i][j] = col_cat.codes.dup.join(row.codes)
|
166
|
-
update_cell(i, j)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
# removes the selected category from both rows and colums
|
171
143
|
def on_remove(e)
|
172
144
|
on_remove_col(e)
|
173
145
|
on_remove_row(e)
|
174
146
|
end
|
175
147
|
|
148
|
+
# handler for removing a row, as selected in drop-down. Will remove the
|
149
|
+
# item from the underlying CodeReview, and redraw grid.
|
176
150
|
def on_remove_col(e)
|
177
151
|
category = @drop_down.current_category
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
def remove_col(idx)
|
185
|
-
@cols.delete_at(idx)
|
186
|
-
@contents.each { | row | row.delete_at(idx) }
|
187
|
-
@grid.delete_cols(idx, 1)
|
188
|
-
@grid.append_cols(1)
|
189
|
-
update_col_labels()
|
152
|
+
if idx = @cr.remove_col(category)
|
153
|
+
@grid.delete_cols(idx, 1)
|
154
|
+
@grid.append_cols(1)
|
155
|
+
refresh()
|
156
|
+
end
|
190
157
|
end
|
191
158
|
|
159
|
+
# handler for removing a row, as selected in drop-down. Will remove the
|
160
|
+
# item from the underlying CodeReview, and redraw grid.
|
192
161
|
def on_remove_row(e)
|
193
162
|
category = @drop_down.current_category
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
163
|
+
if idx = @cr.remove_row(category)
|
164
|
+
@grid.delete_rows(idx, 1)
|
165
|
+
@grid.append_rows(1)
|
166
|
+
refresh()
|
167
|
+
end
|
198
168
|
end
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
@
|
205
|
-
|
169
|
+
|
170
|
+
# repaints and recolours the content of the grid
|
171
|
+
|
172
|
+
#
|
173
|
+
def on_cell_dclicked(e)
|
174
|
+
q = @cr.to_query(@client.app, e.get_row, e.get_col)
|
175
|
+
if q
|
176
|
+
q_id = @client.app.get_preference('NextQuery') || 1
|
177
|
+
@client.app.save_preference('NextQuery', q_id + 1)
|
178
|
+
q.dbid = q_id
|
179
|
+
@workarea.launch_window(QueryWindow, q)
|
180
|
+
end
|
206
181
|
end
|
207
|
-
|
208
|
-
def
|
209
|
-
|
210
|
-
|
182
|
+
|
183
|
+
def refresh()
|
184
|
+
@grid.clear_grid()
|
185
|
+
|
186
|
+
max = @cr.max()
|
187
|
+
@cr.each_cell_value() do | x, y, val |
|
188
|
+
@grid.set_cell_value(x, y, val.to_s)
|
189
|
+
tint = BASE_COLOUR.mix( HIGHLIGHT_COLOUR, max, val)
|
190
|
+
@grid.set_cell_background_colour(x, y, tint)
|
191
|
+
end
|
192
|
+
update_row_labels()
|
193
|
+
update_col_labels()
|
211
194
|
end
|
212
|
-
|
195
|
+
|
196
|
+
# when a column is added or deleted, Wx (2.4.2) doesn't seem to redraw the
|
197
|
+
# labels correctly without help
|
213
198
|
def update_col_labels()
|
214
|
-
@
|
215
|
-
|
216
|
-
|
217
|
-
# check if we need to clean up deleted and now empty row labels
|
218
|
-
# at the end - Wx 2.4.2 doesn't seem to do this automatically
|
219
|
-
@grid.set_col_label_value(@cols.length, '')
|
220
|
-
return if @cols.length == @grid.number_cols()
|
221
|
-
for empty in ( @cols.length ... @grid.number_cols() )
|
199
|
+
@cr.each_col { | c, i | @grid.set_col_label_value(i, c.name) }
|
200
|
+
return if @cr.number_cols == @grid.number_cols
|
201
|
+
for empty in ( @cr.number_cols ... @grid.number_cols )
|
222
202
|
@grid.set_col_label_value(empty, '')
|
223
203
|
end
|
224
204
|
end
|
225
205
|
|
206
|
+
# when a row is added or deleted, Wx (2.4.2) doesn't seem to redraw the
|
207
|
+
# labels correctly without help
|
226
208
|
def update_row_labels()
|
227
|
-
@
|
228
|
-
@grid.set_row_label_value(i, c.name)
|
229
|
-
end
|
209
|
+
@cr.each_row { | r, i | @grid.set_row_label_value(i, r.name) }
|
230
210
|
# check if we need to clean up deleted and now empty row labels
|
231
211
|
# at the end - Wx 2.4.2 doesn't seem to do this automatically
|
232
|
-
return if @
|
233
|
-
for empty in ( @
|
212
|
+
return if @cr.number_rows == @grid.number_rows
|
213
|
+
for empty in ( @cr.number_rows ... @grid.number_rows )
|
234
214
|
@grid.set_row_label_value(empty, '')
|
235
215
|
end
|
236
216
|
end
|
237
|
-
|
238
|
-
|
239
|
-
max = @contents.flatten.collect { | x | x.send(@count_method) }.max
|
240
|
-
@contents.each_with_index do | row_items, row |
|
241
|
-
row_items.each_with_index do | code_table, col |
|
242
|
-
clr = BASE_COLOUR.mix( HIGHLIGHT_COLOUR,
|
243
|
-
max, code_table.send(@count_method))
|
244
|
-
@grid.set_cell_background_colour(row, col, clr)
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
217
|
+
private :update_row_labels, :update_col_labels
|
218
|
+
|
249
219
|
def receive_category_changed(cat)
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
if idx = @rows.index(cat)
|
256
|
-
@rows[idx] = cat
|
257
|
-
calculate_row(idx)
|
258
|
-
end
|
259
|
-
|
260
|
-
recolour_table()
|
220
|
+
changed = nil
|
221
|
+
changed = @cr.update_col(cat)
|
222
|
+
changed = @cr.update_row(cat)
|
223
|
+
refresh() if changed
|
261
224
|
end
|
262
225
|
|
263
226
|
def receive_category_deleted(cat)
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
if idx = @rows.index(cat)
|
269
|
-
remove_row(idx)
|
270
|
-
end
|
271
|
-
|
272
|
-
recolour_table()
|
227
|
+
deleted = nil
|
228
|
+
deleted = @cr.remove_col(cat)
|
229
|
+
deleted = @cr.remove_row(cat)
|
230
|
+
refresh() if deleted
|
273
231
|
end
|
274
232
|
end
|
275
233
|
end
|
@@ -4,13 +4,13 @@ module QDA
|
|
4
4
|
class DocumentWindow < InspectorWindow
|
5
5
|
include Subscriber
|
6
6
|
|
7
|
-
def initialize(doc,
|
7
|
+
def initialize(doc, client, workarea, layout)
|
8
8
|
@doc = doc
|
9
|
-
@
|
9
|
+
@client = client
|
10
10
|
|
11
11
|
super(workarea, doc.title, layout) do | txt_parent |
|
12
12
|
text_box = DocTextViewer.new(txt_parent, @doc.dbid)
|
13
|
-
text_box.set_font(@
|
13
|
+
text_box.set_font(@client.display_font)
|
14
14
|
text_box.append_text( @doc.text )
|
15
15
|
text_box.evt_enter_window do | e |
|
16
16
|
set_cursor Wx::Cursor.new(Wx::CURSOR_IBEAM)
|
@@ -19,14 +19,19 @@ module QDA
|
|
19
19
|
set_cursor Wx::Cursor.new(Wx::CURSOR_ARROW)
|
20
20
|
end
|
21
21
|
text_box.show_position(0)
|
22
|
+
text_box.insertion_point = 0
|
22
23
|
text_box
|
23
24
|
end
|
24
25
|
|
25
26
|
construct_details_panel()
|
26
|
-
set_icon(
|
27
|
-
subscribe(:document_changed, :document_deleted)
|
27
|
+
set_icon( client.fetch_icon("document") )
|
28
|
+
subscribe(@client, :document_changed, :document_deleted)
|
28
29
|
end
|
29
|
-
|
30
|
+
|
31
|
+
def object()
|
32
|
+
@doc
|
33
|
+
end
|
34
|
+
|
30
35
|
def receive_document_deleted(doc)
|
31
36
|
close() if doc.dbid == @doc.dbid
|
32
37
|
end
|
@@ -53,8 +58,7 @@ module QDA
|
|
53
58
|
def on_save_details(e)
|
54
59
|
@doc.memo = @memo_box.value
|
55
60
|
@doc.title = @title_box.value
|
56
|
-
Wx::BusyCursor.busy { @
|
57
|
-
$wxapp.broadcast(:document_changed, @doc)
|
61
|
+
Wx::BusyCursor.busy { @client.app.save_document( @doc ) }
|
58
62
|
end
|
59
63
|
|
60
64
|
# scroll the window's text box to the line containing the
|
@@ -1,56 +1,56 @@
|
|
1
|
-
module QDA
|
2
|
-
module GUI
|
3
|
-
|
4
|
-
class ImageDocumentWindow < InspectorWindow
|
5
|
-
Wx::init_all_image_handlers
|
6
|
-
|
7
|
-
def initialize(image_file, *args)
|
8
|
-
@img = Wx::Image.new(image_file)
|
9
|
-
# magnifier
|
10
|
-
@bitmap = Wx::Bitmap.new( @img )
|
11
|
-
@zoom = 0
|
12
|
-
# check height & widget to set size of child window
|
13
|
-
# @bitmap.get_height
|
14
|
-
# sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
15
|
-
# sizer.add(img, 1, Wx::SHAPED|Wx::GROW, 5)
|
16
|
-
super(*args) do
|
17
|
-
# client_size = Wx::Size.new(@bitmap.width, @bitmap.height)
|
18
|
-
set_client_size(Wx::Size.new(@bitmap.width, @bitmap.height))
|
19
|
-
end
|
20
|
-
self.set_cursor( Wx::Cursor.new(Wx::CURSOR_MAGNIFIER) )
|
21
|
-
evt_paint { on_paint }
|
22
|
-
evt_left_up { | e | zoom_in(e) }
|
23
|
-
evt_right_up { | e | zoom_out(e) }
|
24
|
-
end
|
25
|
-
|
26
|
-
def on_paint
|
27
|
-
paint do | dc |
|
28
|
-
dc.clear
|
29
|
-
dc.draw_bitmap(@bitmap, 0, 0, false)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def zoom_in(*args)
|
34
|
-
@zoom += 1
|
35
|
-
zoom(*args)
|
36
|
-
end
|
37
|
-
|
38
|
-
def zoom_out(*args)
|
39
|
-
@zoom -= 1
|
40
|
-
zoom(*args)
|
41
|
-
end
|
42
|
-
|
43
|
-
def zoom(event)
|
44
|
-
img_x2 = @img.scale(@img.get_width * ( 2 ** @zoom ),
|
45
|
-
@img.get_height * ( 2 ** @zoom) )
|
46
|
-
#rotate90
|
47
|
-
@bitmap = Wx::Bitmap.new( img_x2 )
|
48
|
-
dc = Wx::ClientDC.new(self)
|
49
|
-
dc.clear
|
50
|
-
dc.draw_bitmap(@bitmap, 0, 0, false)
|
51
|
-
set_client_size(Wx::Size.new( @img.get_width * ( 2 ** @zoom ),
|
52
|
-
@img.get_height * ( 2 ** @zoom) ) )
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
1
|
+
module QDA
|
2
|
+
module GUI
|
3
|
+
|
4
|
+
class ImageDocumentWindow < InspectorWindow
|
5
|
+
Wx::init_all_image_handlers
|
6
|
+
|
7
|
+
def initialize(image_file, *args)
|
8
|
+
@img = Wx::Image.new(image_file)
|
9
|
+
# magnifier
|
10
|
+
@bitmap = Wx::Bitmap.new( @img )
|
11
|
+
@zoom = 0
|
12
|
+
# check height & widget to set size of child window
|
13
|
+
# @bitmap.get_height
|
14
|
+
# sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
15
|
+
# sizer.add(img, 1, Wx::SHAPED|Wx::GROW, 5)
|
16
|
+
super(*args) do
|
17
|
+
# client_size = Wx::Size.new(@bitmap.width, @bitmap.height)
|
18
|
+
set_client_size(Wx::Size.new(@bitmap.width, @bitmap.height))
|
19
|
+
end
|
20
|
+
self.set_cursor( Wx::Cursor.new(Wx::CURSOR_MAGNIFIER) )
|
21
|
+
evt_paint { on_paint }
|
22
|
+
evt_left_up { | e | zoom_in(e) }
|
23
|
+
evt_right_up { | e | zoom_out(e) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def on_paint
|
27
|
+
paint do | dc |
|
28
|
+
dc.clear
|
29
|
+
dc.draw_bitmap(@bitmap, 0, 0, false)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def zoom_in(*args)
|
34
|
+
@zoom += 1
|
35
|
+
zoom(*args)
|
36
|
+
end
|
37
|
+
|
38
|
+
def zoom_out(*args)
|
39
|
+
@zoom -= 1
|
40
|
+
zoom(*args)
|
41
|
+
end
|
42
|
+
|
43
|
+
def zoom(event)
|
44
|
+
img_x2 = @img.scale(@img.get_width * ( 2 ** @zoom ),
|
45
|
+
@img.get_height * ( 2 ** @zoom) )
|
46
|
+
#rotate90
|
47
|
+
@bitmap = Wx::Bitmap.new( img_x2 )
|
48
|
+
dc = Wx::ClientDC.new(self)
|
49
|
+
dc.clear
|
50
|
+
dc.draw_bitmap(@bitmap, 0, 0, false)
|
51
|
+
set_client_size(Wx::Size.new( @img.get_width * ( 2 ** @zoom ),
|
52
|
+
@img.get_height * ( 2 ** @zoom) ) )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|