rndk 0.2.0 → 1.0.0

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -4
  3. data/TODO +21 -1
  4. data/demos/appointment.rb +279 -299
  5. data/demos/clock.rb +13 -8
  6. data/demos/rss-reader.rb +84 -0
  7. data/examples/01-hello-world.rb +13 -11
  8. data/examples/02-colors.rb +14 -21
  9. data/examples/03-markup.rb +7 -7
  10. data/examples/04-quick-widgets.rb +2 -2
  11. data/examples/05-position-widget.rb +50 -31
  12. data/examples/06-callbacks.rb +77 -0
  13. data/examples/07-traverse.rb +90 -0
  14. data/examples/10-all-widgets.rb +165 -0
  15. data/examples/calendar.rb +20 -32
  16. data/examples/entry.rb +15 -20
  17. data/examples/label.rb +11 -11
  18. data/examples/scroll.rb +16 -60
  19. data/examples/slider.rb +18 -19
  20. data/examples/viewer.rb +65 -0
  21. data/lib/rndk.rb +28 -7
  22. data/lib/rndk/alphalist.rb +309 -313
  23. data/lib/rndk/button.rb +239 -157
  24. data/lib/rndk/buttonbox.rb +136 -103
  25. data/lib/rndk/calendar.rb +246 -203
  26. data/lib/rndk/core/color.rb +63 -13
  27. data/lib/rndk/core/display.rb +1 -1
  28. data/lib/rndk/core/draw.rb +11 -11
  29. data/lib/rndk/core/markup.rb +21 -21
  30. data/lib/rndk/core/quick_widgets.rb +75 -96
  31. data/lib/rndk/core/screen.rb +145 -102
  32. data/lib/rndk/core/traverse.rb +150 -136
  33. data/lib/rndk/core/utils.rb +5 -6
  34. data/lib/rndk/core/widget.rb +207 -191
  35. data/lib/rndk/core/widget_bind.rb +108 -0
  36. data/lib/rndk/dialog.rb +88 -56
  37. data/lib/rndk/entry.rb +79 -64
  38. data/lib/rndk/fscale.rb +38 -20
  39. data/lib/rndk/fslider.rb +38 -23
  40. data/lib/rndk/graph.rb +92 -53
  41. data/lib/rndk/itemlist.rb +80 -62
  42. data/lib/rndk/label.rb +111 -77
  43. data/lib/rndk/radio.rb +138 -128
  44. data/lib/rndk/scale.rb +123 -122
  45. data/lib/rndk/scroll.rb +444 -391
  46. data/lib/rndk/scroller.rb +21 -21
  47. data/lib/rndk/slider.rb +149 -140
  48. data/lib/rndk/template.rb +74 -61
  49. data/lib/rndk/version.rb +1 -1
  50. data/lib/rndk/viewer.rb +499 -298
  51. metadata +8 -14
  52. data/demos/fileview.rb +0 -141
  53. data/lib/rndk/dscale.rb +0 -13
  54. data/lib/rndk/fselect.rb +0 -938
  55. data/lib/rndk/histogram.rb +0 -412
  56. data/lib/rndk/marquee.rb +0 -244
  57. data/lib/rndk/matrix.rb +0 -1189
  58. data/lib/rndk/mentry.rb +0 -619
  59. data/lib/rndk/menu.rb +0 -478
  60. data/lib/rndk/selection.rb +0 -630
  61. data/lib/rndk/swindow.rb +0 -766
  62. data/lib/rndk/uscale.rb +0 -14
  63. data/lib/rndk/uslider.rb +0 -14
@@ -1,24 +1,44 @@
1
1
  require 'rndk/scale'
2
2
 
3
3
  module RNDK
