rndk 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -7,13 +7,13 @@ module RNDK
7
7
  #
8
8
  # @note Do **not** instantiate this class!
9
9
  # Use it's subclasses.
10
- class SCROLLER < Widget
10
+ class Scroller < Widget
11
11
 
12
12
  def initialize
13
13
  super()
14
14
  end
15
15
 
16
- def KEY_UP
16
+ def scroll_up
17
17
  if @list_size > 0
18
18
  if @current_item > 0
19
19
  if @current_high == 0
@@ -35,7 +35,7 @@ module RNDK
35
35
  end
36
36
  end
37
37
 
38
- def KEY_DOWN
38
+ def scroll_down
39
39
  if @list_size > 0
40
40
  if @current_item < @list_size - 1
41
41
  if @current_high == @view_size - 1
@@ -57,7 +57,7 @@ module RNDK
57
57
  end
58
58
  end
59
59
 
60
- def KEY_LEFT
60
+ def scroll_left
61
61
  if @list_size > 0
62
62
  if @left_char == 0
63
63
  RNDK.beep
@@ -69,7 +69,7 @@ module RNDK
69
69
  end
70
70
  end
71
71
 
72
- def KEY_RIGHT
72
+ def scroll_right
73
73
  if @list_size > 0
74
74
  if @left_char >= @max_left_char
75
75
  RNDK.beep
@@ -81,14 +81,14 @@ module RNDK
81
81
  end
82
82
  end
83
83
 
84
- def KEY_PPAGE
84
+ def scroll_page_up
85
85
  if @list_size > 0
86
86
  if @current_top > 0
87
87
  if @current_top >= @view_size - 1
88
88
  @current_top -= @view_size - 1
89
89
  @current_item -= @view_size - 1
90
90
  else
91
- self.KEY_HOME
91
+ self.scroll_begin
92
92
  end
93
93
  else
94
94
  RNDK.beep
@@ -98,7 +98,7 @@ module RNDK
98
98
  end
99
99
  end
100
100
 
101
- def KEY_NPAGE
101
+ def scroll_page_down
102
102
  if @list_size > 0
103
103
  if @current_top < @max_top_item
104
104
  if @current_top + @view_size - 1 <= @max_top_item
@@ -117,13 +117,13 @@ module RNDK
117
117
  end
118
118
  end
119
119
 
120
- def KEY_HOME
120
+ def scroll_begin
121
121
  @current_top = 0
122
122
  @current_item = 0
123
123
  @current_high = 0
124
124
  end
125
125
 
126
- def KEY_END
126
+ def scroll_end
127
127
  if @max_top_item == -1
128
128
  @current_top = 0
129
129
  @current_item = @last_item - 1
@@ -134,13 +134,13 @@ module RNDK
134
134
  @current_high = @view_size - 1
135
135
  end
136
136
 
137
- def maxViewSize
137
+ def max_view_size
138
138
  return @box_height - (2 * @border_size + @title_lines)
139
139
  end
140
140
 
141
141
  # Set variables that depend upon the list_size
142
- def setViewSize(list_size)
143
- @view_size = self.maxViewSize
142
+ def set_view_size(list_size)
143
+ @view_size = self.max_view_size
144
144
  @list_size = list_size
145
145
  @last_item = list_size - 1
146
146
  @max_top_item = list_size - @view_size
@@ -150,9 +150,9 @@ module RNDK
150
150
  @max_top_item = 0
151
151
  end
152
152
 
153
- if @list_size > 0 && self.maxViewSize > 0
154
- @step = 1.0 * self.maxViewSize / @list_size
155
- @toggle_size = if @list_size > self.maxViewSize
153
+ if @list_size > 0 && self.max_view_size > 0
154
+ @step = 1.0 * self.max_view_size / @list_size
155
+ @toggle_size = if @list_size > self.max_view_size
156
156
  then 1
157
157
  else @step.ceil
158
158
  end
@@ -162,9 +162,9 @@ module RNDK
162
162
  end
163
163
  end
164
164
 
165
- def setPosition(item)
165
+ def set_position(item)
166
166
  if item <= 0
167
- self.KEY_HOME
167
+ self.scroll_begin
168
168
  elsif item > @list_size - 1
169
169
  @current_top = @max_top_item
170
170
  @current_item = @list_size - 1
@@ -180,12 +180,12 @@ module RNDK
180
180
  end
181
181
 
182
182
  # Get/Set the current item number of the scroller.
