libui_paradise 0.1.49

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.

Potentially problematic release.


This version of libui_paradise might be problematic. Click here for more details.

Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1505 -0
  3. data/doc/README.gen +1252 -0
  4. data/doc/SNIPPETS.md +221 -0
  5. data/doc/TODO.md +14 -0
  6. data/lib/libui_paradise/autoinclude.rb +9 -0
  7. data/lib/libui_paradise/domain_specific_language/README.md +5 -0
  8. data/lib/libui_paradise/domain_specific_language/button.yml +7 -0
  9. data/lib/libui_paradise/examples/001_basic_button_example.rb +17 -0
  10. data/lib/libui_paradise/examples/002_basic_table_image.rb +92 -0
  11. data/lib/libui_paradise/examples/003_font_button.rb +34 -0
  12. data/lib/libui_paradise/examples/004_date_time_picker.rb +31 -0
  13. data/lib/libui_paradise/examples/005_msg_box_error.rb +25 -0
  14. data/lib/libui_paradise/examples/006_histogram.rb +193 -0
  15. data/lib/libui_paradise/examples/007_combo_box_example.rb +41 -0
  16. data/lib/libui_paradise/examples/008_simple_notepad_example.rb +23 -0
  17. data/lib/libui_paradise/examples/009_checkbox_example.rb +82 -0
  18. data/lib/libui_paradise/examples/010_grid_example.rb +26 -0
  19. data/lib/libui_paradise/examples/011_fancy_text_example.rb +21 -0
  20. data/lib/libui_paradise/examples/012_control_gallery.rb +180 -0
  21. data/lib/libui_paradise/examples/013_midi_player.rb +91 -0
  22. data/lib/libui_paradise/examples/014_basic_draw_text.rb +134 -0
  23. data/lib/libui_paradise/examples/015_font_example.rb +91 -0
  24. data/lib/libui_paradise/examples/016_search_entry_example.rb +16 -0
  25. data/lib/libui_paradise/examples/017_tabs_example.rb +22 -0
  26. data/lib/libui_paradise/examples/018_image_example.rb +82 -0
  27. data/lib/libui_paradise/examples/019_open_file_button_example.rb +24 -0
  28. data/lib/libui_paradise/examples/020_unicode_text_example.rb +28 -0
  29. data/lib/libui_paradise/examples/021_spinbutton_example.rb +25 -0
  30. data/lib/libui_paradise/examples/022_text_example.rb +16 -0
  31. data/lib/libui_paradise/examples/023_parse_config_file_example.config +6 -0
  32. data/lib/libui_paradise/examples/023_parse_config_file_example.rb +13 -0
  33. data/lib/libui_paradise/examples/024_text_view_example.rb +14 -0
  34. data/lib/libui_paradise/examples/025_scrolling_area.rb +16 -0
  35. data/lib/libui_paradise/examples/026_colour_button.rb +51 -0
  36. data/lib/libui_paradise/examples/027_form_example.rb +37 -0
  37. data/lib/libui_paradise/examples/028_password_entry_example.rb +17 -0
  38. data/lib/libui_paradise/examples/029_two_buttons_showing_how_to_enable_and_disable_them.rb +32 -0
  39. data/lib/libui_paradise/examples/030_table_example.rb +51 -0
  40. data/lib/libui_paradise/experimental/dsl.rb +17 -0
  41. data/lib/libui_paradise/extensions/extensions.rb +25 -0
  42. data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +129 -0
  43. data/lib/libui_paradise/extensions/misc.rb +309 -0
  44. data/lib/libui_paradise/fiddle/pointer.rb +841 -0
  45. data/lib/libui_paradise/images/LIBUI_PARADISE_LOGO.png +0 -0
  46. data/lib/libui_paradise/images/README.md +2 -0
  47. data/lib/libui_paradise/images/form_example.png +0 -0
  48. data/lib/libui_paradise/libui_classes/area_handler.rb +52 -0
  49. data/lib/libui_paradise/libui_classes/button.rb +82 -0
  50. data/lib/libui_paradise/libui_classes/checkbox.rb +37 -0
  51. data/lib/libui_paradise/libui_classes/color_button.rb +44 -0
  52. data/lib/libui_paradise/libui_classes/combobox.rb +55 -0
  53. data/lib/libui_paradise/libui_classes/editable_combobox.rb +51 -0
  54. data/lib/libui_paradise/libui_classes/entry.rb +80 -0
  55. data/lib/libui_paradise/libui_classes/font.rb +78 -0
  56. data/lib/libui_paradise/libui_classes/font_button.rb +40 -0
  57. data/lib/libui_paradise/libui_classes/grid.rb +55 -0
  58. data/lib/libui_paradise/libui_classes/hbox.rb +98 -0
  59. data/lib/libui_paradise/libui_classes/horizontal_separator.rb +41 -0
  60. data/lib/libui_paradise/libui_classes/image.rb +82 -0
  61. data/lib/libui_paradise/libui_classes/label.rb +83 -0
  62. data/lib/libui_paradise/libui_classes/menu.rb +36 -0
  63. data/lib/libui_paradise/libui_classes/msg_box.rb +97 -0
  64. data/lib/libui_paradise/libui_classes/msg_box_error.rb +49 -0
  65. data/lib/libui_paradise/libui_classes/multiline_entry.rb +59 -0
  66. data/lib/libui_paradise/libui_classes/non_wrapping_multiline_entry.rb +41 -0
  67. data/lib/libui_paradise/libui_classes/open_file.rb +42 -0
  68. data/lib/libui_paradise/libui_classes/password_entry.rb +49 -0
  69. data/lib/libui_paradise/libui_classes/progressbar.rb +41 -0
  70. data/lib/libui_paradise/libui_classes/radio_buttons.rb +36 -0
  71. data/lib/libui_paradise/libui_classes/scrolling_area.rb +85 -0
  72. data/lib/libui_paradise/libui_classes/search_entry.rb +36 -0
  73. data/lib/libui_paradise/libui_classes/spinbox.rb +55 -0
  74. data/lib/libui_paradise/libui_classes/tab.rb +39 -0
  75. data/lib/libui_paradise/libui_classes/table.rb +45 -0
  76. data/lib/libui_paradise/libui_classes/text_layout.rb +42 -0
  77. data/lib/libui_paradise/libui_classes/vbox.rb +51 -0
  78. data/lib/libui_paradise/libui_classes/window.rb +167 -0
  79. data/lib/libui_paradise/project/project.rb +26 -0
  80. data/lib/libui_paradise/prototype/README.md +3 -0
  81. data/lib/libui_paradise/prototype/prototype.rb +101 -0
  82. data/lib/libui_paradise/requires/require_the_libui_classes.rb +26 -0
  83. data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +11 -0
  84. data/lib/libui_paradise/version/version.rb +17 -0
  85. data/lib/libui_paradise.rb +1 -0
  86. data/libui_paradise.gemspec +49 -0
  87. metadata +164 -0