4
- class FSCALE < SCALE
5
- def initialize(rndkscreen,
6
- xplace,
7
- yplace,
8
- title,
9
- label,
10
- field_attr,
11
- field_width,
12
- start,
13
- low,
14
- high,
15
- inc,
16
- fast_inc,
17
- digits,
18
- box,
19
- shadow)
4
+ class Fscale < Scale
5
+ def initialize(screen, config={})
6
+ @widget_type = :Fscale
7
+
8
+ x = 0
9
+ y = 0
10
+ title = "fscale"
11
+ label = "label"
12
+ field_attr = RNDK::Color[:normal]
13
+ field_width = 0
14
+ start = 0
15
+ low = 0
16
+ high = 100
17
+ inc = 1
18
+ fast_inc = 5
19
+ digits = 3
20
+ box = true
21
+ shadow = false
22
+
23
+ config.each do |key, val|
24
+ x = val if key == :x
25
+ y = val if key == :y
26
+ title = val if key == :title
27
+ label = val if key == :label
28
+ field_attr = val if key == :field_attr
29
+ field_width = val if key == :field_width
30
+ start = val if key == :start
31
+ low = val if key == :low
32
+ high = val if key == :high
33
+ inc = val if key == :inc
34
+ fast_inc = val if key == :fast_inc
35
+ digits = val if key == :digits
36
+ box = val if key == :box
37
+ shadow = val if key == :shadow
38
+ end
39
+
20
40
  @digits = digits
21
- super(rndkscreen, xplace, yplace, title, label, field_attr, field_width, start, low, high, inc, fast_inc, box, shadow)
41
+ super(screen, x, y, title, label, field_attr, field_width, start, low, high, inc, fast_inc, box, shadow)
22
42
  end
23
43
 
24
44
  def drawField
@@ -54,8 +74,6 @@ module RNDK
54
74
  '%g%c'
55
75
  end
56
76
 
57
- def object_type
58
- :FSCALE
59
- end
60
77
  end
61
78
  end
79
+
@@ -1,29 +1,47 @@
1
1
  require 'rndk/slider'
2
2
 
3
3
  module RNDK
4
- class FSLIDER < Slider
5
- def initialize(rndkscreen,
6
- xplace,
7
- yplace,
8
- title,
9
- label,
10
- filler,
11
- field_width,
12
- start,
13
- low,
14
- high,
15
- inc,
16
- fast_inc,
17
- digits,
18
- box,
19
- shadow)
4
+ class Fslider < Slider
5
+ def initialize(screen, config={})
6
+ x = 0
7
+ y = 0
8
+ title = "fslider"
9
+ label = "label"
10
+ filler = ' '.ord | RNDK::Color[:reverse]
11
+ field_width = 0
12
+ start = 0
13
+ low = 0
14
+ high = 100
15
+ inc = 1
16
+ fast_inc = 5
17
+ digits = 3
18
+ box = true
19
+ shadow = false
20
+
21
+ config.each do |key, val|
22
+ x = val if key == :x
23
+ y = val if key == :y
24
+ title = val if key == :title
25
+ label = val if key == :label
26
+ filler = val if key == :filler
27
+ field_width = val if key == :field_width
28
+ start = val if key == :start
29
+ low = val if key == :low
30
+ high = val if key == :high
31
+ inc = val if key == :inc
32
+ fast_inc = val if key == :fast_inc
33
+ digits = val if key == :digits
34
+ box = val if key == :box
35
+ shadow = val if key == :shadow
36
+ end
20
37
 
21
38
  @digits = digits
22
- super(rndkscreen, xplace, yplace, title, label, filler, field_width, start, low, high, inc, fast_inc, box, shadow)
39
+ super(screen, x, y, title, label, filler, field_width, start, low, high, inc, fast_inc, box, shadow)
40
+ @widget_type = :fslider
23
41
  end
24
42
 
25
43
  # This draws the widget.
26
- def drawField
44
+ def draw_field
27
45
  step = 1.0 * @field_width / (@high - @low)
28
46
 
29
47
  # Determine how many filler characters need to be drawn.
@@ -45,7 +63,7 @@ module RNDK
45
63
  @field_width,
46
64
  0,
47
65
  temp,
48
- Ncurses::A_NORMAL,
66
+ RNDK::Color[:normal],
49
67
  RNDK::HORIZONTAL,
50
68
  0,
51
69
  temp.size)
@@ -54,7 +72,7 @@ module RNDK
54
72
  Ncurses.wrefresh(@field_win)
55
73
  end
56
74
 