183
- def getCurrentItem
183
+ def get_current_item
184
184
  @current_item
185
185
  end
186
186
 
187
- def setCurrentItem(item)
188
- self.setPosition(item);
187
+ def set_current_item(item)
188
+ self.set_position(item);
189
189
  end
190
190
 
191
191
  end
@@ -15,18 +15,18 @@ module RNDK
15
15
  # Next Page:: Increments the field by the accelerated increment value.
16
16
  # D:: Increments the field by the accelerated increment value.
17
17
  # Ctrl-F:: Increments the field by the accelerated increment value.
18
- # Home:: Sets the value to the low value.
19
- # g:: Sets the value to the low value.
20
- # End:: Sets the value to the high value.
21
- # G:: Sets the value to the high value.
22
- # $:: Sets the value to the high value.
18
+ # Home:: Sets the value to the minimum value.
19
+ # g:: Sets the value to the minimum value.
20
+ # End:: Sets the value to the maximum value.
21
+ # G:: Sets the value to the maximum value.
22
+ # $:: Sets the value to the maximum value.
23
23
  # Return:: Exits the widget and returns the current value. This also sets the widget data `exit_type` to `:NORMAL`.
24
24
  # Tab:: Exits the widget and returns the current value. This also sets the widget data `exit_type` to `:NORMAL`.
25
25
  # Escape:: Exits the widget and returns `nil`. Also sets the widget data `exit_type` to `:ESCAPE_HIT`.
26
26
  # Ctrl-L:: Refreshes the screen.
27
27
  #
28
28
  # If the cursor is not pointing to the field's value,
29
- # the following key bindings apply.
29
+ # the folminimuming key bindings apply.
30
30
  #
31
31
  # You may use the left/right arrows to move the cursor
32
32
  # onto the field's value and modify it by typing characters
@@ -38,15 +38,15 @@ module RNDK
38
38
  # D:: Increments the scale by the accelerated value.
39
39
  # -:: Decrements the scale by the normal value.
40
40
  # +:: Increments the scale by the normal value.
41
- # 0:: Sets the scale to the low value.
41
+ # 0:: Sets the scale to the minimum value.
42
42
  #
43
43
  class Slider < Widget
44
44
 
45
45
  # Creates a new Slider Widget.
46
46
  #
47
- # * `xplace` is the x position - can be an integer or
47
+ # * `x` is the x position - can be an integer or
48
48
  # `RNDK::LEFT`, `RNDK::RIGHT`, `RNDK::CENTER`.
49
- # * `yplace` is the y position - can be an integer or
49
+ # * `y` is the y position - can be an integer or
50
50
  # `RNDK::TOP`, `RNDK::BOTTOM`, `RNDK::CENTER`.
51
51
  # * `title` can be more than one line - just split them
52
52
  # with `\n`s.
@@ -59,54 +59,63 @@ module RNDK
59
59
  # If it's a negative value, will create with full width
60
60
  # minus that value.
61
61
  # * `start` is the initial value of the widget.
62
- # * `low`/`high` are the minimum and maximum values of
62
+ # * `minimum`/`maximum` are the minimum and maximum values of
63
63
  # the slider.
64
64
  # * `inc` is the increment value.
65
65
  # * `fast_inc` is the accelerated increment value.
66
66
  # * `box` if the Widget is drawn with a box outside it.
67
67
  # * `shadow` turns on/off the shadow around the Widget.
68
68
  #
69
- def initialize(rndkscreen,
70
- xplace,
71
- yplace,
72
- title,
73
- label,
74
- filler,
75
- field_width,
76
- start,
77
- low,
78
- high,
79
- inc,
80
- fast_inc,
81
- box,
82
- shadow)
69
+ def initialize(screen, config={})
83
70
  super()
71
+ @widget_type = :slider
72
+ @supported_signals += [:before_input, :after_input]
73
+
74
+ x = 0
75
+ y = 0
76
+ title = "slider"
77
+ label = "label"
78
+ filler = ' '.ord | RNDK::Color[:reverse]
79
+ field_width = 0
80
+ start = 0
81
+ minimum = 0
82
+ maximum = 100
83
+ increment = 1
84
+ fast_increment = 5
85
+ box = true
86
+ shadow = false
87
+
88
+ config.each do |key, val|
89
+ x = val if key == :x
90
+ y = val if key == :y
91
+ title = val if key == :title
92
+ label = val if key == :label
93
+ filler = val if key == :filler
94
+ field_width = val if key == :field_width
95
+ start = val if key == :start
96
+ minimum = val if key == :minimum
97
+ maximum = val if key == :maximum
98
+ increment = val if key == :inc
99
+ fast_increment = val if key == :fast_inc
100
+ box = val if key == :box
101
+ shadow = val if key == :shadow
102
+ end
84
103
 