@@ -0,0 +1,841 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Fiddle::Pointer
6
+ #
7
+ # Modify Fiddle::Pointer - but this is super-specific to Libui, so it
8
+ # is really not recommended to do this.
9
+ #
10
+ # A cleaner solution would be to modify just in-place, such as via
11
+ # refinements, but I don't like the syntax of refinements really,
12
+ # so I opted for the simpler toplevel modification instead.
13
+ # =========================================================================== #
14
+ # require 'libui_paradise/fiddle/pointer.rb'
15
+ # =========================================================================== #
16
+ module Fiddle
17
+
18
+ class Pointer # === Fiddle::Pointer
19
+
20
+ # ========================================================================= #
21
+ # === append_text_column
22
+ #
23
+ # This method is specifically used for libui-tables.
24
+ # ========================================================================= #
25
+ def append_text_column(text, a, b)
26
+ object_id = self.object_id
27
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
28
+ type = hash[object_id].last # The last entry contains the type.
29
+ case type
30
+ # ======================================================================= #
31
+ # === :button
32
+ # ======================================================================= #
33
+ when :table
34
+ LibUI.table_append_text_column(self, text, a, b)
35
+ else
36
+ e 'Not registered type in .append_text_column(): '+type.to_s
37
+ end
38
+ end
39
+
40
+ # ========================================================================= #
41
+ # === padded=
42
+ #
43
+ # Set a uniform padding via this method.
44
+ # ========================================================================= #
45
+ def padded=(
46
+ pad_n_px = 25,
47
+ type = nil
48
+ )
49
+ object_id = self.object_id
50
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
51
+ if type.nil?
52
+ # ===================================================================== #
53
+ # In this case we must determine the type in use.
54
+ # ===================================================================== #
55
+ if hash.has_key? object_id
56
+ type = hash[object_id].last # The last entry contains the type.
57
+ end
58
+ end
59
+ case type
60
+ # ======================================================================= #
61
+ # === :button
62
+ #
63
+ # This entry point probably does not work, so don't use it.
64
+ # ======================================================================= #
65
+ when :button
66
+ UI.box_set_padded(self, pad_n_px)
67
+ # ======================================================================= #
68
+ # === :vbox
69
+ # ======================================================================= #
70
+ when :vbox,
71
+ :hbox
72
+ UI.box_set_padded(self, pad_n_px)
73
+ # ======================================================================= #
74
+ # === :grid
75
+ # ======================================================================= #
76
+ when :grid
77
+ UI.grid_set_padded(self, pad_n_px) # This line should be changed at a later time.
78
+ # ======================================================================= #
79
+ # === :entry
80
+ # ======================================================================= #
81
+ when :entry
82
+ # ===================================================================== #
83
+ # This method does not seem to exist. We'll leave this here for the
84
+ # time being.
85
+ # ===================================================================== #
86
+ # UI.entry_set_padded(self, pad_n_px) # This line should be changed at a later time.
87
+ else
88
+ pp caller()
89
+ puts "#{type} (class #{type.class}) is not yet implemented in .padded=."
90
+ end
91
+ end; alias set_padded padded= # === set_padded
92
+
93
+ # ========================================================================= #
94
+ # === disable (disable tag)
95
+ # ========================================================================= #
96
+ def disable(&block)
97
+ object_id = self.object_id
98
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
99
+ type = hash[object_id].last # The last entry contains the type.
100
+ case type
101
+ # ======================================================================= #
102
+ # === :button
103
+ # ======================================================================= #
104
+ when :button
105
+ LibUI.control_disable(self)
106
+ else
107
+ e 'Not registered type in .on_changed(): '+type.to_s
108
+ end
109
+ end
110
+
111
+ # ========================================================================= #
112
+ # === enable (enable tag)
113
+ # ========================================================================= #
114
+ def enable(&block)
115
+ object_id = self.object_id
116
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
117
+ type = hash[object_id].last # The last entry contains the type.
118
+ case type
119
+ # ======================================================================= #
120
+ # === :button
121
+ # ======================================================================= #
122
+ when :button
123
+ LibUI.control_enable(self)
124
+ else
125
+ e 'Not registered type in .on_changed(): '+type.to_s
126
+ end
127
+ end
128
+
129
+ # ========================================================================= #
130
+ # === append (append tag, add tag)
131
+ #
132
+ # This is simply a wrapper over UI.box_append().
133
+ # ========================================================================= #
134
+ def append(
135
+ this_widget,
136
+ padding_to_use = 1
137
+ )
138
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
139
+ _pointer = current_widget.first # Not used currently in this method.
140
+ type = current_widget.last
141
+ case type
142
+ # ======================================================================= #
143
+ # === :tab
144
+ #
145
+ # This is specifically for the notebook-tab. In this case the argument
146
+ # names do not make a lot of sense. For instance, this_widget is
147
+ # actually the text-title for the tab, and padding_to_use is the
148
+ # actual widget that will be embedded. Because this is, however had,
149
+ # the "minor use case", compared to the subsequent "else" clause, I
150
+ # will keep the name as-is. The comment here should be kept, in order
151
+ # to explain this peculiar oddity though.
152
+ # ======================================================================= #
153
+ when :tab
154
+ UI.tab_append(self, this_widget.to_s, padding_to_use)
155
+ # ======================================================================= #
156
+ # === :window
157
+ #
158
+ # Add support for the toplevel window here, as of September 2021.
159
+ # ======================================================================= #
160
+ when :window
161
+ UI.window_set_child(self, this_widget)
162
+ else # This is the default.
163
+ UI.box_append(
164
+ self, this_widget, padding_to_use
165
+ )
166
+ end
167
+ end; alias add append # === add
168
+ alias << append # === <<
169
+
170
+ # ========================================================================= #
171
+ # === on_changed
172
+ #
173
+ # The idea for this method is to respond to on-changed events, in
174
+ # particular on a spinbox. Currently it is enabled only for :entry
175
+ # widgets. This may have to be expanded one day to add more widgets.
176
+ #
177
+ # For a combobox we may have to use this code:
178
+ #
179
+ # LibUI.combobox_on_selected
180
+ # UI.spinbox_on_changed(self, spinbox_changed_callback, nil)
181
+ # end
182
+ #
183
+ # Be sure to pass the proc object into the method, in a block.
184
+ #
185
+ # Usage example:
186
+ #
187
+ # text_entry.on_changed { text_changed_callback }
188
+ #
189
+ # ========================================================================= #
190
+ def on_changed(&block)
191
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
192
+ _pointer = current_widget.first # Not used currently in this method.
193
+ type = current_widget.last
194
+ case type
195
+ # ======================================================================= #
196
+ # === :colour_button
197
+ # ======================================================================= #
198
+ when :colour_button
199
+ LibUI.color_button_on_changed(self, block.call, nil)
200
+ # ======================================================================= #
201
+ # === :entry
202
+ # ======================================================================= #
203
+ when :entry
204
+ LibUI.entry_on_changed(self, block.call, nil)
205
+ else
206
+ e 'Not registered type in .on_changed(): '+type.to_s
207
+ end
208
+ end
209
+
210
+ # ========================================================================= #
211
+ # === set_text
212
+ # ========================================================================= #
213
+ def set_text(
214
+ display_this_text = '', # This is the text that will be used.
215
+ type = nil
216
+ )
217
+ object_id = self.object_id
218
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
219
+ this_widget = hash[object_id].first
220
+ if type.nil?
221
+ type = hash[object_id].last # This should be :grid. But it is not used here.
222
+ end
223
+ case type
224
+ # ======================================================================= #
225
+ # === :multiline_entry
226
+ #
227
+ # This is a text-view widget actually.
228
+ # ======================================================================= #
229
+ when :multiline_entry
230
+ UI.multiline_entry_set_text(
231
+ this_widget,
232
+ display_this_text.to_s
233
+ )
234
+ # ======================================================================= #
235
+ # === :text
236
+ # ======================================================================= #
237
+ when :text,
238
+ :label
239
+ UI.label_set_text(
240
+ this_widget,
241
+ display_this_text.to_s
242
+ )
243
+ # ======================================================================= #
244
+ # === :textview
245
+ # ======================================================================= #
246
+ when :textview
247
+ UI.multiline_entry_set_text(
248
+ this_widget,
249
+ display_this_text.to_s
250
+ )
251
+ # ======================================================================= #
252
+ # === :entry
253
+ # ======================================================================= #
254
+ when :entry
255
+ UI.entry_set_text(
256
+ this_widget,
257
+ display_this_text.to_s
258
+ )
259
+ # else; puts 'Unhandled case so far: '+type.to_s
260
+ end
261
+ end; alias set_content set_text # === set_content
262
+
263
+ # ========================================================================= #
264
+ # === text?
265
+ # ========================================================================= #
266
+ def text?(
267
+ type = nil
268
+ )
269
+ object_id = self.object_id
270
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
271
+ if type.nil?
272
+ # ===================================================================== #
273
+ # In this case we must determine the type in use.
274
+ # ===================================================================== #
275
+ if hash.has_key? object_id
276
+ type = hash[object_id].last # The last entry contains the type.
277
+ end
278
+ end
279
+ case type
280
+ # ======================================================================= #
281
+ # === :textview
282
+ # ======================================================================= #
283
+ when :textview
284
+ return UI.multiline_entry_text(self).to_s
285
+ # ======================================================================= #
286
+ # === :combobox
287
+ # ======================================================================= #
288
+ when :combobox
289
+ return UI.combobox_selected(self).to_s
290
+ else # This is the "historic" default. May have to be removed one day.
291
+ return UI.entry_text(self).to_s
292
+ end
293
+ end; alias buffer? text? # === buffer?
294
+ alias selected? text? # === selected?
295
+
296
+ # ========================================================================= #
297
+ # === @left_counter
298
+ # ========================================================================= #
299
+ @left_counter = 0
300
+
301
+ # ========================================================================= #
302
+ # === Fiddle::Pointer.reset_the_left_counter
303
+ # ========================================================================= #
304
+ def self.reset_the_left_counter
305
+ @left_counter = 0
306
+ end
307
+
308
+ # ========================================================================= #
309
+ # === Fiddle::Pointer.increment_the_left_counter
310
+ # ========================================================================= #
311
+ def self.increment_the_left_counter
312
+ @left_counter += 1
313
+ end
314
+
315
+ # ========================================================================= #
316
+ # === Fiddle::Pointer.left_counter?
317
+ # ========================================================================= #
318
+ def self.left_counter?
319
+ @left_counter
320
+ end
321
+
322
+ # ========================================================================= #
323
+ # === @top_counter
324
+ # ========================================================================= #
325
+ @top_counter = 0
326
+
327
+ # ========================================================================= #
328
+ # === Fiddle::Pointer.increment_the_top_counter
329
+ # ========================================================================= #
330
+ def self.increment_the_top_counter
331
+ @top_counter += 1
332
+ end
333
+
334
+ # ========================================================================= #
335
+ # === Fiddle::Pointer.top_counter?
336
+ # ========================================================================= #
337
+ def self.top_counter?
338
+ @top_counter
339
+ end
340
+
341
+ # ========================================================================= #
342
+ # === right (right tag)
343
+ # ========================================================================= #
344
+ def right(
345
+ widget,
346
+ left = Fiddle::Pointer.left_counter?,
347
+ top = Fiddle::Pointer.top_counter?,
348
+ xspan = 1,
349
+ yspan = 1
350
+ )
351
+ object_id = self.object_id
352
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
353
+ type = hash[object_id].last # The last entry contains the type.
354
+ case type
355
+ # ======================================================================= #
356
+ # === :vbox
357
+ # ======================================================================= #
358
+ when :vbox
359
+ self.add(widget)
360
+ # ======================================================================= #
361
+ # === :grid
362
+ # ======================================================================= #
363
+ when :grid
364
+ self.ui_grid_append(
365
+ widget,
366
+ left, # left
367
+ top, # top
368
+ xspan,
369
+ yspan
370
+ )
371
+ Fiddle::Pointer.reset_the_left_counter
372
+ Fiddle::Pointer.increment_the_top_counter
373
+ else
374
+ end
375
+ end
376
+
377
+ # ========================================================================= #
378
+ # === left (left tag)
379
+ # ========================================================================= #
380
+ def left(
381
+ widget,
382
+ left = Fiddle::Pointer.left_counter?,
383
+ top = Fiddle::Pointer.top_counter?,
384
+ xspan = 1,
385
+ yspan = 1
386
+ )
387
+ object_id = self.object_id
388
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
389
+ type = hash[object_id].last # The last entry contains the type.
390
+ case type
391
+ # ======================================================================= #
392
+ # === :vbox
393
+ # ======================================================================= #
394
+ when :vbox
395
+ self.add(widget)
396
+ # ======================================================================= #
397
+ # === :grid
398
+ # ======================================================================= #
399
+ when :grid
400
+ self.ui_grid_append(
401
+ widget,
402
+ self,
403
+ left, # left
404
+ top, # top
405
+ xspan,
406
+ yspan
407
+ )
408
+ Fiddle::Pointer.increment_the_left_counter
409
+ else
410
+ end
411
+ end
412
+
413
+ # ========================================================================= #
414
+ # === ui_grid_append
415
+ #
416
+ # This method can be used to append onto a grid in LibUI.
417
+ #
418
+ # Usage example:
419
+ #
420
+ # grid.grid_append(text('Right'), 1, 0, 1, 1, 0, 0.5, 1, 0)
421
+ #
422
+ # ========================================================================= #
423
+ def ui_grid_append(
424
+ widget_to_append,
425
+ left = 0,
426
+ top = 0,
427
+ xspan = 1,
428
+ yspan = 1, #
429
+ hexpand = false, # A "boolean".
430
+ halign = 0,
431
+ vexpand = false, # A "boolean".
432
+ valign = 0
433
+ )
434
+ # ======================================================================= #
435
+ # The signature in Go is:
436
+ #
437
+ # Append(child Control, left, top int, xspan, yspan int, hexpand bool, halign Align, vexpand bool, valign Align)
438
+ #
439
+ # ======================================================================= #
440
+ object_id = self.object_id
441
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
442
+ this_widget = hash[object_id].first
443
+ _type = hash[object_id].last # This should be :grid. But it is not used here.
444
+ # ======================================================================= #
445
+ # left, top, xspan, yspan, hexpand, halign, vexpand, valign
446
+ # 0, 0, 2, 1, 0, 0, 1, 0
447
+ # ======================================================================= #
448
+ UI.grid_append(
449
+ this_widget,
450
+ widget_to_append,
451
+ left,
452
+ top,
453
+ xspan,
454
+ yspan,
455
+ hexpand,
456
+ halign,
457
+ vexpand,
458
+ valign
459
+ )
460
+ end; alias grid_append ui_grid_append # === grid_append
461
+
462
+ # ========================================================================= #
463
+ # === populate
464
+ # ========================================================================= #
465
+ def populate(dataset)
466
+ object_id = self.object_id
467
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
468
+ type = hash[object_id].last
469
+ case type
470
+ # ======================================================================= #
471
+ # === :combobox
472
+ # ======================================================================= #
473
+ when :combobox
474
+ self.append_this_array(dataset)
475
+ end
476
+ end
477
+
478
+ # ========================================================================= #
479
+ # === is_padded
480
+ # ========================================================================= #
481
+ def is_padded
482
+ set_padded(1)
483
+ end
484
+
485
+ # ========================================================================= #
486
+ # === main_then_quit
487
+ # ========================================================================= #
488
+ def main_then_quit
489
+ UI.main
490
+ UI.quit
491
+ end
492
+
493
+ # ========================================================================= #
494
+ # === show_then_main_then_quit
495
+ #
496
+ # This method ultimately combines three other method calls.
497
+ # ========================================================================= #
498
+ def show_then_main_then_quit
499
+ UI.control_show(self)
500
+ main_then_quit
501
+ end; alias elegant_exit show_then_main_then_quit # === elegant_exit
502
+ alias complex_finalizer show_then_main_then_quit # === complex_finalizer
503
+ alias intelligent_close_down show_then_main_then_quit # === intelligent_close_down
504
+ alias intelligent_quit show_then_main_then_quit # === intelligent_quit
505
+ alias intelligent_exit show_then_main_then_quit # === intelligent_exit
506
+
507
+ # ========================================================================= #
508
+ # === on_clicked
509
+ #
510
+ # This method is in general called on a button-widget.
511
+ # ========================================================================= #
512
+ def on_clicked(&block)
513
+ UI.button_on_clicked(self, &block)
514
+ end; alias on_click_event on_clicked # === on_click_event
515
+
516
+ # ========================================================================= #
517
+ # === on_key_press_event
518
+ # ========================================================================= #
519
+ def on_key_press_event(&block)
520
+ e 'NOT YET IMPLEMENTED.'
521
+ end
522
+
523
+ # ========================================================================= #
524
+ # === on_button_press_event
525
+ # ========================================================================= #
526
+ def on_button_press_event(&block)
527
+ e 'NOT YET IMPLEMENTED'
528
+ end
529
+
530
+ # ========================================================================= #
531
+ # === available_pointers?
532
+ # ========================================================================= #
533
+ def available_pointers?
534
+ LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
535
+ end; alias main_hash? available_pointers? # === main_hash?
536
+
537
+ # ========================================================================= #
538
+ # === set_value
539
+ #
540
+ # This method has initially been created to assign a value to a
541
+ # spinbutton. That way the following API is made possible:
542
+ #
543
+ # spinbutton.set_value(42)
544
+ #
545
+ # ========================================================================= #
546
+ def set_value(
547
+ new_value
548
+ )
549
+ object_id = self.object_id
550
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
551
+ this_widget = hash[object_id].first
552
+ type = hash[object_id].last
553
+ case type
554
+ # ======================================================================= #
555
+ # === :spinbox
556
+ # ======================================================================= #
557
+ when :spinbox
558
+ UI.spinbox_set_value(
559
+ this_widget,
560
+ new_value.to_i # Must be an Integer.
561
+ )
562
+ else
563
+ e 'Not registered type: '+type.to_s
564
+ end
565
+ end; alias value= set_value # === value=
566
+
567
+ # ========================================================================= #
568
+ # === append_this_array
569
+ # ========================================================================= #
570
+ def append_this_array(array)
571
+ object_id = self.object_id
572
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
573
+ _this_widget = hash[object_id].first # This variable is currently not in use.
574
+ type = hash[object_id].last
575
+ case type
576
+ # ======================================================================= #
577
+ # === :combobox
578
+ # ======================================================================= #
579
+ when :combobox
580
+ array.each {|this_entry|
581
+ UI.combobox_append(self, this_entry)
582
+ }
583
+ UI.combobox_set_selected(self, 0) # The first one will be active too.
584
+ end
585
+ end
586
+
587
+ # ========================================================================= #
588
+ # === maximal
589
+ # ========================================================================= #
590
+ def maximal(this_widget, optional_padding = 1)
591
+ add(this_widget, optional_padding)
592
+ end
593
+
594
+ # ========================================================================= #
595
+ # === minimal
596
+ # ========================================================================= #
597
+ def minimal(this_widget, optional_padding = 0)
598
+ add(this_widget, optional_padding)
599
+ end
600
+
601
+ # ========================================================================= #
602
+ # === text
603
+ #
604
+ # This ad-hoc method can be used to write text onto a widget.
605
+ #
606
+ # Usage example:
607
+ #
608
+ # outer_vbox.text(
609
+ # 'This widget can be used to modify the ID3 tags '\
610
+ # 'of .mp3 files. The taglib-ruby gem is required for this functionality.'
611
+ # )
612
+ #
613
+ # ========================================================================= #
614
+ def text(
615
+ i = '',
616
+ padding_to_use = 0
617
+ )
618
+ i = i.to_s # Let's ensure we have a String past this point.
619
+ object_id = self.object_id
620
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
621
+ _this_widget = hash[object_id].first # This variable is currently not in use.
622
+ type = hash[object_id].last
623
+ case type
624
+ # ======================================================================= #
625
+ # === :vbox
626
+ # ======================================================================= #
627
+ when :vbox,
628
+ :hbox
629
+ _ = ui_text(i)
630
+ self.add(_, padding_to_use)
631
+ end
632
+ end; alias add_text text # === text
633
+
634
+ # ========================================================================= #
635
+ # === add_hsep
636
+ #
637
+ # This method adds a horizontal separator.
638
+ # ========================================================================= #
639
+ def add_hsep
640
+ object_id = self.object_id
641
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
642
+ this_widget = hash[object_id].first
643
+ this_widget.add(::LibuiParadise::Extensions.horizontal_separator, 0)
644
+ end; alias add_horizontal_separator add_hsep # === add_horizontal_separator
645
+
646
+ # ========================================================================= #
647
+ # === active?
648
+ # ========================================================================= #
649
+ def active?
650
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
651
+ pointer = current_widget.first
652
+ type = current_widget.last
653
+ case type
654
+ # ======================================================================= #
655
+ # === :checkbox
656
+ # ======================================================================= #
657
+ when :checkbox
658
+ checked = (UI.checkbox_checked(pointer) == 1)
659
+ return (checked == true)
660
+ # ======================================================================= #
661
+ # === :entry
662
+ #
663
+ # This is unhandled.
664
+ # ======================================================================= #
665
+ when :entry
666
+ e 'An entry can not be "active". Check the code - there may '\
667
+ 'an erroneous assumption if the method .active? is called.'
668
+ end
669
+ end; alias is_active? active? # === is_active?
670
+
671
+ # ========================================================================= #
672
+ # === set_active
673
+ # ========================================================================= #
674
+ def set_active
675
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
676
+ pointer = current_widget.first
677
+ type = current_widget.last
678
+ case type
679
+ # ======================================================================= #
680
+ # === :checkbox
681
+ # ======================================================================= #
682
+ when :checkbox
683
+ UI.checkbox_set_checked(pointer, 1)
684
+ end
685
+ end; alias is_active set_active # === is_active
686
+ alias is_now_active set_active # === is_now_active
687
+
688
+ # ========================================================================= #
689
+ # === set_inactive
690
+ # ========================================================================= #
691
+ def set_inactive
692
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
693
+ pointer = current_widget.first
694
+ type = current_widget.last
695
+ case type
696
+ # ======================================================================= #
697
+ # === :checkbox
698
+ # ======================================================================= #
699
+ when :checkbox
700
+ UI.checkbox_set_checked(pointer, 0)
701
+ end
702
+ end; alias is_inactive set_inactive # === is_inactive
703
+ alias is_now_inactive set_inactive # === is_now_inactive
704
+
705
+ # ========================================================================= #
706
+ # === child
707
+ #
708
+ # This method should only be called on a LibUI-Window.
709
+ # ========================================================================= #
710
+ def child(child_widget)
711
+ UI.window_set_child(self, child_widget)
712
+ end; alias children= child # === children=
713
+ alias child= child # === child=
714
+
715
+ # ========================================================================= #
716
+ # === show_the_controls
717
+ # ========================================================================= #
718
+ def show_the_controls
719
+ UI.control_show(self)
720
+ end; alias control_show show_the_controls # === control_show
721
+
722
+ # ========================================================================= #
723
+ # === close_properly
724
+ #
725
+ # This can be invoked via, for instance:
726
+ #
727
+ # main_window.simple_exit
728
+ #
729
+ # ========================================================================= #
730
+ def close_properly
731
+ UI.window_on_closing(self) {
732
+ UI.exit_from(self)
733
+ }
734
+ end; alias simple_exit close_properly # === simple_exit
735
+ alias sane_exit close_properly # === sane_exit
736
+ alias should_quit close_properly # === should_quit
737
+
738
+ # ========================================================================= #
739
+ # === is_margined (margin tag, margined tag)
740
+ #
741
+ # For now this only works on @main_window.
742
+ # ========================================================================= #
743
+ def is_margined(
744
+ i = LibuiParadise::Extensions.main_window?
745
+ )
746
+ id = self.object_id
747
+ hash = main_hash?
748
+ if hash.has_key? id
749
+ _ = hash[id]
750
+ type = _.last
751
+ case type
752
+ # ===================================================================== #
753
+ # === :window
754
+ # ===================================================================== #
755
+ when :window
756
+ UI.window_set_margined(_.first, 1)
757
+ else
758
+ e 'The type '+type.to_s+' in is_margined() is currently not supported.'
759
+ end
760
+ else
761
+ e
762
+ e '-'*80
763
+ e 'An unhandled situation has been created:'
764
+ e
765
+ e ' No available key in is_margined() for id: '+id.to_s
766
+ e
767
+ e '-'*80
768
+ e
769
+ end
770
+ end; alias uses_a_margin is_margined # === uses_a_margin
771
+ alias has_margin is_margined # === has_margin
772
+
773
+ # ========================================================================= #
774
+ # Skeleton methods:
775
+ #
776
+ # A "skeleton" method is one that doesn't do anything right now. These
777
+ # were added to increase compatibility with the gtk_paradise gem. Some
778
+ # of these skeleton methods may become real methods one day, depending
779
+ # on how sophisticated the libui code will be - but until then we will
780
+ # simply use different options on different toolkits.
781
+ # ========================================================================= #
782
+ def bblack1; end
783
+ def bblack2; end
784
+ def bblack3; end
785
+ def try_to_add_default_CSS_rules; end
786
+ def enable_free_form_css; end
787
+ def show_all; end # This one here may become a real method one day, but right now I don't know how to enable that.
788
+ def align_to_the_left; end
789
+ def pad1px; end
790
+ def pad2px; end
791
+ def pad3px; end
792
+ def pad4px; end
793
+ def pad5px; end
794
+ def pad6px; end
795
+ def pad7px; end
796
+ def pad8px; end
797
+ def pad9px; end
798
+ def pad10px; end
799
+ def yellow_background; end
800
+ def try_to_use_this_font(i = nil); end
801
+ alias use_this_font= try_to_use_this_font
802
+ def hint=(i = nil); end
803
+ alias popup_hint hint= # === popup_hint
804
+ def modify_background(a = :active, b = :coral); end
805
+ def set_focus(true_or_false = true); end
806
+ def clear_background; end
807
+ def position=(i = 10); end
808
+ def reset_the_internal_variables; end
809
+ def editable=(true_or_false = false); end
810
+ def set_max_length(n = 100); end
811
+ def use_gtk_paradise_project_css_file; end
812
+ def append_project_CSS_file; end
813
+ def infer_the_size_automatically; end
814
+ def set_column_spacing(i = 1); end
815
+ def set_row_spacing(i = 1); end
816
+ def css_class(i = ''); end
817
+ def set_border_width(i = 2); end
818
+ def set_colour(i = 'blue'); end
819
+ def make_bold; end
820
+ def set_name(i = ''); end
821
+ def do_use_underline; end
822
+ def lightblue; end
823
+ def set_font(i = ''); end
824
+ def do_markify; end
825
+ def default=(i = ''); end
826
+ def on_click_select_all; end
827
+ def do_center; end
828
+ def on_hover(i = ''); end
829
+ def lightgreen; end
830
+ def set_background_colour(i = ''); end
831
+ def set_size_request(a = 42, b = 42); end
832
+ def the_first_entry_is_active; end
833
+ def clear_old_datapoints; end
834
+ def very_light_yellow_background; end
835
+ def width_height(a = 500, b = 500); end
836
+ def row_spacing=(i = 10); end
837
+ def line_spacing=(i = 10); end
838
+ def to_the_left; end
839
+ def set_editable(i = true); end
840
+
841
+ end; end