57
- def formattedSize(value)
75
+ def formatted_size(value)
58
76
  digits = [@digits, 30].min
59
77
  format = '%%.%if' % [digits]
60
78
  temp = format % [value]
@@ -73,8 +91,5 @@ module RNDK
73
91
  '%g%c'
74
92
  end
75
93
 
76
- def object_type
77
- :FSLIDER
78
- end
79
94
  end
80
95
  end
@@ -1,38 +1,75 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class GRAPH < Widget
5
- def initialize(rndkscreen,
6
- xplace,
7
- yplace,
8
- height,
9
- width,
10
- title,
11
- xtitle,
12
- ytitle)
4
+
5
+ # TODO Fix how this widget is displayed onscreen.
6
+ #
7
+ # ## Signals
8
+ #
9
+ # For info, see Signals section on Widget class.
10
+ #
11
+ # ### :before_set_data
12
+ #
13
+ # * when: right before Graph#set_values fix the new values
14
+ # into the widget.
15
+ # * argument: The **new data** to be fixed
16
+ # * effect when return false: Interrupt fixing the data,
17
+ # old data is kept.
18
+ #
19
+ # ### :after_set_data
20
+ #
21
+ # * when: right after Graph#set_values does it's job.
22
+ # * argument: The **new data** as an argument.
23
+ #
24
+ class Graph < Widget
25
+
26
+ def initialize(screen, config={})
13
27
  super()
14
- parent_width = Ncurses.getmaxx rndkscreen.window
15
- parent_height = Ncurses.getmaxy rndkscreen.window
28
+ @widget_type = :graph
29
+ @supported_signals += [:before_set_data, :after_set_data]
30
+
31
+ x = 0
32
+ y = 0
33
+ width = 0
34
+ height = 0
35
+ title = " graph" # MUST HAVE TWO SPACES BECAUSE OF FUCK
36
+ xtitle = "x"
37
+ ytitle = "y"
38
+ box = true
39
+
40
+ config.each do |key, val|
41
+ x = val if key == :x
42
+ y = val if key == :y
43
+ width = val if key == :width
44
+ height = val if key == :height
45
+ title = val if key == :title
46
+ xtitle = val if key == :xtitle
47
+ ytitle = val if key == :ytitle
48
+ box = val if key == :box
49
+ end
50
+
51
+ parent_width = Ncurses.getmaxx screen.window
52
+ parent_height = Ncurses.getmaxy screen.window
16
53
 
17
54
  self.set_box(false)
18
55
 
19
- box_height = RNDK.setWidgetDimension(parent_height, height, 3)
20
- box_width = RNDK.setWidgetDimension(parent_width, width, 0)
56
+ box_height = RNDK.set_widget_dimension(parent_height, height, 3)
57
+ box_width = RNDK.set_widget_dimension(parent_width, width, 0)
21
58
  box_width = self.set_title(title, box_width)
22
59
  box_height += @title_lines
23
60
  box_width = [parent_width, box_width].min
24
61
  box_height = [parent_height, box_height].min
25
62
 
26
63
  # Rejustify the x and y positions if we need to
27
- xtmp = [xplace]
28
- ytmp = [yplace]
29
- RNDK.alignxy(rndkscreen.window, xtmp, ytmp, box_width, box_height)
64
+ xtmp = [x]
65
+ ytmp = [y]
66
+ RNDK.alignxy(screen.window, xtmp, ytmp, box_width, box_height)
30
67
  xpos = xtmp[0]
31
68
  ypos = ytmp[0]
32
69
 
33
70
  # Create the widget pointer
34
- @screen = rndkscreen
35
- @parent = rndkscreen.window
71
+ @screen = screen
72
+ @parent = screen.window
36
73
  @win = Ncurses.newwin(box_height, box_width, ypos, xpos)
37
74
  @box_height = box_height
38
75
  @box_width = box_width
@@ -42,6 +79,7 @@ module RNDK
42
79
  @yscale = 0
43
80
  @count = 0
44
81
  @display_type = :LINE
82
+ @box = box
45
83
 
46
84
  if @win.nil?
47
85
  self.destroy
@@ -84,24 +122,24 @@ module RNDK
84
122
  @graph_char = 0
