newt 0.9.2 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/README.rdoc +37 -28
  3. data/ext/ruby_newt/extconf.rb +2 -1
  4. data/ext/ruby_newt/ruby_newt.c +365 -745
  5. data/lib/newt.rb +2 -12
  6. data/lib/version.rb +3 -0
  7. metadata +36 -166
  8. data/.autotest +0 -9
  9. data/.gemtest +0 -0
  10. data/History.txt +0 -4
  11. data/Manifest.txt +0 -67
  12. data/Rakefile +0 -26
  13. data/examples/test-j.rb +0 -118
  14. data/examples/test.rb +0 -95
  15. data/examples/test_method/Button_new.rb +0 -22
  16. data/examples/test_method/Checkbox_get.rb +0 -25
  17. data/examples/test_method/Checkbox_new.rb +0 -22
  18. data/examples/test_method/Checkbox_set.rb +0 -28
  19. data/examples/test_method/Checkbox_set_flags.rb +0 -28
  20. data/examples/test_method/CompactButton_new.rb +0 -22
  21. data/examples/test_method/Entry_get.rb +0 -26
  22. data/examples/test_method/Entry_new.rb +0 -23
  23. data/examples/test_method/Entry_set.rb +0 -26
  24. data/examples/test_method/Entry_set_flags.rb +0 -31
  25. data/examples/test_method/Form_destroy.rb +0 -33
  26. data/examples/test_method/Form_set_background.rb +0 -23
  27. data/examples/test_method/Form_set_height.rb +0 -26
  28. data/examples/test_method/Form_set_width.rb +0 -26
  29. data/examples/test_method/Grid_new.rb +0 -26
  30. data/examples/test_method/Label_new.rb +0 -22
  31. data/examples/test_method/Label_setText.rb +0 -25
  32. data/examples/test_method/Listbox_clear.rb +0 -25
  33. data/examples/test_method/Listbox_current_bykey.rb +0 -29
  34. data/examples/test_method/Listbox_delete.rb +0 -27
  35. data/examples/test_method/Listbox_get_current.rb +0 -28
  36. data/examples/test_method/Listbox_insert.rb +0 -24
  37. data/examples/test_method/Listbox_new.rb +0 -24
  38. data/examples/test_method/Listbox_select.rb +0 -27
  39. data/examples/test_method/Listbox_set.rb +0 -27
  40. data/examples/test_method/Listbox_set_current.rb +0 -26
  41. data/examples/test_method/Listbox_set_width.rb +0 -25
  42. data/examples/test_method/Newt_FLAG_SCROLL.rb +0 -21
  43. data/examples/test_method/RadioButton_new.rb +0 -22
  44. data/examples/test_method/ReflowText.rb +0 -27
  45. data/examples/test_method/Scale_new.rb +0 -22
  46. data/examples/test_method/Scale_set.rb +0 -22
  47. data/examples/test_method/Screen_bell.rb +0 -10
  48. data/examples/test_method/Screen_cls.rb +0 -12
  49. data/examples/test_method/Screen_draw_roottext.rb +0 -16
  50. data/examples/test_method/Screen_init.rb +0 -11
  51. data/examples/test_method/Screen_pop_helpline.rb +0 -18
  52. data/examples/test_method/Screen_push_helpline.rb +0 -16
  53. data/examples/test_method/Screen_redraw_helpline.rb +0 -18
  54. data/examples/test_method/Screen_size.rb +0 -15
  55. data/examples/test_method/Screen_win_menu.rb +0 -19
  56. data/examples/test_method/TextboxReflowed_new.rb +0 -23
  57. data/examples/test_method/Textbox_get_num_lines.rb +0 -27
  58. data/examples/test_method/Textbox_new.rb +0 -22
  59. data/examples/test_method/Textbox_set_height.rb +0 -25
  60. data/examples/testgrid-j.rb +0 -85
  61. data/examples/testgrid.rb +0 -83
  62. data/examples/testtree-j.rb +0 -55
  63. data/examples/testtree.rb +0 -54
  64. data/script/console +0 -10
  65. data/script/destroy +0 -14
  66. data/script/generate +0 -14
  67. data/tasks/extconf/ruby_newt.rake +0 -43
  68. data/tasks/extconf.rake +0 -13
  69. data/test/test_helper.rb +0 -3
  70. data/test/test_newt.rb +0 -11
  71. data/test/test_ruby_newt_extn.rb +0 -10
@@ -1,11 +1,5 @@
1
1
  /*
2
- *
3
- * by Noritsugu Nakamura
4
- * from 2001.04.20
5
- *
6
- * modified by Eric Sperano
7
- * from 2012.02.27
8
- *
2
+ * Published under MIT license, see README.
9
3
  */
10
4
 
11
5
  #include <ruby.h>
@@ -49,19 +43,14 @@ struct snackWidget_s {
49
43
  };
50
44
 
51
45
 
52
- /*
53
- * ReflowText
54
- *
55
- */
56
- static VALUE
57
- rb_ext_ReflowText(VALUE self, VALUE text, VALUE width, VALUE flexDown, VALUE flexUp)
46
+ static VALUE rb_ext_ReflowText(VALUE self, VALUE text, VALUE width, VALUE flexDown, VALUE flexUp)
58
47
  {
59
48
  int actualWidth, actualHeight;
60
49
  char *p;
61
50
  VALUE ary = rb_ary_new2(3);
62
51
 
63
52
  p = newtReflowText(StringValuePtr(text), NUM2INT(width), NUM2INT(flexDown), NUM2INT(flexUp),
64
- &actualWidth, &actualHeight);
53
+ &actualWidth, &actualHeight);
65
54
 
66
55
  rb_ary_push(ary, rb_str_new2(p));
67
56
  rb_ary_push(ary, INT2NUM(actualWidth));
@@ -69,12 +58,7 @@ rb_ext_ReflowText(VALUE self, VALUE text, VALUE width, VALUE flexDown, VALUE fle
69
58
  return ary;
70
59
  }
71
60
 
72
- /*
73
- * Screen_new
74
- *
75
- */
76
- static VALUE
77
- rb_ext_Screen_new()
61
+ static VALUE rb_ext_Screen_new()
78
62
  {
79
63
  newtInit();
80
64
  newtCls();
@@ -82,200 +66,115 @@ rb_ext_Screen_new()
82
66
  return Qnil;
83
67
  }
84
68
 
85
- /*
86
- * Screen_Init
87
- *
88
- */
89
- static VALUE
90
- rb_ext_Screen_Init()
69
+ static VALUE rb_ext_Screen_Init()
91
70
  {
92
71
  newtInit();
93
72
  return Qnil;
94
73
  }
95
74
 
96
- /*
97
- * Screen_Cls
98
- *
99
- */
100
- static VALUE
101
- rb_ext_Screen_Cls()
75
+ static VALUE rb_ext_Screen_Cls()
102
76
  {
103
77
  newtCls();
104
78
  return Qnil;
105
79
  }
106
80
 
107
- /*
108
- * Screen_Finished
109
- *
110
- */
111
- static VALUE
112
- rb_ext_Screen_Finished()
81
+ static VALUE rb_ext_Screen_Finished()
113
82
  {
114
83
  newtFinished();
115
84
 
116
85
  return Qnil;
117
86
  }
118
87
 
119
- /*
120
- * Screen_WaitForKey
121
- *
122
- */
123
- static VALUE
124
- rb_ext_Screen_WaitForKey()
88
+ static VALUE rb_ext_Screen_WaitForKey()
125
89
  {
126
90
  newtWaitForKey();
127
91
 
128
92
  return Qnil;
129
93
  }
130
94
 
131
- /*
132
- * Screen_ClearKeyBuffer
133
- *
134
- */
135
- static VALUE
136
- rb_ext_Screen_ClearKeyBuffer()
95
+ static VALUE rb_ext_Screen_ClearKeyBuffer()
137
96
  {
138
97
  newtClearKeyBuffer();
139
98
 
140
99
  return Qnil;
141
100
  }
142
101
 