85
- parent_width = Ncurses.getmaxx(rndkscreen.window)
86
- parent_height = Ncurses.getmaxy(rndkscreen.window)
87
-
88
- bindings = {
89
- 'u' => Ncurses::KEY_UP,
90
- 'U' => Ncurses::KEY_PPAGE,
91
- RNDK::BACKCHAR => Ncurses::KEY_PPAGE,
92
- RNDK::FORCHAR => Ncurses::KEY_NPAGE,
93
- 'g' => Ncurses::KEY_HOME,
94
- '^' => Ncurses::KEY_HOME,
95
- 'G' => Ncurses::KEY_END,
96
- '$' => Ncurses::KEY_END,
97
- }
98
- self.set_box(box)
104
+ parent_width = Ncurses.getmaxx screen.window
105
+ parent_height = Ncurses.getmaxy screen.window
106
+
107
+ self.set_box box
99
108
  box_height = @border_size * 2 + 1
100
109
 
101
110
  # Set some basic values of the widget's data field.
102
111
  @label = []
103
112
  @label_len = 0
104
113
  @label_win = nil
105
- high_value_len = self.formattedSize(high)
114
+ maximum_value_len = self.formattedSize maximum
106
115
 
107
116
  # If the field_width is a negative will be COLS-field_width,
108
117
  # otherwise field_width will be the given width.
109
- field_width = RNDK.setWidgetDimension(parent_width, field_width, 0)
118
+ field_width = RNDK.set_widget_dimension(parent_width, field_width, 0)
110
119
 
111
120
  # Translate the label string to a chtype array.
112
121
  if !(label.nil?) && label.size > 0
@@ -114,9 +123,9 @@ module RNDK
114
123
  @label = RNDK.char2Chtype(label, label_len, [])
115
124
  @label_len = label_len[0]
116
125
  box_width = @label_len + field_width +
117
- high_value_len + 2 * @border_size
126
+ maximum_value_len + 2 * @border_size
118
127
  else
119
- box_width = field_width + high_value_len + 2 * @border_size
128
+ box_width = field_width + maximum_value_len + 2 * @border_size
120
129
  end
121
130
 
122
131
  old_width = box_width
@@ -128,12 +137,12 @@ module RNDK
128
137
  # Make sure we didn't extend beyond the dimensions of the window.
129
138
  box_width = [box_width, parent_width].min
130
139
  box_height = [box_height, parent_height].min
131
- field_width = [field_width, box_width - @label_len - high_value_len - 1].min
140
+ field_width = [field_width, box_width - @label_len - maximum_value_len - 1].min
132
141
 
133
142
  # Rejustify the x and y positions if we need to.
134
- xtmp = [xplace]
135
- ytmp = [yplace]
136
- RNDK.alignxy(rndkscreen.window, xtmp, ytmp, box_width, box_height)
143
+ xtmp = [x]
144
+ ytmp = [y]
145
+ RNDK.alignxy(screen.window, xtmp, ytmp, box_width, box_height)
137
146
  xpos = xtmp[0]
138
147
  ypos = ytmp[0]
139
148
 
@@ -162,7 +171,7 @@ module RNDK
162
171
  # Create the widget's data field window.
163
172
  @field_win = Ncurses.subwin(@win,
164
173
  1,
165
- field_width + high_value_len - 1,
174
+ field_width + maximum_value_len - 1,
166
175
  ypos + @title_lines + @border_size,
167
176
  xpos + @label_len + horizontal_adjust + @border_size)
168
177
 
@@ -174,26 +183,26 @@ module RNDK
174
183
  Ncurses.keypad(@win, true)
175
184
 
176
185
  # Create the widget's data field.
177
- @screen = rndkscreen
178
- @window = rndkscreen.window
186
+ @screen = screen
187
+ @window = screen.window
179
188
  @shadow_win = nil
180
189
  @box_width = box_width
181
190
  @box_height = box_height
182
191
  @field_width = field_width - 1
183
192
  @filler = filler
184
- @low = low
185
- @high = high
193
+ @minimum = minimum
194
+ @maximum = maximum
186
195
  @current = start