85
123
  @values = []
86
124
 
87
- rndkscreen.register(:GRAPH, self)
125
+ screen.register(@widget_type, self)
88
126
  end
89
127
 
90
128
  # This was added for the builder.
91
- def activate(actions)
92
- self.draw(@box)
129
+ def activate(actions=[])
130
+ self.draw
93
131
  end
94
132
 
95
133
  # Set multiple attributes of the widget
96
- def set(values, count, graph_char, start_at_zero, display_type)
97
- ret = self.setValues(values, count, start_at_zero)
134
+ def set(values, graph_char, start_at_zero, display_type)
135
+ ret = self.set_values(values, start_at_zero)
98
136
  self.setCharacters(graph_char)
99
137
  self.setDisplayType(display_type)
100
138
  return ret
101
139
  end
102
140
 
103
141
  # Set the scale factors for the graph after wee have loaded new values.
104
- def setScales
142
+ def set_scales
105
143
  @xscale = (@maxx - @minx) / [1, @box_height - @title_lines - 5].max
106
144
  if @xscale <= 0
107
145
  @xscale = 1
@@ -114,7 +152,9 @@ module RNDK
114
152
  end
115
153
 
116
154
  # Set the values of the graph.
117
- def setValues(values, count, start_at_zero)
155
+ def set_values(values, start_at_zero)
156
+ count = values.size
157
+
118
158
  min = 2**30
119
159
  max = -2**30
120
160
 
@@ -123,6 +163,9 @@ module RNDK
123
163
  return false
124
164
  end
125
165
 
166
+ keep_going = self.run_signal_binding(:before_set_data)
167
+ return if not keep_going
168
+
126
169
  if !(@values.nil?) && @values.size > 0
127
170
  @values = []
128
171
  @count = 0
@@ -147,18 +190,18 @@ module RNDK
147
190
  @minx = 0
148
191
  end
149
192
 
150
- self.setScales
151
-
152
- return true
193
+ self.set_scales
194
+ self.run_signal_binding(:after_set_data)
195
+ true
153
196
  end
154
197
 
155
198
  def getValues(size)
156
199
  size << @count
157
- return @values
200
+ @values
158
201
  end
159
202
 
160
203
  # Set the value of the graph at the given index.
161
- def setValue(index, value, start_at_zero)
204
+ def set_value(index, value, start_at_zero)
162
205
  # Make sure the index is within range.
163
206
  if index < 0 || index >= @count
164
207
  return false
@@ -174,9 +217,8 @@ module RNDK
174
217
  @minx = 0
175
218
  end
176
219
 
177
- self.setScales
178
-
179
- return true
220
+ self.set_scales
221
+ true
180
222
  end
181
223
 
182
224
  def getValue(index)
@@ -236,22 +278,22 @@ module RNDK
236
278
  end
237
279
 
238
280
  # Set the background attribute of the widget.
239
- def set_bg_attrib(attrib)
281
+ def set_bg_color(attrib)
240
282
  Ncurses.wbkgd(@win, attrib)
241
283
  end
242
284
 
243
285
  # Move the graph field to the given location.
244
- def move(xplace, yplace, relative, refresh_flag)
286
+ def move(x, y, relative, refresh_flag)
245
287
  current_x = Ncurses.getbegx(@win)
246
288
  current_y = Ncurses.getbegy(@win)
247
- xpos = xplace
248
- ypos = yplace
289
+ xpos = x
290
+ ypos = y
249
291
 
250
292
  # If this is a relative move, then we will adjust where we want
251
293
  # to move to
252
294
  if relative
253
- xpos = Ncurses.getbegx(@win) + xplace
254
- ypos = Ncurses.getbegy(@win) + yplace
295
+ xpos = Ncurses.getbegx(@win) + x
296
+ ypos = Ncurses.getbegy(@win) + y
255
297
  end
256
298
 
257
299
  # Adjust the window if we need to.
@@ -274,15 +316,15 @@ module RNDK
274
316
 
275
317
  # Reraw the windowk if they asked for it
276
318
  if refresh_flag
277
- self.draw(@box)
319
+ self.draw
278
320
  end