143
- /*
144
- * Screen_OpenWindow
145
- *
146
- */
147
- static VALUE
148
- rb_ext_Screen_OpenWindow(VALUE self, VALUE left, VALUE top,
149
- VALUE width, VALUE height, VALUE title)
102
+ static VALUE rb_ext_Screen_OpenWindow(VALUE self, VALUE left, VALUE top,
103
+ VALUE width, VALUE height, VALUE title)
150
104
  {
151
105
  return INT2NUM(newtOpenWindow(NUM2INT(left), NUM2INT(top),
152
- NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
106
+ NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
153
107
  }
154
108
 
155
- /*
156
- * Screen_CenteredWindow
157
- *
158
- */
159
- static VALUE
160
- rb_ext_Screen_CenteredWindow(VALUE self, VALUE width, VALUE height, VALUE title)
109
+ static VALUE rb_ext_Screen_CenteredWindow(VALUE self, VALUE width, VALUE height, VALUE title)
161
110
  {
162
111
  return INT2NUM(newtCenteredWindow(NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
163
112
  }
164
113
 
165
- /*
166
- * Screen_PopWindow
167
- *
168
- */
169
- static VALUE
170
- rb_ext_Screen_PopWindow(VALUE self)
114
+ static VALUE rb_ext_Screen_PopWindow(VALUE self)
171
115
  {
172
116
  newtPopWindow();
173
117
  return Qnil;
174
118
  }
175
119
 
176
120
 
177
- /*
178
- * Screen_Resume
179
- *
180
- */
181
- static VALUE
182
- rb_ext_Screen_Resume()
121
+ static VALUE rb_ext_Screen_Resume()
183
122
  {
184
123
  newtResume();
185
124
 
186
125
  return Qnil;
187
126
  }
188
127
 
189
- /*
190
- * Screen_Suspend
191
- *
192
- */
193
- static VALUE
194
- rb_ext_Screen_Suspend()
128
+ static VALUE rb_ext_Screen_Suspend()
195
129
  {
196
130
  newtSuspend();
197
131
 
198
132
  return Qnil;
199
133
  }
200
134
 
201
- /*
202
- * Screen_Refresh
203
- *
204
- */
205
- static VALUE
206
- rb_ext_Screen_Refresh()
135
+ static VALUE rb_ext_Screen_Refresh()
207
136
  {
208
137
  newtRefresh();
209
138
 
210
139
  return Qnil;
211
140
  }
212
141
 
213
- /*
214
- * Screen_DrawRootText
215
- *
216
- */
217
- static VALUE
218
- rb_ext_Screen_DrawRootText(VALUE self, VALUE col, VALUE row, VALUE text)
142
+ static VALUE rb_ext_Screen_DrawRootText(VALUE self, VALUE col, VALUE row, VALUE text)
219
143
  {
220
144
 
221
145
  newtDrawRootText(NUM2INT(col), NUM2INT(row), StringValuePtr(text));
222
146
  return Qnil;
223
147
  }
224
148
 
225
- /*
226
- * Screen_PushHelpLine
227
- *
228
- */
229
- static VALUE
230
- rb_ext_Screen_PushHelpLine(VALUE self, VALUE text)
149
+ static VALUE rb_ext_Screen_PushHelpLine(VALUE self, VALUE text)
231
150
  {
232
151
  newtPushHelpLine(StringValuePtr(text));
233
152
 
234
153
  return Qnil;
235
154
  }
236
155
 
237
- /*
238
- * Screen_RedrawHelpLine
239
- *
240
- */
241
- static VALUE
242
- rb_ext_Screen_RedrawHelpLine(VALUE self)
156
+ static VALUE rb_ext_Screen_RedrawHelpLine(VALUE self)
243
157
  {
244
158
  newtRedrawHelpLine();
245
159
 
246
160
  return Qnil;
247
161
  }
248
162
 
249
- /*
250
- * Screen_PopHelpLine
251
- *
252
- */
253
- static VALUE
254
- rb_ext_Screen_PopHelpLine(VALUE self)
163
+ static VALUE rb_ext_Screen_PopHelpLine(VALUE self)
255
164
  {
256
165
  newtPopHelpLine();
257
166
 
258
167
  return Qnil;
259
168
  }
260
169
 
261
- /*
262
- * Screen_Bell
263
- *
264
- */
265
- static VALUE
266
- rb_ext_Screen_Bell(VALUE self)
170
+ static VALUE rb_ext_Screen_Bell(VALUE self)
267
171
  {
268
172
  newtBell();
269
173
 
270
174
  return Qnil;
271
175
  }
272
176
 
273
- /*
274
- * Screen_Size
275
- *
276
- */
277
- static VALUE
278
- rb_ext_Screen_Size(VALUE self)
177
+ static VALUE rb_ext_Screen_Size(VALUE self)
279
178
  {
280
179
  int cols, rows;
281
180
  VALUE ary = rb_ary_new2(2);
@@ -287,47 +186,32 @@ rb_ext_Screen_Size(VALUE self)
287
186
  return ary;
288
187
  }
289
188
 
290
- /*
291
- * Screen_WinMessage
292
- *
293
- */
294
- static VALUE
295
- rb_ext_Screen_WinMessage(VALUE self, VALUE args)
189
+ static VALUE rb_ext_Screen_WinMessage(VALUE self, VALUE args)
296
190
  {
297
191
  if (RARRAY_LEN(args) < 3) {
298
- rb_raise(rb_eArgError, "3 arguments required");
192
+ rb_raise(rb_eArgError, "3 arguments required");
299
193
  } else {
300
-
301
- newtWinMessage(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]), StringValuePtr(RARRAY_PTR(args)[2]));
194
+
195
+ newtWinMessage(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]), StringValuePtr(RARRAY_PTR(args)[2]));
302
196
  }
303
197
 
304
198
  return Qnil;
305
199
  }
306
200
 
307
- /*
308
- * Screen_WinChoice
309
- *
310
- */
311
- static VALUE
312
- rb_ext_Screen_WinChoice(VALUE self, VALUE args)
201
+ static VALUE rb_ext_Screen_WinChoice(VALUE self, VALUE args)
313
202
  {
314
203
  if (RARRAY_LEN(args) < 4) {
315
- rb_raise(rb_eArgError, "4 arguments required");
204
+ rb_raise(rb_eArgError, "4 arguments required");
316
205
  } else {
317
-
318
- newtWinChoice(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
319
- StringValuePtr(RARRAY_PTR(args)[2]), StringValuePtr(RARRAY_PTR(args)[3]));
206
+
207
+ newtWinChoice(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
208
+ StringValuePtr(RARRAY_PTR(args)[2]), StringValuePtr(RARRAY_PTR(args)[3]));
320
209
  }
321
210
 
322
211
  return Qnil;
323
212
  }
324
213
 
325
- /*
326
- * Screen_WinMenu
327
- *
328
- */
329
- static VALUE
330
- rb_ext_Screen_WinMenu(VALUE self, VALUE args)
214
+ static VALUE rb_ext_Screen_WinMenu(VALUE self, VALUE args)
331
215
  {
332
216
  long len;
333
217
  int i, listItem;
@@ -335,52 +219,47 @@ rb_ext_Screen_WinMenu(VALUE self, VALUE args)
335
219
 
336
220
  len = RARRAY_LEN(args);
337
221
  if (len == 8) {
338
- Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
339
-
340
- len = RARRAY_LEN(RARRAY_PTR(args)[6]);
341
- cptr = ALLOCA_N(char*, len + 1);
342
- for (i = 0; i < len; i++) {
343
- Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
344
- cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
345
- }
346
- cptr[len] = NULL;
347
-
348
- newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
349
- NUM2INT(RARRAY_PTR(args)[2]),
350
- NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
351
- NUM2INT(RARRAY_PTR(args)[5]),
352
- cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
353
- return INT2NUM(listItem);
354
- } else if (len == 9) {
355
- Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
356
-
357
- len = RARRAY_LEN(RARRAY_PTR(args)[6]);
358
- cptr = ALLOCA_N(char*, len + 1);
359
- for (i = 0; i < len; i++) {
360
- Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
361
- cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
362
- }
363
- cptr[len] = NULL;
364
-
365
- newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
366
- NUM2INT(RARRAY_PTR(args)[2]),
367
- NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
368
- NUM2INT(RARRAY_PTR(args)[5]),
369
- cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
370
- return INT2NUM(listItem);
222
+ Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
223
+
224
+ len = RARRAY_LEN(RARRAY_PTR(args)[6]);
225
+ cptr = ALLOCA_N(char*, len + 1);
226
+ for (i = 0; i < len; i++) {
227
+ Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
228
+ cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
229
+ }
230
+ cptr[len] = NULL;
231
+
232
+ newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
233
+ NUM2INT(RARRAY_PTR(args)[2]),
234
+ NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
235
+ NUM2INT(RARRAY_PTR(args)[5]),
236
+ cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
237
+ return INT2NUM(listItem);
238
+ } else if (len == 9) {
239
+ Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
240
+
241
+ len = RARRAY_LEN(RARRAY_PTR(args)[6]);
242
+ cptr = ALLOCA_N(char*, len + 1);
243
+ for (i = 0; i < len; i++) {
244
+ Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
245
+ cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
246
+ }
247
+ cptr[len] = NULL;
248
+
249
+ newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
250
+ NUM2INT(RARRAY_PTR(args)[2]),
251
+ NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
252
+ NUM2INT(RARRAY_PTR(args)[5]),
253
+ cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
254
+ return INT2NUM(listItem);
371
255
  } else {
372
- rb_raise(rb_eArgError, "8 or 9 arguments required");
256
+ rb_raise(rb_eArgError, "8 or 9 arguments required");
373
257
  }
374
258
 
375
259
  return Qnil;
376
260
  }
377
261
 
