rbcurse 0.1.3 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +126 -0
- data/Manifest.txt +53 -20
- data/README.markdown +423 -0
- data/Rakefile +3 -1
- data/examples/keytest.rb +177 -0
- data/examples/mpad2.rb +156 -0
- data/examples/newtesttabp.rb +121 -0
- data/examples/rfe.rb +48 -10
- data/examples/rfe_renderer.rb +4 -4
- data/examples/rvimsplit.rb +376 -0
- data/examples/sqlc.rb +97 -106
- data/examples/sqlm.rb +446 -0
- data/examples/test1.rb +4 -4
- data/examples/test2.rb +12 -12
- data/examples/testchars.rb +140 -0
- data/examples/testkeypress.rb +9 -4
- data/examples/testmulticomp.rb +72 -0
- data/examples/testscroller.rb +136 -0
- data/examples/testscrolllb.rb +86 -0
- data/examples/testscrollp.rb +87 -0
- data/examples/testscrollta.rb +80 -0
- data/examples/testscrolltable.rb +166 -0
- data/examples/testsplit.rb +87 -0
- data/examples/testsplit2.rb +123 -0
- data/examples/testsplit3.rb +215 -0
- data/examples/testsplit3_1.rb +244 -0
- data/examples/testsplit3a.rb +215 -0
- data/examples/testsplit3b.rb +237 -0
- data/examples/testsplitta.rb +148 -0
- data/examples/testsplittv.rb +142 -0
- data/examples/testsplittvv.rb +144 -0
- data/examples/testtable.rb +1 -1
- data/examples/testtabp.rb +3 -2
- data/examples/testtestw.rb +69 -0
- data/examples/testtodo.rb +5 -3
- data/examples/testtpane.rb +203 -0
- data/examples/testtpane2.rb +145 -0
- data/examples/testtpanetable.rb +199 -0
- data/examples/viewtodo.rb +5 -3
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/celleditor.rb +2 -2
- data/lib/rbcurse/colormap.rb +5 -5
- data/lib/rbcurse/defaultlistselectionmodel.rb +3 -3
- data/lib/rbcurse/io.rb +663 -0
- data/lib/rbcurse/listeditable.rb +306 -0
- data/lib/rbcurse/listkeys.rb +15 -15
- data/lib/rbcurse/listscrollable.rb +168 -27
- data/lib/rbcurse/mapper.rb +35 -13
- data/lib/rbcurse/rchangeevent.rb +28 -0
- data/lib/rbcurse/rform.rb +845 -0
- data/lib/rbcurse/rlistbox.rb +144 -34
- data/lib/rbcurse/rmessagebox.rb +10 -5
- data/lib/rbcurse/rmulticontainer.rb +325 -0
- data/lib/rbcurse/rmultitextview.rb +306 -0
- data/lib/rbcurse/rscrollform.rb +369 -0
- data/lib/rbcurse/rscrollpane.rb +511 -0
- data/lib/rbcurse/rsplitpane.rb +820 -0
- data/lib/rbcurse/rtabbedpane.rb +737 -109
- data/lib/rbcurse/rtabbedwindow.rb +326 -0
- data/lib/rbcurse/rtable.rb +220 -64
- data/lib/rbcurse/rtextarea.rb +340 -181
- data/lib/rbcurse/rtextview.rb +237 -101
- data/lib/rbcurse/rviewport.rb +203 -0
- data/lib/rbcurse/rwidget.rb +919 -95
- data/lib/rbcurse/scrollable.rb +7 -7
- data/lib/rbcurse/selectable.rb +4 -4
- data/lib/rbcurse/table/tablecellrenderer.rb +3 -0
- data/lib/rbcurse/undomanager.rb +181 -0
- data/lib/rbcurse/vieditable.rb +100 -0
- data/lib/ver/window.rb +471 -21
- metadata +66 -22
- data/README.txt +0 -312
- data/examples/testd.db +0 -0
- data/examples/todocsv.csv +0 -28
@@ -0,0 +1,511 @@
|
|
1
|
+
=begin
|
2
|
+
* Name: Scrollpane
|
3
|
+
* Description: a scrollable widget allowing user to scroll and view
|
4
|
+
parts of underlying object that typically are larger than screen area.
|
5
|
+
Mainly, contains a viewport, scrollbars and manages viewport through usage
|
6
|
+
of scrollbars.
|
7
|
+
Also contains viewport for row and columns.
|
8
|
+
* Author: rkumar
|
9
|
+
Todo section:
|
10
|
+
- add events, property changed etc at least for scrolling - DONE
|
11
|
+
SCrollpane normall should listen in to changes in viewport, however Scro calls those very methods
|
12
|
+
and what's more, other classes would listen to SCR and not to VP.
|
13
|
+
- scrollbars to be classes - shall we avoid over-engineering, and KISS
|
14
|
+
- if scrollpane reduced it should also resize, as example inside splitpane.
|
15
|
+
* file created 2009-10-27 19:20
|
16
|
+
* Added a call to child's set_form_col from set_form_row
|
17
|
+
Major changes 2010-02-11 19:51 to simplify version RFED16
|
18
|
+
* Still need to clean up this and viewport. make as light as possible
|
19
|
+
* If scrolling, no repainting should happen. Scrollpane could get the buffer
|
20
|
+
and scroll itself. Or ensure that inner object does not rework...
|
21
|
+
|
22
|
+
Pass handle_key to child, also repaint refer child.
|
23
|
+
Avoid passing to viewport as this would slow down alot.
|
24
|
+
|
25
|
+
NOTE: if a caller is interested in knowing what scrolling has happened, pls bind to :STATE_CHANGE, you will receive the viewport object. If you find this cumbersome, and wish to know only about scrolling, we can put in a scrolling event and inform of row or col scrolling. Or we can fire a property change with row or col increment.
|
26
|
+
|
27
|
+
|
28
|
+
--------
|
29
|
+
* License:
|
30
|
+
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
31
|
+
|
32
|
+
=end
|
33
|
+
#require 'rubygems'
|
34
|
+
require 'ncurses'
|
35
|
+
require 'logger'
|
36
|
+
require 'rbcurse'
|
37
|
+
require 'rbcurse/rviewport'
|
38
|
+
|
39
|
+
include Ncurses
|
40
|
+
include RubyCurses
|
41
|
+
module RubyCurses
|
42
|
+
extend self
|
43
|
+
|
44
|
+
##
|
45
|
+
# A scrollable box throgh which one can see portions of underlying object
|
46
|
+
# such as textarea, table or a form, usually the underlying data is larger
|
47
|
+
# than what can be displayed.
|
48
|
+
|
49
|
+
class ScrollPane < Widget
|
50
|
+
# viewport
|
51
|
+
# row_viewport
|
52
|
+
# column_viewport
|
53
|
+
# horizontal scrollbar 0-NONE, 1=ALWAYS, 2=AS_NEEDED
|
54
|
+
# vertical scrollbar 0-NONE, 1=ALWAYS, 2=AS_NEEDED
|
55
|
+
attr_accessor :cascade_changes # should changes in size go down to child, default false
|
56
|
+
|
57
|
+
def initialize form, config={}, &block
|
58
|
+
@focusable = true
|
59
|
+
@editable = false
|
60
|
+
#@left_margin = 1
|
61
|
+
@row = 0
|
62
|
+
@col = 0
|
63
|
+
super
|
64
|
+
@row_offset = @col_offset = 1
|
65
|
+
init_vars
|
66
|
+
# $log.debug " SCROLLPANE recvs form #{form.name}, #{form.window.name} " unless form.nil?
|
67
|
+
|
68
|
+
|
69
|
+
end
|
70
|
+
##
|
71
|
+
# set child component being used in viewport
|
72
|
+
# @see set_viewport_view
|
73
|
+
def child ch
|
74
|
+
if ch != nil
|
75
|
+
@child = ch # added 2010-02-11 15:28 we might do away with viewport, setting panned to child
|
76
|
+
@child.rows_panned = @child.cols_panned = 0
|
77
|
+
|
78
|
+
ch.parent_component = self # added 2010-01-13 12:55 so offsets can go down ?
|
79
|
+
|
80
|
+
@child.should_create_buffer = true
|
81
|
+
@form.add_rows += 2 # related to scr_top XXX What if form not set. i cannot keep accumulating
|
82
|
+
update_child
|
83
|
+
# -3 since we start row +1 to get indented by 1, also we use
|
84
|
+
# height -1 in scrollpane, so we need -2 to indent, and one more
|
85
|
+
# for row
|
86
|
+
set_viewport_view(ch)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
##
|
90
|
+
# update of child's coordinates, needs to be called whenever it
|
91
|
+
# changes, so i need to call it before calling child's update
|
92
|
+
# FIXME - this is become 2 calls, make it one - becoming expensive
|
93
|
+
# if called often
|
94
|
+
def update_child
|
95
|
+
scr_top = 3 # for Pad, if Pad passed as in SplitPane
|
96
|
+
scr_left = 1 # for Pad, if Pad passed as in SplitPane
|
97
|
+
if @form.window.window_type == :WINDOW
|
98
|
+
scr_top = @row + 1
|
99
|
+
scr_left = @col + 1
|
100
|
+
@child.row(@row+@row_offset)
|
101
|
+
@child.col(@col+@col_offset)
|
102
|
+
else
|
103
|
+
# PAD case
|
104
|
+
@child.row(scr_top)
|
105
|
+
@child.col(scr_left)
|
106
|
+
end
|
107
|
+
@child.set_buffering(:target_window => @target_window || @form.window, :form => @form, :bottom => @height-3, :right => @width-3 )
|
108
|
+
@child.set_buffering(:screen_top => scr_top, :screen_left => scr_left)
|
109
|
+
# lets set the childs ext offsets
|
110
|
+
$log.debug "SCRP #{name} adding (to #{@child.name}) ext_row_off: #{@child.ext_row_offset} += #{@ext_row_offset} +#{@row_offset} "
|
111
|
+
$log.debug "SCRP adding ext_col_off: #{@child.ext_col_offset} += #{@ext_col_offset} +#{@col_offset} "
|
112
|
+
## 2010-02-09 18:58 i think we should not put col_offset since the col
|
113
|
+
## of child would take care of that. same for row_offset. XXX
|
114
|
+
@child.ext_col_offset += @ext_col_offset + @col + @col_offset - @screen_left # 2010-02-09 19:14
|
115
|
+
# added row and col setting to child RFED16 2010-02-17 00:22 as
|
116
|
+
# in splitpane. seems we are not using ext_offsets now ? texta
|
117
|
+
# and TV are not. and i've commented off from widget
|
118
|
+
|
119
|
+
$log.debug " #{@child.ext_row_offset} += #{@ext_row_offset} + #{@row} -#{@screen_top} "
|
120
|
+
@child.ext_row_offset += @ext_row_offset + @row + @row_offset - @screen_top
|
121
|
+
# adding this since child's ht should not be less. or we have a
|
122
|
+
# copywin failure
|
123
|
+
@child.height ||= @height
|
124
|
+
@child.width ||= @width
|
125
|
+
if @child.height < @height
|
126
|
+
@child.height = @height
|
127
|
+
end
|
128
|
+
if @child.width < @width
|
129
|
+
@child.width = @width
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
def init_vars
|
134
|
+
#@curpos = @pcol = @toprow = @current_index = 0
|
135
|
+
@hsb_policy = :AS_NEEDED
|
136
|
+
@vsb_policy = :AS_NEEDED
|
137
|
+
@repaint_required = true
|
138
|
+
@repaint_border = true
|
139
|
+
@row_outofbounds=0
|
140
|
+
@col_outofbounds=0
|
141
|
+
@border_width = 2
|
142
|
+
@screen_top = 0
|
143
|
+
@screen_left = 0
|
144
|
+
end
|
145
|
+
# set the component to be viewed
|
146
|
+
def set_viewport_view ch
|
147
|
+
@viewport = Viewport.new nil
|
148
|
+
@viewport.set_view ch
|
149
|
+
## this -2 should depend on whether we are putting border/scrollbars or not.
|
150
|
+
# -1 added on 2010-02-16 23:35 since we are red 1, and bw
|
151
|
+
@viewport.set_view_size(@height-@border_width-0, @width-@border_width-0) # XXX make it one less
|
152
|
+
@viewport.cascade_changes = @cascade_changes # added 2010-02-04 18:19
|
153
|
+
@viewport.bind(:STATE_CHANGE) { |e| view_state_changed(e) }
|
154
|
+
@viewport.bind(:PROPERTY_CHANGE) { |e| view_property_changed(e) }
|
155
|
+
end
|
156
|
+
# return underlying viewport
|
157
|
+
# in order to run some of its methods
|
158
|
+
def get_viewport
|
159
|
+
return @viewport
|
160
|
+
end
|
161
|
+
# Directly set the viewport.
|
162
|
+
# Usually it is best to use set_viewport_view instead
|
163
|
+
def set_viewport vp
|
164
|
+
old = @viewport
|
165
|
+
@viewport = vp
|
166
|
+
fire_property_change "viewport", old, @viewport
|
167
|
+
end
|
168
|
+
# sets the component to be used as a rowheader TODO
|
169
|
+
def set_rowheader_view ch
|
170
|
+
old = @rowheader
|
171
|
+
@rowheader = Viewport.new
|
172
|
+
@rowheader.set_view ch
|
173
|
+
fire_property_change "row_header", old, @rowheader
|
174
|
+
end
|
175
|
+
# sets the component to be used as a column header TODO
|
176
|
+
def set_columnheader_view ch
|
177
|
+
old = @columnheader
|
178
|
+
@columnheader = Viewport.new
|
179
|
+
@columnheader.set_view ch
|
180
|
+
fire_property_change "column_header", old, @columnheader
|
181
|
+
end
|
182
|
+
def set_view_size h,w
|
183
|
+
# calling the property shoudl uniformally trigger fire_property_change
|
184
|
+
@viewport.set_view_size h,w
|
185
|
+
#height(h)
|
186
|
+
#width(w)
|
187
|
+
#fire_handler :PROPERTY_CHANGE, self # XXX should it be an event STATE_CHANGED with details
|
188
|
+
end
|
189
|
+
## seems i wrote this only so i could set repaint_required to true
|
190
|
+
# However, now that VP calls state changed, that will happen XXX
|
191
|
+
def set_view_position r,c
|
192
|
+
ret = @viewport.set_view_position r,c
|
193
|
+
if ret
|
194
|
+
@repaint_required = true if ret
|
195
|
+
# fire_property_change("view_position",
|
196
|
+
end
|
197
|
+
return ret
|
198
|
+
end
|
199
|
+
# this method is registered with Viewport for changes
|
200
|
+
def view_state_changed ev
|
201
|
+
fire_handler :STATE_CHANGE, ev #???
|
202
|
+
@repaint_required = true
|
203
|
+
end
|
204
|
+
# this method is registered with Viewport for changes to properties
|
205
|
+
def view_property_changed ev
|
206
|
+
fire_handler :PROPERTY_CHANGE, ev #???
|
207
|
+
@repaint_required = true
|
208
|
+
end
|
209
|
+
# @return [true, false] false if r,c not changed
|
210
|
+
def increment_view_row num
|
211
|
+
#x r = @viewport.row() #- @viewport.top_margin
|
212
|
+
#x c = @viewport.col() #- @viewport.left_margin
|
213
|
+
r, c = @viewport.get_pad_top_left()
|
214
|
+
$log.debug " SCR inc viewport currently : r #{r} c #{c} "
|
215
|
+
r += num
|
216
|
+
ret = set_view_position r, c
|
217
|
+
v_scroll_bar if ret
|
218
|
+
return ret
|
219
|
+
end
|
220
|
+
# @return [true, false] false if r,c not changed
|
221
|
+
def increment_view_col num
|
222
|
+
r, c = @viewport.get_pad_top_left()
|
223
|
+
#r = @viewport.row() #- @viewport.top_margin
|
224
|
+
#c = @viewport.col() #- @viewport.left_margin
|
225
|
+
c += num
|
226
|
+
ret = set_view_position r, c
|
227
|
+
h_scroll_bar if ret
|
228
|
+
return ret
|
229
|
+
end
|
230
|
+
def repaint # scrollpane
|
231
|
+
# viewports child should repaint onto pad
|
232
|
+
# viewport then clips
|
233
|
+
# this calls viewports refresh from its refresh
|
234
|
+
return unless @repaint_required
|
235
|
+
if @viewport
|
236
|
+
update_child
|
237
|
+
$log.debug "SCRP #{@name} calling viewport repaint"
|
238
|
+
#@viewport.repaint_all true # 2010-01-16 23:09
|
239
|
+
@viewport.repaint_required true # changed 2010-01-19 19:34
|
240
|
+
@viewport.repaint # child's repaint should do it on its pad
|
241
|
+
$log.debug " #{@name} SCRP scrollpane repaint #{@graphic.name} "
|
242
|
+
end
|
243
|
+
# TODO this only if major change
|
244
|
+
if @repaint_border && @repaint_all # added 2010-01-16 20:15
|
245
|
+
#@graphic.wclear
|
246
|
+
$log.debug " #{@name} repaint all scroll: r #{@row} c #{@col} h #{@height}-1 w #{@width} "
|
247
|
+
bordercolor = @border_color || $datacolor
|
248
|
+
borderatt = @border_attrib || Ncurses::A_NORMAL
|
249
|
+
# NOTE - should be width-1 print_b reduces one from width, but
|
250
|
+
# not height !
|
251
|
+
|
252
|
+
@graphic.print_border_only(@row, @col, @height-1, @width, bordercolor, borderatt)
|
253
|
+
h_scroll_bar
|
254
|
+
v_scroll_bar
|
255
|
+
#x XXX @viewport.repaint_all(true) unless @viewport.nil? # brought here 2010-01-19 19:34
|
256
|
+
#@repaint_border = false # commented off on 2010-01-16 20:15 so repaint_all can have effect
|
257
|
+
end
|
258
|
+
return if @viewport == nil
|
259
|
+
$log.debug "SCRP #{@name} calling viewport to SCRP b2s #{@graphic.name} "
|
260
|
+
paint
|
261
|
+
end
|
262
|
+
def getvalue
|
263
|
+
# TODO
|
264
|
+
end
|
265
|
+
## handle keys for scrollpane.
|
266
|
+
# First hands key to child object
|
267
|
+
# If unused, checks to see if it has anything mapped.
|
268
|
+
# If not consumed, returns :UNHANDLED, else 0.
|
269
|
+
def handle_key ch
|
270
|
+
# if this gets key it should just hand it to child
|
271
|
+
return :UNHANDLED if @viewport.nil? # added 2010-02-02 12:44
|
272
|
+
if @viewport != nil
|
273
|
+
$log.debug " calling child handle_key #{ch} "
|
274
|
+
ret = @viewport.handle_key ch
|
275
|
+
# XXX ret returns 0under normal circumstance, so will next line work ?
|
276
|
+
# what i mean is if ret == 0
|
277
|
+
|
278
|
+
@repaint_required = true if ret == 0 # added 2009-12-27 22:21 BUFFERED
|
279
|
+
$log.debug " ... child ret #{ret}"
|
280
|
+
|
281
|
+
|
282
|
+
## Here's the only option scrollpane has of checking whether the child has
|
283
|
+
##+ exceeded boundary BUFFERED 2009-12-29 23:12
|
284
|
+
# TEMPORARILY COMMENTED WHILE TESTING SCROLL UP AND DOWN XXX
|
285
|
+
#fr = @form.row
|
286
|
+
#fc = @form.col
|
287
|
+
#if fr >= @row + @height -2
|
288
|
+
#@form.setrowcol @row + @height -2, fc
|
289
|
+
#elsif fr < @row
|
290
|
+
#@form.setrowcol @row, fc
|
291
|
+
#end
|
292
|
+
#if fc >= @col + @width -1
|
293
|
+
#@form.setrowcol fr, @col + @width -1
|
294
|
+
#end
|
295
|
+
##
|
296
|
+
|
297
|
+
return ret if ret != :UNHANDLED
|
298
|
+
end
|
299
|
+
ret = 0 # default return value
|
300
|
+
ks = keycode_tos(ch)
|
301
|
+
$log.debug " scrollpane gets KEY #{ch}, ks #{ks} "
|
302
|
+
case ch
|
303
|
+
when ?\M-n.getbyte(0)
|
304
|
+
## scroll down one row (unless multiplier set)
|
305
|
+
ret = down
|
306
|
+
when ?\M-p.getbyte(0)
|
307
|
+
## scroll up one row (unless multiplier set)
|
308
|
+
ret = up
|
309
|
+
#when ?0.getbyte(0), ?\C-[.getbyte(0)
|
310
|
+
#goto_start #start of buffer # cursor_start
|
311
|
+
#when ?\C-].getbyte(0)
|
312
|
+
#goto_end # end / bottom cursor_end # TODO
|
313
|
+
when ?\M-\<.getbyte(0)
|
314
|
+
@height.times { up ; }
|
315
|
+
when ?\M-\>.getbyte(0)
|
316
|
+
@height.times { down ; }
|
317
|
+
when KEY_DOWN
|
318
|
+
ret = down
|
319
|
+
#check_curpos
|
320
|
+
when ?\M-h.getbyte(0)
|
321
|
+
## scroll left one position
|
322
|
+
repeatm {
|
323
|
+
ret = cursor_backward
|
324
|
+
@child.cols_panned = @child.cols_panned+1 if ret
|
325
|
+
@form.setrowcol @form.row, @form.col+1+@col_outofbounds if ret
|
326
|
+
}
|
327
|
+
when ?\M-l.getbyte(0)
|
328
|
+
## scroll right one position
|
329
|
+
repeatm {
|
330
|
+
ret = cursor_forward
|
331
|
+
@child.cols_panned = @child.cols_panned-1 if ret
|
332
|
+
@form.setrowcol @form.row, @form.col-1+@col_outofbounds if ret
|
333
|
+
}
|
334
|
+
when KEY_BACKSPACE, 127
|
335
|
+
ret = cursor_backward
|
336
|
+
#when ?\C-u.getbyte(0)
|
337
|
+
## multiplier. Series is 4 16 64
|
338
|
+
#@multiplier = (@multiplier == 0 ? 4 : @multiplier *= 4)
|
339
|
+
#return 0
|
340
|
+
when ?\C-c.getbyte(0)
|
341
|
+
$multiplier = 0
|
342
|
+
return 0
|
343
|
+
else
|
344
|
+
return :UNHANDLED
|
345
|
+
end
|
346
|
+
ret = :UNHANDLED if !ret
|
347
|
+
$multiplier = 0
|
348
|
+
return ret # 0 2010-02-04 18:47 returning ret else repaint is happening when UNHANDLED
|
349
|
+
end
|
350
|
+
# private
|
351
|
+
def _down
|
352
|
+
increment_view_row(1)
|
353
|
+
end
|
354
|
+
# private
|
355
|
+
def _up
|
356
|
+
increment_view_row(-1)
|
357
|
+
end
|
358
|
+
def cursor_forward
|
359
|
+
increment_view_col(1)
|
360
|
+
end
|
361
|
+
def cursor_backward
|
362
|
+
increment_view_col(-1)
|
363
|
+
end
|
364
|
+
def down
|
365
|
+
## scroll down one row (currently one only)
|
366
|
+
$log.debug " MULT DOWN #{$multiplier} "
|
367
|
+
repeatm {
|
368
|
+
ret = _down
|
369
|
+
return unless ret # 2010-02-04 18:29
|
370
|
+
## we've scrolled down, but we need to keep the cursor where
|
371
|
+
##+ editing actually is. Isn't this too specific to textarea ?
|
372
|
+
$log.debug " SCRP setting row to #{@form.row-1} upon scrolling down "
|
373
|
+
## only move up the cursor if its within bounds
|
374
|
+
# if @form.row > @row
|
375
|
+
@child.rows_panned = @child.rows_panned-1 if ret
|
376
|
+
@form.setrowcol @form.row-1+@row_outofbounds, @form.col if ret
|
377
|
+
}
|
378
|
+
end
|
379
|
+
def up
|
380
|
+
## scroll up one row (currently one only)
|
381
|
+
repeatm {
|
382
|
+
ret = _up
|
383
|
+
return unless ret # 2010-02-04 18:29
|
384
|
+
$log.debug " SCRP setting row to #{@form.row+1} upon scrolling up R:#{@row} H:#{@height} "
|
385
|
+
# if @form.row < @row + @height
|
386
|
+
@child.rows_panned = @child.rows_panned+1 if ret
|
387
|
+
@form.setrowcol @form.row+1+@row_outofbounds, @form.col if ret
|
388
|
+
}
|
389
|
+
end
|
390
|
+
def on_enter
|
391
|
+
#super 2010-01-02 18:53 leading to a stack overflow XXX ???
|
392
|
+
set_form_row
|
393
|
+
end
|
394
|
+
# this is called once externally, on on_enter
|
395
|
+
#+ after that its called internally only, which in this case is never
|
396
|
+
def set_form_row
|
397
|
+
#@form.row = @row + 1 unless @form.nil?
|
398
|
+
if @viewport != nil
|
399
|
+
#$log.debug " calling scrollpane set_form_row"
|
400
|
+
ret = @viewport.child.set_form_row # added 2009-12-27 23:23 BUFFERED
|
401
|
+
ret = @viewport.child.set_form_col # added 2010-01-16 21:09
|
402
|
+
end
|
403
|
+
$log.debug " FORM SCRP #{@form.name} "
|
404
|
+
$log.debug "SCRP set_form_row #{@form.row} #{@form.col} "
|
405
|
+
end
|
406
|
+
## added 2010-02-09 10:17
|
407
|
+
# Sometimes some parent objects may just call this.
|
408
|
+
# Would be better if they only called row and row called both ??? or is that less reliable
|
409
|
+
# In any case we have to combine this someday!!
|
410
|
+
def set_form_col
|
411
|
+
#@form.row = @row + 1 unless @form.nil?
|
412
|
+
if @viewport != nil
|
413
|
+
#$log.debug " calling scrollpane set_form_row"
|
414
|
+
ret = @viewport.child.set_form_col # added 2010-01-16 21:09
|
415
|
+
end
|
416
|
+
$log.debug " FORM SCRP #{@form.name} "
|
417
|
+
$log.debug "SCRP set_form_col #{@form.row} #{@form.col} "
|
418
|
+
end
|
419
|
+
|
420
|
+
## this is called once only, on select_field by form.
|
421
|
+
##+ after that not at all.
|
422
|
+
def rowcol
|
423
|
+
r1 = @row #+@row_offset
|
424
|
+
c1 = @col #+@col_offset
|
425
|
+
return r1, c1 if @viewport.nil? # added 2010-02-02 12:41
|
426
|
+
|
427
|
+
r,c = @viewport.child.rowcol # added 2009-12-28 15:23 BUFFERED
|
428
|
+
$log.debug "SCRP rowcol: #{r1} + #{r} , #{c1} + #{c} "
|
429
|
+
return r1+r, c1+c
|
430
|
+
end
|
431
|
+
|
432
|
+
def paint
|
433
|
+
@repaint_required = false
|
434
|
+
@repaint_all = false
|
435
|
+
end
|
436
|
+
def h_scroll_bar
|
437
|
+
return if @viewport.nil?
|
438
|
+
sz = (@viewport.width*1.00/@viewport.child().width)*@viewport.width
|
439
|
+
#$log.debug " h_scroll_bar sz #{sz}, #{@viewport.width} #{@viewport.child().width}"
|
440
|
+
sz = sz.ceil
|
441
|
+
return if sz < 1
|
442
|
+
start = 1
|
443
|
+
start = ((@viewport.col*1.00+@viewport.width)/@viewport.child().width)*@viewport.width
|
444
|
+
start -= sz
|
445
|
+
start = start.ceil
|
446
|
+
# # the problem with next 2 lines is that attributes of border could be overwritten
|
447
|
+
# draw horiz line
|
448
|
+
r = @row #+ @ext_row_offset # 2010-02-11 11:57 RFED16
|
449
|
+
c = @col #+ @ext_col_offset # 2010-02-11 11:57 RFED16
|
450
|
+
$log.debug " h_scroll_bar start #{start}, r #{r} c #{c} h:#{@height} "
|
451
|
+
@graphic.rb_mvwhline(r+@height-1, c+1, ACS_HLINE, @width-2)
|
452
|
+
# draw scroll bar
|
453
|
+
#sz.times{ |i| @graphic.mvaddch(r+@height-1, c+start+1+i, ACS_CKBOARD) }
|
454
|
+
sz.times{ |i| @graphic.rb_mvaddch(r+@height-1, c+start+1+i, ACS_CKBOARD) }
|
455
|
+
end
|
456
|
+
def v_scroll_bar
|
457
|
+
return if @viewport.nil?
|
458
|
+
sz = (@viewport.height*1.00/@viewport.child().height)*@viewport.height
|
459
|
+
#$log.debug " v_scroll_bar sz #{sz}, #{@viewport.width} #{@viewport.child().width}"
|
460
|
+
sz = sz.ceil
|
461
|
+
return if sz < 1
|
462
|
+
start = 1
|
463
|
+
start = ((@viewport.row*1.00+@viewport.height)/@viewport.child().height)*@viewport.height
|
464
|
+
start -= sz
|
465
|
+
r = @row #+ @ext_row_offset # 2010-02-11 11:57 RFED16
|
466
|
+
c = @col #+ @ext_col_offset # 2010-02-11 11:57 RFED16
|
467
|
+
$log.debug " v_scroll_bar start #{start}, col:#{@col} w:#{@width}, r #{r}+1 c #{c}+w-1 "
|
468
|
+
start = start.ceil
|
469
|
+
# # the problem with next 2 lines is that attributes of border could be overwritten
|
470
|
+
# draw verti line
|
471
|
+
# this is needed to erase previous bar when shrinking
|
472
|
+
#@graphic.mvwvline(r+1,c+@width-1, ACS_VLINE, @height-2)
|
473
|
+
@graphic.rb_mvwvline(r+1,c+@width-1, ACS_VLINE, @height-2)
|
474
|
+
# draw scroll bar
|
475
|
+
#sz.times{ |i| @graphic.mvaddch(r+start+1+i, c+@width-1, ACS_CKBOARD) }
|
476
|
+
sz.times{ |i| @graphic.rb_mvaddch(r+start+1+i, c+@width-1, ACS_CKBOARD) }
|
477
|
+
end
|
478
|
+
# set height
|
479
|
+
# a container must pass down changes in size to it's children
|
480
|
+
# 2010-02-04 18:06 - i am not sure about this. When viewport is set then it passes down
|
481
|
+
# changes to child which user did not intend. Maybe in splitpane it is okay but other cases?
|
482
|
+
# Perhaps its okay if scrollpane gets larger than child, not otherwise.
|
483
|
+
# added 2010-01-16 23:55
|
484
|
+
def height(*val)
|
485
|
+
return @height if val.empty?
|
486
|
+
oldvalue = @height || 0
|
487
|
+
super
|
488
|
+
@height = val[0]
|
489
|
+
return if @viewport == nil
|
490
|
+
delta = @height - oldvalue
|
491
|
+
return if delta == 0
|
492
|
+
@repaint_required = true
|
493
|
+
@viewport.height += delta
|
494
|
+
end
|
495
|
+
# set width
|
496
|
+
# a container must pass down changes in size to it's children
|
497
|
+
# added 2010-01-16 23:55
|
498
|
+
def width(*val)
|
499
|
+
return @width if val.empty?
|
500
|
+
oldvalue = @width || 0
|
501
|
+
super
|
502
|
+
@width = val[0]
|
503
|
+
return if @viewport == nil
|
504
|
+
delta = @width - oldvalue
|
505
|
+
return if delta == 0
|
506
|
+
@repaint_required = true
|
507
|
+
@viewport.width += delta
|
508
|
+
end
|
509
|
+
|
510
|
+
end # class ScrollPane
|
511
|
+
end # module
|