279
321
  end
280
322
 
281
- # Draw the grpah widget
282
- def draw(box)
323
+ # Draw the graph widget
324
+ def draw(box=false)
283
325
  adj = 2 + (if @xtitle.nil? || @xtitle.size == 0 then 0 else 1 end)
284
326
  spacing = 0
285
- attrib = ' '.ord | Ncurses::A_REVERSE
327
+ attrib = ' '.ord | RNDK::Color[:reverse]
286
328
 
287
329
  if box
288
330
  Draw.drawObjBox(@win, self)
@@ -304,12 +346,12 @@ module RNDK
304
346
  @box_height - 3,
305
347
  Ncurses::ACS_HLINE)
306
348
 
307
- self.drawTitle(@win)
349
+ self.draw_title(@win)
308
350
 
309
351
  # Draw in the X axis title.
310
352
  if !(@xtitle.nil?) && @xtitle.size > 0
311
353
  Draw.writeChtype(@win, 0, @xtitle_pos, @xtitle, RNDK::VERTICAL, 0, @xtitle_len)
312
- attrib = @xtitle[0] & Ncurses::A_ATTRIBUTES
354
+ attrib = @xtitle[0] & RNDK::Color[:extract]
313
355
  end
314
356
 
315
357
  # Draw in the X axis high value
@@ -377,25 +419,22 @@ module RNDK
377
419
  end
378
420
 
379
421
  def destroy
380
- self.cleanTitle
381
- self.clean_bindings(:GRAPH)
382
- RNDK::Screen.unregister(:GRAPH, self)
422
+ self.clean_title
423
+ self.clean_bindings
424
+ @screen.unregister self
383
425
  RNDK.window_delete(@win)
384
426
  end
385
427
 
386
428
  def erase
387
- if self.valid_widget?
429
+ if self.valid?
388
430
  RNDK.window_erase(@win)
389
431
  end
390
432
  end
391
433
 
392
- def object_type
393
- :GRAPH
394
- end
395
-
396
434
  def position
397
435
  super(@win)
398
436
  end
437
+
399
438
  end
400
439
  end
401
440
 
@@ -1,15 +1,40 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class ITEMLIST < Widget
5
- def initialize(rndkscreen, xplace, yplace, title, label, item, count,
6
- default_item, box, shadow)
4
+
5
+ class Itemlist < Widget
6
+
7
+ def initialize(screen, config={})
7
8
  super()
8
- parent_width = Ncurses.getmaxx(rndkscreen.window)
9
- parent_height = Ncurses.getmaxy(rndkscreen.window)
9
+ @widget_type = :itemlist
10
+ @supported_signals += [:before_input, :after_input]
11
+
12
+ x = 0
13
+ y = 0
14
+ title = "itemlist"
15
+ label = "label"
16
+ items = []
17
+ default_item = 0
18
+ box = true
19
+ shadow = false
20
+
21
+ config.each do |key, val|
22
+ x = val if key == :x
23
+ y = val if key == :y
24
+ title = val if key == :title
25
+ label = val if key == :label
26
+ items = val if key == :items
27
+ default_item = val if key == :default_item
28
+ box = val if key == :box
29
+ shadow = val if key == :shadow
30
+ end
31
+
32
+ count = items.size
33
+ parent_width = Ncurses.getmaxx(screen.window)
34
+ parent_height = Ncurses.getmaxy(screen.window)
10
35
  field_width = 0
11
36
 
12
- if !self.createList(item, count)
37
+ if !self.create_list items
13
38
  self.destroy
14
39
  return nil
15
40
  end
@@ -41,9 +66,9 @@ module RNDK
41
66
  self.updateFieldWidth
42
67
 
43
68
  # Rejustify the x and y positions if we need to.
44
- xtmp = [xplace]
45
- ytmp = [yplace]
46
- RNDK.alignxy(rndkscreen.window, xtmp, ytmp, box_width, box_height)
69
+ xtmp = [x]
70
+ ytmp = [y]
71
+ RNDK.alignxy(screen.window, xtmp, ytmp, box_width, box_height)
47
72
  xpos = xtmp[0]