378
- /*
379
- * Screen_WinEntries
380
- *
381
- */
382
- static VALUE
383
- rb_ext_Screen_WinEntries(VALUE self, VALUE args)
262
+ static VALUE rb_ext_Screen_WinEntries(VALUE self, VALUE args)
384
263
  {
385
264
  long len;
386
265
  int i;
@@ -393,67 +272,63 @@ rb_ext_Screen_WinEntries(VALUE self, VALUE args)
393
272
 
394
273
  len = RARRAY_LEN(args);
395
274
  if (len == 8) {
396
- Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
397
-
398
- len = RARRAY_LEN(RARRAY_PTR(args)[6]);
399
- if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
400
- items = ALLOCA_N(struct newtWinEntry, len + 1);
401
- for (i = 0; i < len; i++) {
402
- Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
403
- items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
404
- items[i].value = entries + i;
405
- items[i].flags = 0;
406
- }
407
- items[len].text = NULL;
408
- items[len].value = NULL;
409
- items[len].flags = 0;
410
-
411
- newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
412
- NUM2INT(RARRAY_PTR(args)[2]),
413
- NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
414
- NUM2INT(RARRAY_PTR(args)[5]),
415
- items, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
416
- for (i = 0; i < len; i++) {
417
- rb_ary_push(ary, rb_str_new2(entries[i]));
418
- }
419
- return ary;
420
- } else if (len == 9) {
421
- Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
422
-
423
- len = RARRAY_LEN(RARRAY_PTR(args)[6]);
424
- if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
425
- items = ALLOCA_N(struct newtWinEntry, len + 1);
426
- for (i = 0; i < len; i++) {
427
- Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
428
- items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
429
- items[i].value = entries + i;
430
- items[i].flags = 0;
431
- }
432
- items[len].text = NULL;
433
- items[len].value = NULL;
434
- items[len].flags = 0;
435
-
436
- newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
437
- NUM2INT(RARRAY_PTR(args)[2]),
438
- NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
439
- NUM2INT(RARRAY_PTR(args)[5]),
440
- items, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
441
- for (i = 0; i < len; i++) {
442
- rb_ary_push(ary, rb_str_new2(entries[i]));
443
- }
444
- return ary;
275
+ Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
276
+
277
+ len = RARRAY_LEN(RARRAY_PTR(args)[6]);
278
+ if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
279
+ items = ALLOCA_N(struct newtWinEntry, len + 1);
280
+ for (i = 0; i < len; i++) {
281
+ Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
282
+ items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
283
+ items[i].value = entries + i;
284
+ items[i].flags = 0;
285
+ }
286
+ items[len].text = NULL;
287
+ items[len].value = NULL;
288
+ items[len].flags = 0;
289
+
290
+ newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
291
+ NUM2INT(RARRAY_PTR(args)[2]),
292
+ NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
293
+ NUM2INT(RARRAY_PTR(args)[5]),
294
+ items, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
295
+ for (i = 0; i < len; i++) {
296
+ rb_ary_push(ary, rb_str_new2(entries[i]));
297
+ }
298
+ return ary;
299
+ } else if (len == 9) {
300
+ Check_Type(RARRAY_PTR(args)[6], T_ARRAY);
301
+
302
+ len = RARRAY_LEN(RARRAY_PTR(args)[6]);
303
+ if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
304
+ items = ALLOCA_N(struct newtWinEntry, len + 1);
305
+ for (i = 0; i < len; i++) {
306
+ Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
307
+ items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
308
+ items[i].value = entries + i;
309
+ items[i].flags = 0;
310
+ }
311
+ items[len].text = NULL;
312
+ items[len].value = NULL;
313
+ items[len].flags = 0;
314
+
315
+ newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
316
+ NUM2INT(RARRAY_PTR(args)[2]),
317
+ NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
318
+ NUM2INT(RARRAY_PTR(args)[5]),
319
+ items, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
320
+ for (i = 0; i < len; i++) {
321
+ rb_ary_push(ary, rb_str_new2(entries[i]));
322
+ }
323
+ return ary;
445
324
  } else {
446
- rb_raise(rb_eArgError, "8 or 9 arguments required");
325
+ rb_raise(rb_eArgError, "8 or 9 arguments required");
447
326
  }
448
327
 
449
328
  return Qnil;
450
329
  }
451
330
 
452
- /*
453
- * Widget_callback_function
454
- *
455
- */
456
- void
331
+ void
457
332
  rb_ext_Widget_callback_function(newtComponent co, void *proc)
458
333
  {
459
334
  VALUE widget;
@@ -467,39 +342,38 @@ rb_ext_Widget_callback_function(newtComponent co, void *proc)
467
342
  };
468
343
  };
469
344
 
470
- /*
471
- * Widget_callback
472
- *
473
- */
474
- static VALUE
475
- rb_ext_Widget_callback(int argc, VALUE argv[], VALUE self)
345
+ static VALUE rb_ext_Widget_callback(int argc, VALUE argv[], VALUE self)
476
346
  {
477
347
  newtComponent co;
478
348
  VALUE arg1, value;
479
349
 
480
350
  Data_Get_Struct(self, struct newtComponent_struct, co);
481
351
  switch(rb_scan_args(argc, argv, "01", &arg1)){
482
- case 0:
483
- value = rb_hash_aref(rb_ext_Widget_CALLBACK_HASH, self);
484
- break;
485
- case 1:
486
- rb_hash_aset(rb_ext_Widget_CALLBACK_HASH, self, arg1);
487
- newtComponentAddCallback(co, rb_ext_Widget_callback_function, (void*)arg1);
488
- value = Qnil;
489
- break;
490
- default:
491
- rb_bug("rb_ext_Widget_callback");
352
+ case 0:
353
+ value = rb_hash_aref(rb_ext_Widget_CALLBACK_HASH, self);
354
+ break;
355
+ case 1:
356
+ rb_hash_aset(rb_ext_Widget_CALLBACK_HASH, self, arg1);
357
+ newtComponentAddCallback(co, rb_ext_Widget_callback_function, (void*)arg1);
358
+ value = Qnil;
359
+ break;
360
+ default:
361
+ rb_bug("rb_ext_Widget_callback");
492
362
  };
493
363
 
494
364
  return value;
495
365
  }
496
366
 
497
- /*
498
- * Widget_equal
499
- *
500
- */
501
- static VALUE
502
- rb_ext_Widget_equal(VALUE self, VALUE widget)
367
+ static VALUE rb_ext_Widget_takesFocus(VALUE self, VALUE index)
368
+ {
369
+ newtComponent form;
370
+
371
+ Data_Get_Struct(self, struct newtComponent_struct, form);
372
+ newtComponentTakesFocus(form, NUM2INT(index));
373
+ return Qnil;
374
+ }
375
+
376
+ static VALUE rb_ext_Widget_equal(VALUE self, VALUE widget)
503
377
  {
504
378
  newtComponent co, co2;
505
379
 
@@ -508,17 +382,11 @@ rb_ext_Widget_equal(VALUE self, VALUE widget)
508
382
 
509
383
  Data_Get_Struct(self, struct newtComponent_struct, co);
510
384
  Data_Get_Struct(widget, struct newtComponent_struct, co2);
511
- /*fprintf(stderr, "* %p %p", co, co2);*/
512
385
  if (co == co2) return Qtrue;
513
386
  return Qfalse;
514
387
  }
515
388
 
516
- /*
517
- * Label_new
518
- *
519
- */
520
- static VALUE
521
- rb_ext_Label_new(VALUE self, VALUE left, VALUE top, VALUE text)
389
+ static VALUE rb_ext_Label_new(VALUE self, VALUE left, VALUE top, VALUE text)
522
390
  {
523
391
  newtComponent co;
524
392
 
@@ -526,12 +394,7 @@ rb_ext_Label_new(VALUE self, VALUE left, VALUE top, VALUE text)
526
394
  return Data_Wrap_Struct(self, 0, 0, co);
527
395
  }
528
396
 
529
- /*
530
- * Label_SetText
531
- *
532
- */
533
- static VALUE
534
- rb_ext_Label_SetText(VALUE self, VALUE text)
397
+ static VALUE rb_ext_Label_SetText(VALUE self, VALUE text)
535
398
  {
536
399
  newtComponent co;
537
400
 
@@ -540,12 +403,7 @@ rb_ext_Label_SetText(VALUE self, VALUE text)
540
403
  return Qnil;
541
404
  }
542
405
 
543
- /*
544
- * CompactButton_new
545
- *
546
- */
547
- static VALUE
548
- rb_ext_CompactButton_new(VALUE self, VALUE left, VALUE top, VALUE text)
406
+ static VALUE rb_ext_CompactButton_new(VALUE self, VALUE left, VALUE top, VALUE text)
549
407
  {
550
408
  newtComponent co;
551
409
 
@@ -553,12 +411,7 @@ rb_ext_CompactButton_new(VALUE self, VALUE left, VALUE top, VALUE text)
553
411
  return Data_Wrap_Struct(self, 0, 0, co);
554
412
  }
555
413
 
556
- /*
557
- * Button_new
558
- *
559
- */
560
- static VALUE
561
- rb_ext_Button_new(VALUE self, VALUE left, VALUE top, VALUE text)
414
+ static VALUE rb_ext_Button_new(VALUE self, VALUE left, VALUE top, VALUE text)
562
415
  {
563
416
  newtComponent co;
564
417
 
@@ -566,32 +419,22 @@ rb_ext_Button_new(VALUE self, VALUE left, VALUE top, VALUE text)
566
419
  return Data_Wrap_Struct(self, 0, 0, co);
567
420
  }
568
421
 
569
- /*
570
- * Checkbox_new
571
- *
572
- */
573
- static VALUE
574
- rb_ext_Checkbox_new(VALUE self, VALUE left, VALUE top, VALUE text,
575
- VALUE defValue, VALUE seq)
422
+ static VALUE rb_ext_Checkbox_new(VALUE self, VALUE left, VALUE top, VALUE text,
423
+ VALUE defValue, VALUE seq)
576
424
  {
577
425
  newtComponent co;
578
426
 
579
427
  if (NIL_P(seq)) {
580
- co = newtCheckbox(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
581
- StringValuePtr(defValue)[0], NULL, NULL);
428
+ co = newtCheckbox(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
429
+ StringValuePtr(defValue)[0], NULL, NULL);
582
430
  } else {
583
- co = newtCheckbox(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
584
- StringValuePtr(defValue)[0], StringValuePtr(seq), NULL);
431
+ co = newtCheckbox(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
432
+ StringValuePtr(defValue)[0], StringValuePtr(seq), NULL);
585
433
  }
586
434
  return Data_Wrap_Struct(self, 0, 0, co);
587
435
  }
588
436
 
589
- /*
590
- * Checkbox_GetValue
591
- *
592
- */
593
- static VALUE
594
- rb_ext_Checkbox_GetValue(VALUE self)
437
+ static VALUE rb_ext_Checkbox_GetValue(VALUE self)
595
438
  {
596
439
  newtComponent co;
597
440
  char value[10];
@@ -602,73 +445,53 @@ rb_ext_Checkbox_GetValue(VALUE self)
602
445
  return rb_str_new2(value);
603
446
  }