187
- @inc = inc
188
- @fastinc = fast_inc
196
+ @increment = increment
197
+ @fast_increment = fast_increment
189
198
  @accepts_focus = true
190
199
  @input_window = @win
191
200
  @shadow = shadow
192
201
  @field_edit = 0
193
202
 
194
203
  # Set the start value.
195
- if start < low
196
- @current = low
204
+ if start < minimum
205
+ @current = minimum
197
206
  end
198
207
 
199
208
  # Do we want a shadow?
@@ -209,11 +218,14 @@ module RNDK
209
218
  end
210
219
 
211
220
  # Setup the key bindings.
212
- bindings.each do |from, to|
213
- self.bind(:slider, from, :getc, to)
214
- end
215
-
216
- rndkscreen.register(:slider, self)
221
+ self.bind_key('u') { self.increment @increment }
222
+ self.bind_key('U') { self.increment @fast_increment }
223
+ self.bind_key('g') { @current = @minimum }
224
+ self.bind_key('^') { @current = @minimum }
225
+ self.bind_key('G') { @current = @maximum }
226
+ self.bind_key('$') { @current = @maximum }
227
+
228
+ screen.register(@widget_type, self)
217
229
  end
218
230
 
219
231
  # Activates the Widget, letting the user interact with it.
@@ -223,11 +235,11 @@ module RNDK
223
235
  #
224
236
  # @return The current value of the slider.
225
237
  def activate(actions=[])
226
- self.draw @box
238
+ self.draw
227
239
 
228
240
  if actions.nil? || actions.size == 0
229
241
  while true
230
- input = self.getch([])
242
+ input = self.getch
231
243
 
232
244
  # Inject the character into the widget.
233
245
  ret = self.inject(input)
@@ -250,13 +262,13 @@ module RNDK
250
262
  return nil
251
263
  end
252
264
 
253
- # Check if the value lies outside the low/high range. If so, force it in.
265
+ # Check if the value lies outside the minimum/maximum range. If so, force it in.
254
266
  def limitCurrentValue
255
- if @current < @low
256
- @current = @low
267
+ if @current < @minimum
268
+ @current = @minimum
257
269
  RNDK.beep
258
- elsif @current > @high
259
- @current = @high
270
+ elsif @current > @maximum
271
+ @current = @maximum
260
272
  RNDK.beep
261
273
  end
262
274
  end
@@ -278,7 +290,7 @@ module RNDK
278
290
  return false
279
291
  end
280
292
  ch = Ncurses.winch(@field_win)
281
- if RNDK.CharOf(ch) != ' '
293
+ if RNDK.char_of(ch) != ' '
282
294
  return true
283
295
  end
284
296
  if new_position > 1
@@ -287,13 +299,13 @@ module RNDK
287
299
  return false
288
300
  end
289
301
  ch = Ncurses.winch(@field_win)
290
- return RNDK.CharOf(ch) != ' '
302
+ return RNDK.char_of(ch) != ' '
291
303
  end
292
304
  return false
293
305
  end
294
306
 
295
307
  # Set the edit position. Normally the cursor is one cell to the right of
296
- # the editable field. Moving it left, over the field, allows the user to
308
+ # the editable field. Moving it left, over the field, alminimums the user to
297
309
  # modify cells by typing in replacement characters for the field's value.
298
310
  def setEditPosition(new_position)
299
311
  if new_position < 0
@@ -351,8 +363,8 @@ module RNDK
351
363
  end
352
364
  if modify &&
353
365
  ((value, test) = temp.scanf(self.SCAN_FMT)).size == 2 &&
354
- test == ' ' && value >= @low && value <= @high
355
- self.setValue(value)
366
+ test == ' ' && value >= @minimum && value <= @maximum
367
+ self.set_value(value)
356
368
  result = true
357
369
  end
358
370
  return result
@@ -376,28 +388,24 @@ module RNDK
376
388
 
377
389
  # @see Widget#inject
378
390
  def inject input
379
- pp_return = 1
391
+ pp_return = true
380
392
  ret = nil
381
393
  complete = false
382
394
 
383
- # Set the exit type.
384
- self.set_exit_type(0)
395
+ self.set_exit_type 0
385
396
 
386
- # Draw the field.
387
- self.drawField
397
+ self.draw_field
388
398
 
389
399
  # Check if there is a pre-process function to be called.