48
73
  ypos = ytmp[0]
49
74
 
@@ -77,8 +102,8 @@ module RNDK
77
102
  end
78
103
 
79
104
  # Set up the rest of the structure
80
- @screen = rndkscreen
81
- @parent = rndkscreen.window
105
+ @screen = screen
106
+ @parent = screen.window
82
107
  @shadow_win = nil
83
108
  @accepts_focus = true
84
109
  @shadow = shadow
@@ -103,22 +128,22 @@ module RNDK
103
128
  end
104
129
 
105
130
  # Register this baby.
106
- rndkscreen.register(:ITEMLIST, self)
131
+ screen.register(@widget_type, self)
107
132
  end
108
133
 
109
134
  # This allows the user to play with the widget.
110
- def activate(actions)
111
- ret = -1
135
+ def activate(actions=[])
136
+ ret = false
112
137
 
113
138
  # Draw the widget.
114
- self.draw(@box)
115
- self.drawField(true)
139
+ self.draw
140
+ self.draw_field(true)
116
141
 
117
142
  if actions.nil? || actions.size == 0
118
143
  input = 0
119
144
 
120
145
  while true
121
- input = self.getch([])
146
+ input = self.getch
122
147
 
123
148
  # Inject the character into the widget.
124
149
  ret = self.inject(input)
@@ -142,28 +167,26 @@ module RNDK
142
167
  end
143
168
 
144
169
  # This injects a single character into the widget.
145
- def inject(input)
146
- pp_return = 1
147
- ret = -1
170
+ def inject input
171
+ pp_return = true
172
+ ret = false
148
173
  complete = false
149
174
 
150
175
  # Set the exit type.
151
176
  self.set_exit_type(0)
152
177
 
153
178
  # Draw the widget field
154
- self.drawField(true)
179
+ self.draw_field(true)
155
180
 
156
181
  # Check if there is a pre-process function to be called.
157
- unless @pre_process_func.nil?
158
- pp_return = @pre_process_func.call(:ITEMLIST, self,
159
- @pre_process_data, input)
160
- end
182
+ keep_going = self.run_signal_binding(:before_input, input)
183
+
184
+ if keep_going
161
185
 
162
- # Should we continue?
163
- if pp_return != 0
164
186
  # Check a predefined binding.
165
- if self.checkBind(:ITEMLIST, input)
166
- complete = true
187
+ if self.is_bound? input
188
+ self.run_key_binding input
189
+ #complete = true
167
190
  else
168
191
  case input
169
192
  when Ncurses::KEY_UP, Ncurses::KEY_RIGHT, ' '.ord, '+'.ord, 'n'.ord
@@ -203,13 +226,11 @@ module RNDK
203
226
  end
204
227
 
205
228
  # Should we call a post-process?
206
- if !complete && !(@post_process_func.nil?)
207
- @post_process_func.call(:ITEMLIST, self, @post_process_data, input)
208
- end
229
+ self.run_signal_binding(:after_input) if not complete
209
230
  end
210
231
 
211
232
  if !complete
212
- self.drawField(true)
233
+ self.draw_field(true)
213
234
  self.set_exit_type(0)
214
235
  end
215
236
 
@@ -218,20 +239,18 @@ module RNDK
218
239
  end
219
240
 
220
241
  # This moves the itemlist field to the given location.
221
- def move(xplace, yplace, relative, refresh_flag)
242
+ def move(x, y, relative, refresh_flag)
222
243
  windows = [@win, @field_win, @label_win, @shadow_win]
223
- self.move_specific(xplace, yplace, relative, refresh_flag,
224
- windows, [])
244
+
245
+ self.move_specific(x, y, relative, refresh_flag, windows, [])
225
246
  end
226
247
 
227
248
  # This draws the widget on the screen.
228
- def draw(box)
249
+ def draw
229
250
  # Did we ask for a shadow?
230
- unless @shadow_win.nil?
231
- Draw.drawShadow(@shadow_win)
232
- end
251
+ Draw.drawShadow(@shadow_win) unless @shadow_win.nil?
233
252
 
234
- self.drawTitle(@win)
253
+ self.draw_title(@win)
235
254
 