604
447
 
605
- /*
606
- * Checkbox_SetValue
607
- *
608
- */
609
- static VALUE
610
- rb_ext_Checkbox_SetValue(VALUE self, VALUE value)
448
+ static VALUE rb_ext_Checkbox_SetValue(VALUE self, VALUE value)
611
449
  {
612
450
  newtComponent co;
613
451
 
614
452
  Data_Get_Struct(self, struct newtComponent_struct, co);
615
- if (RSTRING(value)->len > 0) {
616
- newtCheckboxSetValue(co, StringValuePtr(value)[0]);
453
+ if (RSTRING_LEN(value) > 0) {
454
+ newtCheckboxSetValue(co, StringValuePtr(value)[0]);
617
455
  }
618
456
  return Qnil;
619
457
  }
620
458
 
621
- /*
622
- * Checkbox_SetFlags
623
- *
624
- */
625
- static VALUE
626
- rb_ext_Checkbox_SetFlags(VALUE self, VALUE args)
459
+ static VALUE rb_ext_Checkbox_SetFlags(VALUE self, VALUE args)
627
460
  {
628
461
  newtComponent co;
629
462
  long len;
630
463
 
631
464
  len = RARRAY_LEN(args);
632
465
  if (len == 1) {
633
- Data_Get_Struct(self, struct newtComponent_struct, co);
634
- newtCheckboxSetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NEWT_FLAGS_SET);
466
+ Data_Get_Struct(self, struct newtComponent_struct, co);
467
+ newtCheckboxSetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NEWT_FLAGS_SET);
635
468
  } else if (len == 2) {
636
- Data_Get_Struct(self, struct newtComponent_struct, co);
637
- newtCheckboxSetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NUM2INT(RARRAY_PTR(args)[1]));
469
+ Data_Get_Struct(self, struct newtComponent_struct, co);
470
+ newtCheckboxSetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NUM2INT(RARRAY_PTR(args)[1]));
638
471
  } else {
639
- rb_raise(rb_eArgError, "1 argument or 2 arguments required");
472
+ rb_raise(rb_eArgError, "1 argument or 2 arguments required");
640
473
  }
641
474
 
642
475
  return Qnil;
643
476
  }
644
477
 
645
- /*
646
- * RadioButton_new
647
- *
648
- */
649
- static VALUE
650
- rb_ext_RadioButton_new(VALUE self, VALUE left, VALUE top, VALUE text,
651
- VALUE isDefault, VALUE prevButton)
478
+ static VALUE rb_ext_RadioButton_new(VALUE self, VALUE left, VALUE top, VALUE text,
479
+ VALUE isDefault, VALUE prevButton)
652
480
  {
653
481
  newtComponent co, cco;
654
482
 
655
483
  if (NIL_P(prevButton)) {
656
- co = newtRadiobutton(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
657
- NUM2INT(isDefault), NULL);
484
+ co = newtRadiobutton(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
485
+ NUM2INT(isDefault), NULL);
658
486
  } else {
659
- Data_Get_Struct(prevButton, struct newtComponent_struct, cco);
660
- co = newtRadiobutton(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
661
- NUM2INT(isDefault), cco);
487
+ Data_Get_Struct(prevButton, struct newtComponent_struct, cco);
488
+ co = newtRadiobutton(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
489
+ NUM2INT(isDefault), cco);
662
490
  }
663
491
  return Data_Wrap_Struct(self, 0, 0, co);
664
492
  }
665
493
 
666
- /*
667
- * Listbox_new
668
- *
669
- */
670
- static VALUE
671
- rb_ext_Listbox_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE flags)
494
+ static VALUE rb_ext_Listbox_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE flags)
672
495
  {
673
496
  newtComponent co;
674
497
 
@@ -676,12 +499,7 @@ rb_ext_Listbox_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE flags)
676
499
  return Data_Wrap_Struct(self, 0, 0, co);
677
500
  }
678
501
 
679
- /*
680
- * Listbox_GetCurrent
681
- *
682
- */
683
- static VALUE
684
- rb_ext_Listbox_GetCurrent(VALUE self)
502
+ static VALUE rb_ext_Listbox_GetCurrent(VALUE self)
685
503
  {
686
504
  newtComponent co;
687
505
  int i = 0;
@@ -697,12 +515,7 @@ rb_ext_Listbox_GetCurrent(VALUE self)
697
515
  return INT2NUM(i);
698
516
  }
699
517
 
700
- /*
701
- * Listbox_SetCurrent
702
- *
703
- */
704
- static VALUE
705
- rb_ext_Listbox_SetCurrent(VALUE self, VALUE num)
518
+ static VALUE rb_ext_Listbox_SetCurrent(VALUE self, VALUE num)
706
519
  {
707
520
  newtComponent co;
708
521
 
@@ -711,37 +524,27 @@ rb_ext_Listbox_SetCurrent(VALUE self, VALUE num)
711
524
  return Qnil;
712
525
  }
713
526
 
714
- /*
715
- * Listbox_SetCurrentByKey
716
- *
717
- */
718
- static VALUE
719
- rb_ext_Listbox_SetCurrentByKey(VALUE self, VALUE key)
527
+ static VALUE rb_ext_Listbox_SetCurrentByKey(VALUE self, VALUE key)
720
528
  {
721
529
  newtComponent co;
722
530
 
723
531
  Data_Get_Struct(self, struct newtComponent_struct, co);
724
532
 
725
533
  switch(TYPE(key)) {
726
- case T_STRING:
727
- newtListboxSetCurrentByKey(co, (void *)StringValuePtr(key));
728
- break;
729
- case T_FIXNUM:
730
- newtListboxSetCurrentByKey(co, (void *)NUM2INT(key));
731
- break;
732
- default:
733
- rb_raise(rb_eTypeError, "String or Fixnum expected");
734
- break;
534
+ case T_STRING:
535
+ newtListboxSetCurrentByKey(co, (void *)StringValuePtr(key));
536
+ break;
537
+ case T_FIXNUM:
538
+ newtListboxSetCurrentByKey(co, (void *)NUM2INT(key));
539
+ break;
540
+ default:
541
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
542
+ break;
735
543
  }
736
544
  return Qnil;
737
545
  }
738
546
 
739
- /*
740
- * Listbox_SetEntry
741
- *
742
- */
743
- static VALUE
744
- rb_ext_Listbox_SetEntry(VALUE self, VALUE num, VALUE text)
547
+ static VALUE rb_ext_Listbox_SetEntry(VALUE self, VALUE num, VALUE text)
745
548
  {
746
549
  newtComponent co;
747
550
 
@@ -750,12 +553,7 @@ rb_ext_Listbox_SetEntry(VALUE self, VALUE num, VALUE text)
750
553
  return Qnil;
751
554
  }
752
555
 
753
- /*
754
- * Listbox_SetWidth
755
- *
756
- */
757
- static VALUE
758
- rb_ext_Listbox_SetWidth(VALUE self, VALUE width)
556
+ static VALUE rb_ext_Listbox_SetWidth(VALUE self, VALUE width)
759
557
  {
760
558
  newtComponent co;
761
559
 
@@ -764,131 +562,106 @@ rb_ext_Listbox_SetWidth(VALUE self, VALUE width)
764
562
  return Qnil;
765
563
  }
766
564
 
767
- /*
768
- * Listbox_SetData
769
- *
770
- */
771
- static VALUE
772
- rb_ext_Listbox_SetData(VALUE self, VALUE num, VALUE data)
565
+ static VALUE rb_ext_Listbox_SetData(VALUE self, VALUE num, VALUE data)
773
566
  {
774
567
  newtComponent co;
775
568
 
776
569
  Data_Get_Struct(self, struct newtComponent_struct, co);
777
570
 
778
571
  switch(TYPE(data)) {
779
- case T_STRING:
780
- newtListboxSetData(co, NUM2INT(num), (void *)StringValuePtr(data));
781
- break;
782
- case T_FIXNUM:
783
- newtListboxSetData(co, NUM2INT(num), (void *)NUM2INT(data));
784
- break;
785
- default:
786
- rb_raise(rb_eTypeError, "String or Fixnum expected");
787
- break;
572
+ case T_STRING:
573
+ newtListboxSetData(co, NUM2INT(num), (void *)StringValuePtr(data));
574
+ break;
575
+ case T_FIXNUM:
576
+ newtListboxSetData(co, NUM2INT(num), (void *)NUM2INT(data));
577
+ break;
578
+ default:
579
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
580
+ break;
788
581
  }
789
582
  return Qnil;
790
583
  }
791
584
 
792
- /*
793
- * Listbox_AppendEntry
794
- *
795
- */
796
- static VALUE
797
- rb_ext_Listbox_AppendEntry(VALUE self, VALUE text, VALUE data)
585
+ static VALUE rb_ext_Listbox_AppendEntry(VALUE self, VALUE text, VALUE data)
798
586
  {
799
587
  newtComponent co;
800
588
 
801
589
  Data_Get_Struct(self, struct newtComponent_struct, co);
802
590
 
803
591
  switch(TYPE(data)) {
804
- case T_STRING:
805
- newtListboxAppendEntry(co, StringValuePtr(text), (void *)StringValuePtr(data));
806
- break;
807
- case T_FIXNUM:
808
- newtListboxAppendEntry(co, StringValuePtr(text), (void *)NUM2INT(data));
809
- break;
810
- default:
811
- rb_raise(rb_eTypeError, "String or Fixnum expected");
812
- break;
592
+ case T_STRING:
593
+ newtListboxAppendEntry(co, StringValuePtr(text), (void *)StringValuePtr(data));
594
+ break;
595
+ case T_FIXNUM:
596
+ newtListboxAppendEntry(co, StringValuePtr(text), (void *)NUM2INT(data));
597
+ break;
598
+ default:
599
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
600
+ break;
813
601
  }
814
602
  return Qnil;
815
603
  }
