Class: CDK::SCROLLER
Instance Attribute Summary
Attributes inherited from CDKOBJS
#BXAttr, #HZChar, #LLChar, #LRChar, #ULChar, #URChar, #VTChar, #accepts_focus, #binding_list, #border_size, #box, #exit_type, #has_focus, #is_visible, #screen, #screen_index
Instance Method Summary
collapse
Methods inherited from CDKOBJS
#SCREEN_XPOS, #SCREEN_YPOS, #bind, #bindableObject, #checkBind, #cleanBindings, #cleanTitle, #destroy, #draw, #drawTitle, #erase, #focus, #getBox, #getc, #getch, #inject, #isBind, #move, #move_specific, #object_type, #position, #refreshData, #saveData, #setBXattr, #setBackgroundColor, #setBox, #setExitType, #setHZchar, #setLLchar, #setLRchar, #setPostProcess, #setPreProcess, #setTitle, #setULchar, #setURchar, #setVTchar, #unbind, #unfocus, #validCDKObject, #validObjType
Constructor Details
Returns a new instance of SCROLLER.
4
5
6
|
# File 'lib/cdk/scroller.rb', line 4
def initialize
super()
end
|
Instance Method Details
#getCurrentItem ⇒ Object
Get/Set the current item number of the scroller.
175
176
177
|
# File 'lib/cdk/scroller.rb', line 175
def getCurrentItem
@current_item
end
|
#KEY_DOWN ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/cdk/scroller.rb', line 30
def KEY_DOWN
if @list_size > 0
if @current_item < @list_size - 1
if @current_high == @view_size - 1
if @current_top < @max_top_item
@current_top += 1
@current_item += 1
else
CDK.Beep
end
else
@current_item += 1
@current_high += 1
end
else
CDK.Beep
end
else
CDK.Beep
end
end
|
#KEY_END ⇒ Object
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/cdk/scroller.rb', line 118
def KEY_END
if @max_top_item == -1
@current_top = 0
@current_item = @last_item - 1
else
@current_top = @max_top_item
@current_item = @last_item
end
@current_high = @view_size - 1
end
|
#KEY_HOME ⇒ Object
112
113
114
115
116
|
# File 'lib/cdk/scroller.rb', line 112
def KEY_HOME
@current_top = 0
@current_item = 0
@current_high = 0
end
|
#KEY_LEFT ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/cdk/scroller.rb', line 52
def KEY_LEFT
if @list_size > 0
if @left_char == 0
CDK.Beep
else
@left_char -= 1
end
else
CDK.Beep
end
end
|
#KEY_NPAGE ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/cdk/scroller.rb', line 93
def KEY_NPAGE
if @list_size > 0
if @current_top < @max_top_item
if @current_top + @view_size - 1 <= @max_top_item
@current_top += @view_size - 1
@current_item += @view_size - 1
else
@current_top = @max_top_item
@current_item = @last_item
@current_high = @view_size - 1
end
else
CDK.Beep
end
else
CDK.Beep
end
end
|
#KEY_PPAGE ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/cdk/scroller.rb', line 76
def KEY_PPAGE
if @list_size > 0
if @current_top > 0
if @current_top >= @view_size - 1
@current_top -= @view_size - 1
@current_item -= @view_size - 1
else
self.KEY_HOME
end
else
CDK.Beep
end
else
CDK.Beep
end
end
|
#KEY_RIGHT ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/cdk/scroller.rb', line 64
def KEY_RIGHT
if @list_size > 0
if @left_char >= @max_left_char
CDK.Beep
else
@left_char += 1
end
else
CDK.Beep
end
end
|
#KEY_UP ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/cdk/scroller.rb', line 8
def KEY_UP
if @list_size > 0
if @current_item > 0
if @current_high == 0
if @current_top != 0
@current_top -= 1
@current_item -= 1
else
CDK.Beep
end
else
@current_item -= 1
@current_high -= 1
end
else
CDK.Beep
end
else
CDK.Beep
end
end
|
#maxViewSize ⇒ Object
129
130
131
|
# File 'lib/cdk/scroller.rb', line 129
def maxViewSize
return @box_height - (2 * @border_size + @title_lines)
end
|
#setCurrentItem(item) ⇒ Object
179
180
181
|
# File 'lib/cdk/scroller.rb', line 179
def setCurrentItem(item)
self.setPosition(item);
end
|
#setPosition(item) ⇒ Object
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/cdk/scroller.rb', line 157
def setPosition(item)
if item <= 0
self.KEY_HOME
elsif item > @list_size - 1
@current_top = @max_top_item
@current_item = @list_size - 1
@current_high = @view_size - 1
elsif item >= @current_top && item < @current_top + @view_size
@current_item = item
@current_high = item - @current_top
else
@current_top = item - (@view_size - 1)
@current_item = item
@current_high = @view_size - 1
end
end
|
#setViewSize(list_size) ⇒ Object
Set variables that depend upon the list_size
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/cdk/scroller.rb', line 134
def setViewSize(list_size)
@view_size = self.maxViewSize
@list_size = list_size
@last_item = list_size - 1
@max_top_item = list_size - @view_size
if list_size < @view_size
@view_size = list_size
@max_top_item = 0
end
if @list_size > 0 && self.maxViewSize > 0
@step = 1.0 * self.maxViewSize / @list_size
@toggle_size = if @list_size > self.maxViewSize
then 1
else @step.ceil
end
else
@step = 1
@toggle_size = 1
end
end
|