236
255
  # Draw in the label to the widget.
237
256
  unless @label_win.nil?
@@ -240,25 +259,23 @@ module RNDK
240
259
  end
241
260
 
242
261
  # Box the widget if asked.
243
- if box
244
- Draw.drawObjBox(@win, self)
245
- end
262
+ Draw.drawObjBox(@win, self) if @box
246
263
 
247
264
  Ncurses.wrefresh @win
248
265
 
249
266
  # Draw in the field.
250
- self.drawField(false)
267
+ self.draw_field(false)
251
268
  end
252
269
 
253
270
  # This sets the background attribute of the widget
254
- def set_bg_attrib(attrib)
271
+ def set_bg_color(attrib)
255
272
  Ncurses.wbkgd(@win, attrib)
256
273
  Ncurses.wbkgd(@field_win, attrib)
257
274
  Ncurses.wbkgd(@label_win, attrib) unless @label_win.nil?
258
275
  end
259
276
 
260
277
  # This function draws the contents of the field.
261
- def drawField(highlight)
278
+ def draw_field(highlight)
262
279
  # Declare local vars.
263
280
  current_item = @current_item
264
281
 
@@ -273,7 +290,7 @@ module RNDK
273
290
  c = @item[current_item][x]
274
291
 
275
292
  if highlight
276
- c = c.ord | Ncurses::A_REVERSE
293
+ c = c.ord | RNDK::Color[:reverse]
277
294
  end
278
295
 
279
296
  Ncurses.mvwaddch(@field_win, 0, x + @item_pos[current_item], c)
@@ -285,7 +302,7 @@ module RNDK
285
302
 
286
303
  # This function removes the widget from the screen.
287
304
  def erase
288
- if self.valid_widget?
305
+ if self.valid?
289
306
  RNDK.window_erase(@field_win)
290
307
  RNDK.window_erase(@label_win)
291
308
  RNDK.window_erase(@win)
@@ -300,7 +317,7 @@ module RNDK
300
317
 
301
318
  # This function destroys the widget and all the memory it used.
302
319
  def destroy
303
- self.cleanTitle
320
+ self.clean_title
304
321
  self.destroyInfo
305
322
 
306
323
  # Delete the windows
@@ -310,20 +327,20 @@ module RNDK
310
327
  RNDK.window_delete(@win)
311
328
 
312
329
  # Clean the key bindings.
313
- self.clean_bindings(:ITEMLIST)
330
+ self.clean_bindings
314
331
 
315
- RNDK::Screen.unregister(:ITEMLIST, self)
332
+ @screen.unregister self
316
333
  end
317
334
 
318
335
  # This sets multiple attributes of the widget.
319
336
  def set(list, count, current, box)
320
- self.setValues(list, count, current)
337
+ self.set_values(list, count, current)
321
338
  self.set_box(box)
322
339
  end
323
340
 
324
341
  # This function sets the contents of the list
325
- def setValues(item, count, default_item)
326
- if self.createList(item, count)
342
+ def set_values(item, default_item)
343
+ if self.create_list item
327
344
  old_width = @field_width
328
345
 
329
346
  # Set the default item.
@@ -341,7 +358,7 @@ module RNDK
341
358
 
342
359
  # Draw the field.
343
360
  self.erase
344
- self.draw(@box)
361
+ self.draw
345
362
  end
346
363
  end
347
364
 
@@ -379,14 +396,16 @@ module RNDK
379
396
  end
380
397
 
381
398
  def focus
382
- self.drawField(true)
399
+ self.draw_field(true)
383
400
  end
384
401
 
385
402
  def unfocus
386
- self.drawField(false)
403
+ self.draw_field(false)
387
404
  end
388
405
 
389
- def createList(item, count)
406
+ def create_list item
407
+ count = item.size
408
+
390
409
  status = false
391
410
  new_items = []
392
411
  new_pos = []
@@ -467,8 +486,7 @@ module RNDK
467
486
  super(@win)
468
487
  end
469
488
 
470
- def object_type
471
- :ITEMLIST
472
- end
489
+
490
+
473
491
  end
474
492
  end