816
604
 
817
- /*
818
- * Listbox_InsertEntry
819
- *
820
- */
821
- static VALUE
822
- rb_ext_Listbox_InsertEntry(VALUE self, VALUE text, VALUE data, VALUE key)
605
+ static VALUE rb_ext_Listbox_InsertEntry(VALUE self, VALUE text, VALUE data, VALUE key)
823
606
  {
824
607
  newtComponent co;
825
608
 
826
609
  Data_Get_Struct(self, struct newtComponent_struct, co);
827
610
 
828
611
  switch(TYPE(data)) {
829
- case T_STRING:
830
- switch(TYPE(key)) {
831
- case T_STRING:
832
- newtListboxInsertEntry(co, StringValuePtr(text), (void *)StringValuePtr(data), (void *)StringValuePtr(key));
833
- break;
834
- case T_FIXNUM:
835
- newtListboxInsertEntry(co, StringValuePtr(text), (void *)StringValuePtr(data), (void *)NUM2INT(key));
836
- break;
837
- default:
838
- rb_raise(rb_eTypeError, "String or Fixnum expected");
839
- break;
840
- }
841
- case T_FIXNUM:
842
- switch(TYPE(key)) {
843
- case T_STRING:
844
- newtListboxInsertEntry(co, StringValuePtr(text), (void *)NUM2INT(data), (void *)StringValuePtr(key));
845
- break;
846
- case T_FIXNUM:
847
- newtListboxInsertEntry(co, StringValuePtr(text), (void *)NUM2INT(data), (void *)NUM2INT(key));
848
- break;
849
- default:
850
- rb_raise(rb_eTypeError, "String or Fixnum expected");
851
- break;
852
- }
853
- break;
854
- default:
855
- rb_raise(rb_eTypeError, "String or Fixnum expected");
856
- break;
612
+ case T_STRING:
613
+ switch(TYPE(key)) {
614
+ case T_STRING:
615
+ newtListboxInsertEntry(co, StringValuePtr(text), (void *)StringValuePtr(data), (void *)StringValuePtr(key));
616
+ break;
617
+ case T_FIXNUM:
618
+ newtListboxInsertEntry(co, StringValuePtr(text), (void *)StringValuePtr(data), (void *)NUM2INT(key));
619
+ break;
620
+ default:
621
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
622
+ break;
623
+ }
624
+ case T_FIXNUM:
625
+ switch(TYPE(key)) {
626
+ case T_STRING:
627
+ newtListboxInsertEntry(co, StringValuePtr(text), (void *)NUM2INT(data), (void *)StringValuePtr(key));
628
+ break;
629
+ case T_FIXNUM:
630
+ newtListboxInsertEntry(co, StringValuePtr(text), (void *)NUM2INT(data), (void *)NUM2INT(key));
631
+ break;
632
+ default:
633
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
634
+ break;
635
+ }
636
+ break;
637
+ default:
638
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
639
+ break;
857
640
  }
858
641
  return Qnil;
859
642
  }
860
643
 
861
- /*
862
- * Listbox_DeleteEntry
863
- *
864
- */
865
- static VALUE
866
- rb_ext_Listbox_DeleteEntry(VALUE self, VALUE data)
644
+ static VALUE rb_ext_Listbox_DeleteEntry(VALUE self, VALUE data)
867
645
  {
868
646
  newtComponent co;
869
647
 
870
648
  Data_Get_Struct(self, struct newtComponent_struct, co);
871
649
 
872
650
  switch(TYPE(data)) {
873
- case T_STRING:
874
- newtListboxDeleteEntry(co, (void *)StringValuePtr(data));
875
- break;
876
- case T_FIXNUM:
877
- newtListboxDeleteEntry(co, (void *)NUM2INT(data));
878
- break;
879
- default:
880
- rb_raise(rb_eTypeError, "String or Fixnum expected");
881
- break;
651
+ case T_STRING:
652
+ newtListboxDeleteEntry(co, (void *)StringValuePtr(data));
653
+ break;
654
+ case T_FIXNUM:
655
+ newtListboxDeleteEntry(co, (void *)NUM2INT(data));
656
+ break;
657
+ default:
658
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
659
+ break;
882
660
  }
883
661
  return Qnil;
884
662
  }
885
663
 
886
- /*
887
- * Listbox_Clear
888
- *
889
- */
890
- static VALUE
891
- rb_ext_Listbox_Clear(VALUE self)
664
+ static VALUE rb_ext_Listbox_Clear(VALUE self)
892
665
  {
893
666
  newtComponent co;
894
667
 
@@ -898,12 +671,7 @@ rb_ext_Listbox_Clear(VALUE self)
898
671
  return Qnil;
899
672
  }
900
673
 
901
- /*
902
- * Listbox_ClearSelection
903
- *
904
- */
905
- static VALUE
906
- rb_ext_Listbox_ClearSelection(VALUE self)
674
+ static VALUE rb_ext_Listbox_ClearSelection(VALUE self)
907
675
  {
908
676
  newtComponent co;
909
677
 
@@ -913,37 +681,27 @@ rb_ext_Listbox_ClearSelection(VALUE self)
913
681
  return Qnil;
914
682
  }
915
683
 
916
- /*
917
- * Listbox_SelectItem
918
- *
919
- */
920
- static VALUE
921
- rb_ext_Listbox_SelectItem(VALUE self, VALUE key, VALUE sense)
684
+ static VALUE rb_ext_Listbox_SelectItem(VALUE self, VALUE key, VALUE sense)
922
685
  {
923
686
  newtComponent co;
924
687
 
925
688
  Data_Get_Struct(self, struct newtComponent_struct, co);
926
689
 
927
690
  switch(TYPE(key)) {
928
- case T_STRING:
929
- newtListboxSelectItem(co, (void *)StringValuePtr(key), NUM2INT(sense));
930
- break;
931
- case T_FIXNUM:
932
- newtListboxSelectItem(co, (void *)NUM2INT(key), NUM2INT(sense));
933
- break;
934
- default:
935
- rb_raise(rb_eTypeError, "String or Fixnum expected");
936
- break;
691
+ case T_STRING:
692
+ newtListboxSelectItem(co, (void *)StringValuePtr(key), NUM2INT(sense));
693
+ break;
694
+ case T_FIXNUM:
695
+ newtListboxSelectItem(co, (void *)NUM2INT(key), NUM2INT(sense));
696
+ break;
697
+ default:
698
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
699
+ break;
937
700
  }
938
701
  return Qnil;
939
702
  }
940
703
 
941
- /*
942
- * CheckboxTree_new
943
- *
944
- */
945
- static VALUE
946
- rb_ext_CheckboxTree_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE flags)
704
+ static VALUE rb_ext_CheckboxTree_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE flags)
947
705
  {
948
706
  newtComponent co;
949
707
 
@@ -951,14 +709,9 @@ rb_ext_CheckboxTree_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE f
951
709
  return Data_Wrap_Struct(self, 0, 0, co);
952
710
  }
953
711
 