390
- unless @pre_process_func.nil?
391
- # Call the pre-process function.
392
- pp_return = @pre_process_func.call(:slider, self,
393
- @pre_process_data, input)
394
- end
400
+ keep_going = self.run_signal_binding(:before_input, input)
401
+
402
+ if keep_going
395
403
 
396
- # Should we continue?
397
- if pp_return != 0
398
404
  # Check for a key binding.
399
- if self.checkBind(:slider, input)
400
- complete = true
405
+ if self.is_bound? input
406
+ self.run_key_binding input
407
+ #complete = true
408
+
401
409
  else
402
410
  case input
403
411
  when Ncurses::KEY_LEFT
@@ -405,17 +413,17 @@ module RNDK
405
413
  when Ncurses::KEY_RIGHT
406
414
  self.setEditPosition(@field_edit - 1)
407
415
  when Ncurses::KEY_DOWN
408
- @current = RNDK::Slider.Decrement(@current, @inc)
416
+ self.decrement @increment
409
417
  when Ncurses::KEY_UP
410
- @current = RNDK::Slider.Increment(@current, @inc)
411
- when Ncurses::KEY_PPAGE
412
- @current = RNDK::Slider.Increment(@current, @fastinc)
413
- when Ncurses::KEY_NPAGE
414
- @current = RNDK::Slider.Decrement(@current, @fastinc)
418
+ self.increment @increment
419
+ when Ncurses::KEY_PPAGE, RNDK::BACKCHAR
420
+ self.increment @fast_increment
421
+ when Ncurses::KEY_NPAGE, RNDK::FORCHAR
422
+ self.decrement @fast_increment
415
423
  when Ncurses::KEY_HOME
416
- @current = @low
424
+ @current = @minimum
417
425
  when Ncurses::KEY_END
418
- @current = @high
426
+ @current = @maximum
419
427
  when RNDK::KEY_TAB, RNDK::KEY_RETURN, Ncurses::KEY_ENTER
420
428
  self.set_exit_type(input)
421
429
  ret = @current
@@ -453,16 +461,12 @@ module RNDK
453
461
  end
454
462
  end
455
463
  self.limitCurrentValue
456
-
457
- # Should we call a post-process?
458
- if !complete && !(@post_process_func.nil?)
459
- @post_process_func.call(:slider, self, @post_process_data, input)
460
- end
464
+ self.run_signal_binding(:after_input) if not complete
461
465
  end
462
466
 
463
- if !complete
464
- self.drawField
465
- self.set_exit_type(0)
467
+ if not complete
468
+ self.draw_field
469
+ self.set_exit_type 0
466
470
  end
467
471
 
468
472
  @return_data = 0
@@ -470,24 +474,24 @@ module RNDK
470
474
  end
471
475
 
472
476
  # @see Widget#move
473
- def move(xplace, yplace, relative, refresh_flag)
477
+ def move(x, y, relative, refresh_flag)
474
478
  windows = [@win, @label_win, @field_win, @shadow_win]
475
479
 
476
- self.move_specific(xplace, yplace, relative, refresh_flag, windows, [])
480
+ self.move_specific(x, y, relative, refresh_flag, windows, [])
477
481
  end
478
482
 
479
483
  # Draws the Widget on the Screen.
480
484
  #
481
485
  # If `box` is true, it is drawn with a box.
482
- def draw box
486
+ def draw
483
487
 
484
488
  # Draw the shadow.
485
489
  Draw.drawShadow(@shadow_win) unless @shadow_win.nil?
486
490
 
487
491
  # Box the widget if asked.
488
- Draw.drawObjBox(@win, self) if box
492
+ Draw.drawObjBox(@win, self) if @box
489
493
 
490
- self.drawTitle @win
494
+ self.draw_title @win
491
495
 
492
496
  # Draw the label.
493
497
  unless @label_win.nil?
@@ -498,15 +502,15 @@ module RNDK
498
502
  Ncurses.wrefresh @win
499
503
 
500
504
  # Draw the field window.
501
- self.drawField
505
+ self.draw_field
502
506
  end
503
507
 
504
508
  # This draws the widget.
505
- def drawField
506
- step = 1.0 * @field_width / (@high - @low)
509
+ def draw_field
510
+ step = 1.0 * @field_width / (@maximum - @minimum)
507
511
 
508
512
  # Determine how many filler characters need to be drawn.
509
- filler_characters = (@current - @low) * step
513
+ filler_characters = (@current - @minimum) * step
510
514
 
511
515
  Ncurses.werase(@field_win)