954
- /*
955
- * CheckboxTree_AddItem
956
- *
957
- */
958
- static VALUE
959
- rb_ext_CheckboxTree_AddItem(VALUE self, VALUE args)
960
- /*rb_ext_CheckboxTree_AddItem(VALUE self, VALUE text, VALUE data, VALUE flags)*/
961
- /*, VALUE index)*/
712
+ static VALUE rb_ext_CheckboxTree_AddItem(VALUE self, VALUE args)
713
+ /*rb_ext_CheckboxTree_AddItem(VALUE self, VALUE text, VALUE data, VALUE flags)*/
714
+ /*, VALUE index)*/
962
715
  {
963
716
  newtComponent co;
964
717
  #if 1
@@ -967,72 +720,62 @@ rb_ext_CheckboxTree_AddItem(VALUE self, VALUE args)
967
720
 
968
721
  len = RARRAY_LEN(args);
969
722
  if (len < 4) {
970
- rb_raise(rb_eArgError, "4 arguments required");
723
+ rb_raise(rb_eArgError, "4 arguments required");
971
724
  } else {
972
- Data_Get_Struct(self, struct newtComponent_struct, co);
973
-
974
- indexes = ALLOCA_N(int, (len - 4) + 2);
975
- for (i = 0; i < (len - 4) + 1; i++) {
976
- indexes[i] = NUM2INT(RARRAY_PTR(args)[i+3]);
977
- }
978
- indexes[(len - 4) + 1] = NEWT_ARG_LAST;
979
-
980
- switch(TYPE(RARRAY_PTR(args)[1])) {
981
- case T_STRING:
982
- newtCheckboxTreeAddArray(co, StringValuePtr(RARRAY_PTR(args)[0]), (void *)StringValuePtr(RARRAY_PTR(args)[1]),
983
- NUM2INT(RARRAY_PTR(args)[2]), indexes);
984
- break;
985
- case T_FIXNUM:
986
- newtCheckboxTreeAddArray(co, StringValuePtr(RARRAY_PTR(args)[0]), (void *)NUM2INT(RARRAY_PTR(args)[1]),
987
- NUM2INT(RARRAY_PTR(args)[2]), indexes);
988
- break;
989
- default:
990
- rb_raise(rb_eTypeError, "String or Fixnum expected");
991
- break;
992
- }
993
- return Qnil;
725
+ Data_Get_Struct(self, struct newtComponent_struct, co);
726
+
727
+ indexes = ALLOCA_N(int, (len - 4) + 2);
728
+ for (i = 0; i < (len - 4) + 1; i++) {
729
+ indexes[i] = NUM2INT(RARRAY_PTR(args)[i+3]);
730
+ }
731
+ indexes[(len - 4) + 1] = NEWT_ARG_LAST;
732
+
733
+ switch(TYPE(RARRAY_PTR(args)[1])) {
734
+ case T_STRING:
735
+ newtCheckboxTreeAddArray(co, StringValuePtr(RARRAY_PTR(args)[0]), (void *)StringValuePtr(RARRAY_PTR(args)[1]),
736
+ NUM2INT(RARRAY_PTR(args)[2]), indexes);
737
+ break;
738
+ case T_FIXNUM:
739
+ newtCheckboxTreeAddArray(co, StringValuePtr(RARRAY_PTR(args)[0]), (void *)NUM2INT(RARRAY_PTR(args)[1]),
740
+ NUM2INT(RARRAY_PTR(args)[2]), indexes);
741
+ break;
742
+ default:
743
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
744
+ break;
745
+ }
746
+ return Qnil;
994
747
  }
995
748
  #else
996
749
  Data_Get_Struct(self, struct newtComponent_struct, co);
997
750
 
998
751
  switch(TYPE(data)) {
999
- case T_STRING:
1000
- newtCheckboxTreeAddItem(co, StringValuePtr(text), (void *)StringValuePtr(data), NUM2INT(flags), NEWT_ARG_APPEND, NEWT_ARG_LAST);
1001
- break;
1002
- case T_FIXNUM:
1003
- newtCheckboxTreeAddItem(co, StringValuePtr(text), (void *)NUM2INT(data), NUM2INT(flags), NEWT_ARG_APPEND, NEWT_ARG_LAST);
1004
- break;
1005
- default:
1006
- rb_raise(rb_eTypeError, "String or Fixnum expected");
1007
- break;
752
+ case T_STRING:
753
+ newtCheckboxTreeAddItem(co, StringValuePtr(text), (void *)StringValuePtr(data), NUM2INT(flags), NEWT_ARG_APPEND, NEWT_ARG_LAST);
754
+ break;
755
+ case T_FIXNUM:
756
+ newtCheckboxTreeAddItem(co, StringValuePtr(text), (void *)NUM2INT(data), NUM2INT(flags), NEWT_ARG_APPEND, NEWT_ARG_LAST);
757
+ break;
758
+ default:
759
+ rb_raise(rb_eTypeError, "String or Fixnum expected");
760
+ break;
1008
761
  }
1009
762
  return Qnil;
1010
763
  #endif
1011
764
  }
1012
765
 
1013
- /*
1014
- * CheckboxTreeMulti_new
1015
- *
1016
- */
1017
- static VALUE
1018
- rb_ext_CheckboxTreeMulti_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE seq, VALUE flags)
766
+ static VALUE rb_ext_CheckboxTreeMulti_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE seq, VALUE flags)
1019
767
  {
1020
768
  newtComponent co;
1021
769
 
1022
770
  if (NIL_P(seq)) {
1023
- co = newtCheckboxTreeMulti(NUM2INT(left), NUM2INT(top), NUM2INT(height), NULL, NUM2INT(flags));
771
+ co = newtCheckboxTreeMulti(NUM2INT(left), NUM2INT(top), NUM2INT(height), NULL, NUM2INT(flags));
1024
772
  } else {
1025
- co = newtCheckboxTreeMulti(NUM2INT(left), NUM2INT(top), NUM2INT(height), StringValuePtr(seq), NUM2INT(flags));
773
+ co = newtCheckboxTreeMulti(NUM2INT(left), NUM2INT(top), NUM2INT(height), StringValuePtr(seq), NUM2INT(flags));
1026
774
  }
1027
775
  return Data_Wrap_Struct(self, 0, 0, co);
1028
776
  }
1029
777
 
1030
- /*
1031
- * Textbox_new
1032
- *
1033
- */
1034
- static VALUE
1035
- rb_ext_Textbox_new(VALUE self, VALUE left, VALUE top, VALUE width, VALUE height, VALUE flags)
778
+ static VALUE rb_ext_Textbox_new(VALUE self, VALUE left, VALUE top, VALUE width, VALUE height, VALUE flags)
1036
779
  {
1037
780
  newtComponent co;
1038
781
 
@@ -1040,12 +783,7 @@ rb_ext_Textbox_new(VALUE self, VALUE left, VALUE top, VALUE width, VALUE height,
1040
783
  return Data_Wrap_Struct(self, 0, 0, co);
1041
784
  }
1042
785
 
1043
- /*
1044
- * Textbox_SetText
1045
- *
1046
- */
1047
- static VALUE
1048
- rb_ext_Textbox_SetText(VALUE self, VALUE text)
786
+ static VALUE rb_ext_Textbox_SetText(VALUE self, VALUE text)
1049
787
  {
1050
788
  newtComponent co;
1051
789
 
@@ -1054,12 +792,7 @@ rb_ext_Textbox_SetText(VALUE self, VALUE text)
1054
792
  return Qnil;
1055
793
  }
1056
794
 
1057
- /*
1058
- * Textbox_SetHeight
1059
- *
1060
- */
1061
- static VALUE
1062
- rb_ext_Textbox_SetHeight(VALUE self, VALUE height)
795
+ static VALUE rb_ext_Textbox_SetHeight(VALUE self, VALUE height)
1063
796
  {
1064
797
  newtComponent co;
1065
798
 
@@ -1068,12 +801,7 @@ rb_ext_Textbox_SetHeight(VALUE self, VALUE height)
1068
801
  return Qnil;
1069
802
  }
1070
803
 
1071
- /*
1072
- * Textbox_GetNumLines
1073
- *
1074
- */
1075
- static VALUE
1076
- rb_ext_Textbox_GetNumLines(VALUE self)
804
+ static VALUE rb_ext_Textbox_GetNumLines(VALUE self)
1077
805
  {
1078
806
  newtComponent co;
1079
807
 
@@ -1081,41 +809,26 @@ rb_ext_Textbox_GetNumLines(VALUE self)
1081
809
  return INT2NUM(newtTextboxGetNumLines(co));
1082
810
  }
1083
811
 
1084
- /*
1085
- * TextboxReflowed_new
1086
- *
1087
- */
1088
- static VALUE
1089
- rb_ext_TextboxReflowed_new(VALUE self, VALUE left, VALUE top, VALUE text, VALUE width, VALUE flexDown, VALUE flexUp, VALUE flags)
812
+ static VALUE rb_ext_TextboxReflowed_new(VALUE self, VALUE left, VALUE top, VALUE text, VALUE width, VALUE flexDown, VALUE flexUp, VALUE flags)
1090
813
  {
1091
814
  newtComponent co;
1092
815
 
1093
816
  co = newtTextboxReflowed(NUM2INT(left), NUM2INT(top), StringValuePtr(text), NUM2INT(width),
1094
- NUM2INT(flexDown), NUM2INT(flexUp), NUM2INT(flags));
817
+ NUM2INT(flexDown), NUM2INT(flexUp), NUM2INT(flags));
1095
818
  return Data_Wrap_Struct(self, 0, 0, co);
1096
819
  }
1097
820
 
1098
- /*
1099
- * Form_Destroy
1100
- *
1101
- */
1102
- static void
1103
- rb_ext_Form_Destroy(VALUE self)
821
+ static void rb_ext_Form_Destroy(VALUE self)
1104
822
  {
1105
823
  newtComponent form;
1106
824
 
1107
825
  if (self) {
1108
- Data_Get_Struct(cForm, struct newtComponent_struct, form);
1109
- newtFormDestroy(form);
826
+ Data_Get_Struct(cForm, struct newtComponent_struct, form);
827
+ newtFormDestroy(form);
1110
828
  }
1111
829
  }
1112
830
 
1113
- /*
1114
- * Form_new
1115
- *
1116
- */
1117
- static VALUE
1118
- rb_ext_Form_new(VALUE self, VALUE left, VALUE top, VALUE text)
831
+ static VALUE rb_ext_Form_new(VALUE self, VALUE left, VALUE top, VALUE text)
1119
832
  {
1120
833
  newtComponent co;
1121
834
 
@@ -1123,12 +836,7 @@ rb_ext_Form_new(VALUE self, VALUE left, VALUE top, VALUE text)
1123
836
  return Data_Wrap_Struct(self, 0, rb_ext_Form_Destroy, co);
1124
837
  }
1125
838
 
1126
- /*
1127
- * Form_SetBackground
1128
- *
1129
- */
1130
- static VALUE
1131
- rb_ext_Form_SetBackground(VALUE self, VALUE color)
839
+ static VALUE rb_ext_Form_SetBackground(VALUE self, VALUE color)
1132
840
  {
1133
841
  newtComponent form;
1134
842
 
@@ -1138,8 +846,7 @@ rb_ext_Form_SetBackground(VALUE self, VALUE color)
1138
846
  }
1139
847
 
1140
848
  #if 0
1141
- static VALUE
1142
- rb_ext_Form_AddComponent(VALUE self, VALUE co)
849
+ static VALUE rb_ext_Form_AddComponent(VALUE self, VALUE co)
1143
850
  {
1144
851
  newtComponent form, cco;
1145
852
 
@@ -1150,12 +857,7 @@ rb_ext_Form_AddComponent(VALUE self, VALUE co)
1150
857
  }
1151
858
  #endif
1152
859
 
1153
- /*
1154
- * Form_AddComponents
1155
- *
1156
- */
1157
- static VALUE
1158
- rb_ext_Form_AddComponents(VALUE self, VALUE co)
860
+ static VALUE rb_ext_Form_AddComponents(VALUE self, VALUE co)
1159
861
  {
1160
862
  int i;
1161
863
  newtComponent form, cco;
@@ -1163,18 +865,13 @@ rb_ext_Form_AddComponents(VALUE self, VALUE co)
1163
865
  Data_Get_Struct(self, struct newtComponent_struct, form);
1164
866
 
1165
867
  for (i = 0; i < RARRAY_LEN(co); i++) {
1166
- Data_Get_Struct(RARRAY_PTR(co)[i], struct newtComponent_struct, cco);
1167
- newtFormAddComponent(form, cco);
868
+ Data_Get_Struct(RARRAY_PTR(co)[i], struct newtComponent_struct, cco);
869
+ newtFormAddComponent(form, cco);
1168
870
  }
1169
871
  return Qnil;
1170
872
  }
1171
873
 
1172
- /*
1173
- * Form_SetHeight
1174
- *
1175
- */
1176
- static VALUE
1177
- rb_ext_Form_SetHeight(VALUE self, VALUE height)
874
+ static VALUE rb_ext_Form_SetHeight(VALUE self, VALUE height)
1178
875
  {
1179
876
  newtComponent form;
1180
877
 
@@ -1183,12 +880,7 @@ rb_ext_Form_SetHeight(VALUE self, VALUE height)
1183
880
  return Qnil;
1184
881
  }
1185
882
 
1186
- /*
1187
- * Form_SetWidth
1188
- *
1189
- */
1190
- static VALUE
1191
- rb_ext_Form_SetWidth(VALUE self, VALUE width)
883
+ static VALUE rb_ext_Form_SetWidth(VALUE self, VALUE width)
1192
884
  {
1193
885
  newtComponent form;
1194
886
 
@@ -1197,12 +889,7 @@ rb_ext_Form_SetWidth(VALUE self, VALUE width)
1197
889
  return Qnil;
1198
890
  }
1199
891
 
1200
- /*
1201
- * Run_Form
1202
- *
1203
- */
1204
- static VALUE
1205
- rb_ext_Run_Form(VALUE self)
892
+ static VALUE rb_ext_Run_Form(VALUE self)
1206
893
  {
1207
894
  newtComponent form, co;
1208
895
 
@@ -1211,12 +898,7 @@ rb_ext_Run_Form(VALUE self)
1211
898
  return Data_Wrap_Struct(cWidget, 0, 0, co);
1212
899
  }
1213
900
 
1214
- /*
1215
- * Form_DrawForm
1216
- *
1217
- */
1218
- static VALUE
1219
- rb_ext_Form_DrawForm(VALUE self)
901
+ static VALUE rb_ext_Form_DrawForm(VALUE self)
1220
902
  {
1221
903
  newtComponent form;
1222
904
 
@@ -1225,12 +907,7 @@ rb_ext_Form_DrawForm(VALUE self)
1225
907
  return Qnil;
1226
908
  }
1227
909
 
1228
- /*
1229
- * Form_AddHotKey
1230
- *
1231
- */
1232
- static VALUE
1233
- rb_ext_Form_AddHotKey(VALUE self, VALUE key)
910
+ static VALUE rb_ext_Form_AddHotKey(VALUE self, VALUE key)
1234
911
  {
1235
912
  newtComponent form;
1236
913
 
@@ -1239,54 +916,39 @@ rb_ext_Form_AddHotKey(VALUE self, VALUE key)
1239
916
  return Qnil;
1240
917
  }
1241
918
 
1242
- /*
1243
- * Entry_new
1244
- *
1245
- */
1246
- static VALUE
1247
- rb_ext_Entry_new(VALUE self, VALUE left, VALUE top, VALUE initialValue, VALUE width, VALUE flags)
919
+ static VALUE rb_ext_Entry_new(VALUE self, VALUE left, VALUE top, VALUE initialValue, VALUE width, VALUE flags)
1248
920
  {
1249
921
  newtComponent co;
1250
922
 
1251
923
  co = newtEntry(NUM2INT(left), NUM2INT(top), StringValuePtr(initialValue), NUM2INT(width),
1252
- NULL, NUM2INT(flags));
924
+ NULL, NUM2INT(flags));
1253
925
  return Data_Wrap_Struct(self, 0, 0, co);
1254
926
  }
1255
927
 
1256
- /*
1257
- * Entry_Set
1258
- *
1259
- */
1260
- static VALUE
1261
- rb_ext_Entry_Set(VALUE self, VALUE value, VALUE cursorAtEnd)
928
+ static VALUE rb_ext_Entry_Set(VALUE self, VALUE value, VALUE cursorAtEnd)
1262
929
  {
1263
930
  newtComponent co;
1264
931
 
1265
932
  Data_Get_Struct(self, struct newtComponent_struct, co);
1266
933
  switch(TYPE(cursorAtEnd)) {
1267
- case T_TRUE:
1268
- newtEntrySet(co, StringValuePtr(value), 1);
1269
- break;
1270
- case T_FALSE:
1271
- newtEntrySet(co, StringValuePtr(value), 0);
1272
- break;
1273
- case T_FIXNUM:
1274
- newtEntrySet(co, StringValuePtr(value), NUM2INT(cursorAtEnd));
1275
- break;
1276
- default:
1277
- rb_raise(rb_eTypeError, "Boolean or Fixnum expected");
1278
- break;
934
+ case T_TRUE:
935
+ newtEntrySet(co, StringValuePtr(value), 1);
936
+ break;
937
+ case T_FALSE:
938
+ newtEntrySet(co, StringValuePtr(value), 0);
939
+ break;
940
+ case T_FIXNUM:
941
+ newtEntrySet(co, StringValuePtr(value), NUM2INT(cursorAtEnd));
942
+ break;
943
+ default:
944
+ rb_raise(rb_eTypeError, "Boolean or Fixnum expected");
945
+ break;
1279
946
  }
1280
-
947
+
1281
948
  return Qnil;
1282
949
  }
1283
950
 
1284
- /*
1285
- * Entry_GetValue
1286
- *
1287
- */
1288
- static VALUE
1289
- rb_ext_Entry_GetValue(VALUE self)
951
+ static VALUE rb_ext_Entry_GetValue(VALUE self)
1290
952
  {
1291
953
  newtComponent co;
1292
954
 
@@ -1294,35 +956,25 @@ rb_ext_Entry_GetValue(VALUE self)
1294
956
  return rb_str_new2(newtEntryGetValue(co));
1295
957
  }
1296
958
 
1297
- /*
1298
- * Entry_SetFlags
1299
- *
1300
- */
1301
- static VALUE
1302
- rb_ext_Entry_SetFlags(VALUE self, VALUE args)
959
+ static VALUE rb_ext_Entry_SetFlags(VALUE self, VALUE args)
1303
960
  {
1304
961
  newtComponent co;
1305
962
  long len;
1306
963
 
1307
964
  len = RARRAY_LEN(args);
1308
965
  if (len == 1) {
1309
- Data_Get_Struct(self, struct newtComponent_struct, co);
1310
- newtEntrySetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NEWT_FLAGS_SET);
966
+ Data_Get_Struct(self, struct newtComponent_struct, co);
967
+ newtEntrySetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NEWT_FLAGS_SET);
1311
968
  } else if (len == 2) {
1312
- Data_Get_Struct(self, struct newtComponent_struct, co);
1313
- newtEntrySetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NUM2INT(RARRAY_PTR(args)[1]));
969
+ Data_Get_Struct(self, struct newtComponent_struct, co);
970
+ newtEntrySetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NUM2INT(RARRAY_PTR(args)[1]));
1314
971
  } else {
1315
- rb_raise(rb_eArgError, "1 argument or 2 arguments required");
972
+ rb_raise(rb_eArgError, "1 argument or 2 arguments required");
1316
973
  }
1317
974
  return Qnil;
1318
975
  }
1319
976
 