512
516
 
@@ -517,14 +521,14 @@ module RNDK
517
521
 
518
522
  # Draw the value in the field.
519
523
  Draw.writeCharAttrib(@field_win, @field_width, 0, @current.to_s,
520
- Ncurses::A_NORMAL, RNDK::HORIZONTAL, 0, @current.to_s.size)
524
+ RNDK::Color[:normal], RNDK::HORIZONTAL, 0, @current.to_s.size)
521
525
 
522
526
  self.moveToEditPosition(@field_edit)
523
527
  Ncurses.wrefresh(@field_win)
524
528
  end
525
529
 
526
530
  # This sets the background attribute of the widget.
527
- def set_bg_attrib(attrib)
531
+ def set_bg_color(attrib)
528
532
  # Set the widget's background attribute.
529
533
  Ncurses.wbkgd(@win, attrib)
530
534
  Ncurses.wbkgd(@field_win, attrib)
@@ -533,7 +537,7 @@ module RNDK
533
537
 
534
538
  # @see Widget#destroy
535
539
  def destroy
536
- self.cleanTitle
540
+ self.clean_title
537
541
  @label = []
538
542
 
539
543
  # Clean up the windows.
@@ -543,15 +547,15 @@ module RNDK
543
547
  RNDK.window_delete(@win)
544
548
 
545
549
  # Clean the key bindings.
546
- self.clean_bindings(:slider)
550
+ self.clean_bindings
547
551
 
548
- # Unregister this object.
549
- RNDK::Screen.unregister(:slider, self)
552
+ # Unregister this widget.
553
+ @screen.unregister self
550
554
  end
551
555
 
552
556
  # @see Widget#erase
553
557
  def erase
554
- if self.valid_widget?
558
+ if self.valid?
555
559
  RNDK.window_erase @label_win
556
560
  RNDK.window_erase @field_win
557
561
  RNDK.window_erase @lwin
@@ -563,52 +567,52 @@ module RNDK
563
567
  return value.to_s.size
564
568
  end
565
569
 
566
- # This function sets the low/high/current values of the widget.
567
- def set(low, high, value, box)
568
- self.setLowHigh(low, high)
569
- self.setValue(value)
570
+ # This function sets the minimum/maximum/current values of the widget.
571
+ def set(minimum, maximum, value, box)
572
+ self.setMinimumMaximum(minimum, maximum)
573
+ self.set_value(value)
570
574
  self.set_box(box)
571
575
  end
572
576
 
573
577
  # This sets the widget's value.
574
- def setValue(value)
578
+ def set_value(value)
575
579
  @current = value
576
580
  self.limitCurrentValue
577
581
  end
578
582
 
579
- def getValue
583
+ def get_value
580
584
  return @current
581
585
  end
582
586
 
583
- # This function sets the low/high values of the widget.
584
- def setLowHigh(low, high)
587
+ # This function sets the minimum/maximum values of the widget.
588
+ def setMinimumMaximum(minimum, maximum)
585
589
  # Make sure the values aren't out of bounds.
586
- if low <= high
587
- @low = low
588
- @high = high
589
- elsif low > high
590
- @low = high
591
- @high = low
590
+ if minimum <= maximum
591
+ @minimum = minimum
592
+ @maximum = maximum
593
+ elsif minimum > maximum
594
+ @minimum = maximum
595
+ @maximum = minimum
592
596
  end
593
597
 
594
598
  # Make sure the user hasn't done something silly.
595
599
  self.limitCurrentValue
596
600
  end
597
601
 
598
- def getLowValue
599
- return @low
602
+ def getMinimumValue
603
+ return @minimum
600
604
  end
601
605
 
602
- def getHighValue
603
- return @high
606
+ def getMaximumValue
607
+ return @maximum
604
608
  end
605
609
 
606
610
  def focus
607
- self.draw(@box)
611
+ self.draw
608
612
  end
609
613
 
610
614
  def unfocus
611
- self.draw(@box)
615
+ self.draw
612
616
  end
613
617
 
614
618
  def SCAN_FMT
@@ -619,8 +623,13 @@ module RNDK
619
623
  super(@win)
620
624
  end
621
625
 
622
- def object_type
623
- :slider
626
+ def decrement by
627
+ @current = @current - by if (@current - by) < @current
624
628
  end
629
+
630
+ def increment by
631
+ @current = @current + by if (@current + by) > @current
632
+ end
633
+
625
634
  end
626
635
  end