1320
- /*
1321
- * Scale_new
1322
- *
1323
- */
1324
- static VALUE
1325
- rb_ext_Scale_new(VALUE self, VALUE left, VALUE top, VALUE width, VALUE fullValue)
977
+ static VALUE rb_ext_Scale_new(VALUE self, VALUE left, VALUE top, VALUE width, VALUE fullValue)
1326
978
  {
1327
979
  newtComponent co;
1328
980
 
@@ -1330,12 +982,7 @@ rb_ext_Scale_new(VALUE self, VALUE left, VALUE top, VALUE width, VALUE fullValue
1330
982
  return Data_Wrap_Struct(self, 0, 0, co);
1331
983
  }
1332
984
 
1333
- /*
1334
- * Scale_Set
1335
- *
1336
- */
1337
- static VALUE
1338
- rb_ext_Scale_Set(VALUE self, VALUE amount)
985
+ static VALUE rb_ext_Scale_Set(VALUE self, VALUE amount)
1339
986
  {
1340
987
  newtComponent co;
1341
988
 
@@ -1344,27 +991,17 @@ rb_ext_Scale_Set(VALUE self, VALUE amount)
1344
991
  return Qnil;
1345
992
  }
1346
993
 
1347
- /*
1348
- * Grid_free
1349
- *
1350
- */
1351
- static void
1352
- rb_ext_Grid_free(VALUE self)
994
+ static void rb_ext_Grid_free(VALUE self)
1353
995
  {
1354
996
  newtGrid grid;
1355
997
 
1356
998
  if (self) {
1357
- Data_Get_Struct(cGrid, struct grid_s, grid);
1358
- newtGridFree(grid, 1);
999
+ Data_Get_Struct(cGrid, struct grid_s, grid);
1000
+ newtGridFree(grid, 1);
1359
1001
  }
1360
1002
  }
1361
1003
 
1362
- /*
1363
- * Grid_new
1364
- *
1365
- */
1366
- static VALUE
1367
- rb_ext_Grid_new(VALUE self, VALUE cols, VALUE rows)
1004
+ static VALUE rb_ext_Grid_new(VALUE self, VALUE cols, VALUE rows)
1368
1005
  {
1369
1006
  newtGrid grid;
1370
1007
 
@@ -1373,14 +1010,9 @@ rb_ext_Grid_new(VALUE self, VALUE cols, VALUE rows)
1373
1010
  return Data_Wrap_Struct(self, 0, rb_ext_Grid_free, grid);
1374
1011
  }
1375
1012
 
1376
- /*
1377
- * Grid_SetField
1378
- *
1379
- */
1380
- static VALUE
1381
- rb_ext_Grid_SetField(VALUE self, VALUE col, VALUE row, VALUE type, VALUE val,
1382
- VALUE padLeft, VALUE padTop, VALUE padRight, VALUE padBottom,
1383
- VALUE anchor, VALUE flags)
1013
+ static VALUE rb_ext_Grid_SetField(VALUE self, VALUE col, VALUE row, VALUE type, VALUE val,
1014
+ VALUE padLeft, VALUE padTop, VALUE padRight, VALUE padBottom,
1015
+ VALUE anchor, VALUE flags)
1384
1016
  {
1385
1017
  newtGrid grid;
1386
1018
  newtComponent co;
@@ -1388,42 +1020,32 @@ rb_ext_Grid_SetField(VALUE self, VALUE col, VALUE row, VALUE type, VALUE val,
1388
1020
  Data_Get_Struct(self, struct grid_s, grid);
1389
1021
  Data_Get_Struct(val, struct newtComponent_struct, co);
1390
1022
  newtGridSetField(grid, NUM2INT(col), NUM2INT(row), NUM2INT(type), co,
1391
- NUM2INT(padLeft), NUM2INT(padTop), NUM2INT(padRight), NUM2INT(padBottom),
1392
- NUM2INT(anchor), NUM2INT(flags));
1023
+ NUM2INT(padLeft), NUM2INT(padTop), NUM2INT(padRight), NUM2INT(padBottom),
1024
+ NUM2INT(anchor), NUM2INT(flags));
1393
1025
  return Qnil;
1394
1026
  }
1395
1027
 
1396
- /*
1397
- * Grid_WrappedWindow
1398
- *
1399
- */
1400
- static VALUE
1401
- rb_ext_Grid_WrappedWindow(VALUE self, VALUE args)
1028
+ static VALUE rb_ext_Grid_WrappedWindow(VALUE self, VALUE args)
1402
1029
  {
1403
1030
  newtGrid grid;
1404
1031
  long len;
1405
1032
 
1406
1033
  len = RARRAY_LEN(args);
1407
1034
  if (len == 1) {
1408
- Data_Get_Struct(self, struct grid_s, grid);
1409
- newtGridWrappedWindow(grid, StringValuePtr(RARRAY_PTR(args)[0]));
1035
+ Data_Get_Struct(self, struct grid_s, grid);
1036
+ newtGridWrappedWindow(grid, StringValuePtr(RARRAY_PTR(args)[0]));
1410
1037
  } else if (len == 3) {
1411
- Data_Get_Struct(self, struct grid_s, grid);
1412
- newtGridWrappedWindowAt(grid, StringValuePtr(RARRAY_PTR(args)[0]),
1413
- NUM2INT(StringValuePtr(RARRAY_PTR(args)[1])), NUM2INT(StringValuePtr(RARRAY_PTR(args)[2])));
1038
+ Data_Get_Struct(self, struct grid_s, grid);
1039
+ newtGridWrappedWindowAt(grid, StringValuePtr(RARRAY_PTR(args)[0]),
1040
+ NUM2INT(StringValuePtr(RARRAY_PTR(args)[1])), NUM2INT(StringValuePtr(RARRAY_PTR(args)[2])));
1414
1041
  } else {
1415
- rb_raise(rb_eArgError, "1 argument or 3 arguments required");
1042
+ rb_raise(rb_eArgError, "1 argument or 3 arguments required");
1416
1043
  }
1417
-
1044
+
1418
1045
  return Qnil;
1419
1046
  }
1420
1047
 
1421
- /*
1422
- * Grid_GetSize
1423
- *
1424
- */
1425
- static VALUE
1426
- rb_ext_Grid_GetSize(VALUE self)
1048
+ static VALUE rb_ext_Grid_GetSize(VALUE self)
1427
1049
  {
1428
1050
  int width, height;
1429
1051
  newtGrid grid;
@@ -1437,12 +1059,7 @@ rb_ext_Grid_GetSize(VALUE self)
1437
1059
  return ary;
1438
1060
  }
1439
1061
 
1440
- /*
1441
- * Init_ruby_newt
1442
- *
1443
- */
1444
- void
1445
- Init_ruby_newt(){
1062
+ void Init_ruby_newt(){
1446
1063
  mNewt = rb_define_module("Newt");
1447
1064
  rb_define_module_function(mNewt, "reflow_text", rb_ext_ReflowText, 4);
1448
1065
 
@@ -1476,27 +1093,28 @@ Init_ruby_newt(){
1476
1093
 
1477
1094
  cWidget = rb_define_class_under(mNewt, "Widget", rb_cObject);
1478
1095
  rb_define_method(cWidget, "callback", rb_ext_Widget_callback, -1);
1096
+ rb_define_method(cWidget, "takesFocus", rb_ext_Widget_takesFocus, 1);
1479
1097
  rb_define_method(cWidget, "==", rb_ext_Widget_equal, 1);
1480
1098
 
1481
1099
  cCompactButton = rb_define_class_under(mNewt, "CompactButton", cWidget);
1482
1100
  rb_define_singleton_method(cCompactButton, "new", rb_ext_CompactButton_new, 3);
1483
-
1101
+
1484
1102
  cButton = rb_define_class_under(mNewt, "Button", cWidget);
1485
1103
  rb_define_singleton_method(cButton, "new", rb_ext_Button_new, 3);
1486
-
1104
+
1487
1105
  cCheckbox = rb_define_class_under(mNewt, "Checkbox", cWidget);
1488
1106
  rb_define_singleton_method(cCheckbox, "new", rb_ext_Checkbox_new, 5);
1489
1107
  rb_define_method(cCheckbox, "get", rb_ext_Checkbox_GetValue, 0);
1490
1108
  rb_define_method(cCheckbox, "set", rb_ext_Checkbox_SetValue, 1);
1491
1109
  rb_define_method(cCheckbox, "set_flags", rb_ext_Checkbox_SetFlags, -2);
1492
-
1110
+
1493
1111
  cRadioButton = rb_define_class_under(mNewt, "RadioButton", cWidget);
1494
1112
  rb_define_singleton_method(cRadioButton, "new", rb_ext_RadioButton_new, 5);
1495
1113
 
1496
1114
  cLabel = rb_define_class_under(mNewt, "Label", cWidget);
1497
1115
  rb_define_singleton_method(cLabel, "new", rb_ext_Label_new, 3);
1498
1116
  rb_define_method(cLabel, "set_text", rb_ext_Label_SetText, 1);
1499
-
1117
+
1500
1118
  cListbox = rb_define_class_under(mNewt, "Listbox", cWidget);
1501
1119
  rb_define_singleton_method(cListbox, "new", rb_ext_Listbox_new, 4);
1502
1120
  rb_define_method(cListbox, "get_current", rb_ext_Listbox_GetCurrent, 0);
@@ -1559,7 +1177,7 @@ Init_ruby_newt(){
1559
1177
  rb_define_method(cGrid, "set_field", rb_ext_Grid_SetField, 10);
1560
1178
  rb_define_method(cGrid, "wrapped_window", rb_ext_Grid_WrappedWindow, -2);
1561
1179
  rb_define_method(cGrid, "get_size", rb_ext_Grid_GetSize, 0);
1562
-
1180
+
1563
1181
  rb_define_const(mNewt, "COLORSET_ROOT", INT2FIX(NEWT_COLORSET_ROOT));
1564
1182
  rb_define_const(mNewt, "COLORSET_BORDER", INT2FIX(NEWT_COLORSET_BORDER));
1565
1183
  rb_define_const(mNewt, "COLORSET_WINDOW", INT2FIX(NEWT_COLORSET_WINDOW));
@@ -1600,7 +1218,9 @@ Init_ruby_newt(){
1600
1218
  rb_define_const(mNewt, "FLAG_MULTIPLE", INT2FIX(NEWT_FLAG_MULTIPLE));
1601
1219
  rb_define_const(mNewt, "FLAG_SELECTED", INT2FIX(NEWT_FLAG_SELECTED));
1602
1220
  rb_define_const(mNewt, "FLAG_CHECKBOX", INT2FIX(NEWT_FLAG_CHECKBOX));
1603
-
1221
+ rb_define_const(mNewt, "FLAG_PASSWORD", INT2FIX(NEWT_FLAG_PASSWORD));
1222
+ rb_define_const(mNewt, "FLAG_SHOWCURSOR", INT2FIX(NEWT_FLAG_SHOWCURSOR));
1223
+
1604
1224
  rb_define_const(mNewt, "ANCHOR_LEFT", INT2FIX(NEWT_ANCHOR_LEFT));
1605
1225
  rb_define_const(mNewt, "ANCHOR_RIGHT", INT2FIX(NEWT_ANCHOR_RIGHT));
1606
1226
  rb_define_const(mNewt, "ANCHOR_TOP", INT2FIX(NEWT_ANCHOR_TOP));