libguib 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/install-pkg.rb +1042 -0
- data/install.rb +4 -0
- data/lgpl.txt +515 -0
- data/lib/libGUIb14.rb +1617 -0
- data/lib/libGUIb16.rb +1613 -0
- data/libguib.gemspec +23 -0
- data/readme.txt +14 -0
- data/src/Container.rb +103 -0
- data/src/FileSelector.rb +43 -0
- data/src/FileSelector.rbin +0 -0
- data/src/PathSelector-extension.rb +37 -0
- data/src/PathSelector.rb +62 -0
- data/src/PathSelector.rbin +0 -0
- data/src/__FX__.rb +17 -0
- data/src/_guib_FileSelector.rb +60 -0
- data/src/app.rb +21 -0
- data/src/dcwindow.rb +88 -0
- data/src/event_listener.rb +59 -0
- data/src/fox_classes.rb +22 -0
- data/src/fxbase.rb +855 -0
- data/src/fxobjects.rb +253 -0
- data/src/icon_not_found.png +0 -0
- data/src/main-window.rb +1 -0
- data/src/make.rb +196 -0
- data/src/middle-right-mouse.rb +51 -0
- data/src/radio_group.rb +46 -0
- data/src/radio_matrix.rb +95 -0
- data/src/relative-path.rb +14 -0
- data/src/style.rb +116 -0
- data/src/table.rb +84 -0
- data.tar.gz.sig +0 -0
- metadata +147 -0
- metadata.gz.sig +0 -0
data/src/fxbase.rb
ADDED
@@ -0,0 +1,855 @@
|
|
1
|
+
# Copyright (c) 2004-2006 by Henon (meinrad dot recheis at gmail dot com)
|
2
|
+
|
3
|
+
# Description: an adapter that simplifies the fox api
|
4
|
+
# reading this file gives you the information what widgets are currently implemented
|
5
|
+
|
6
|
+
# ~ if __FILE__==$0
|
7
|
+
# ~ require "fox14"
|
8
|
+
# ~ end
|
9
|
+
|
10
|
+
require "middle-right-mouse"
|
11
|
+
require "fxobjects"
|
12
|
+
require "radio_group"
|
13
|
+
|
14
|
+
# workaround for a fxruby 1.4.4 bug
|
15
|
+
if Fox.fxrubyversion == "1.4.4"
|
16
|
+
class Fox::FXMenuCaption
|
17
|
+
def text= text
|
18
|
+
@text = text
|
19
|
+
setText(text)
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :text
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module FX
|
27
|
+
# mixin module definitions
|
28
|
+
module CheckState
|
29
|
+
def state=(x)
|
30
|
+
setCheck(x ? Fox::TRUE : Fox::FALSE)
|
31
|
+
end
|
32
|
+
|
33
|
+
def state
|
34
|
+
((getCheckState == Fox::TRUE) ? true : false)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module RangeAccessor
|
39
|
+
def range= val
|
40
|
+
val = val.last..val.first if val.last < val.first
|
41
|
+
setRange val
|
42
|
+
end
|
43
|
+
|
44
|
+
def range
|
45
|
+
getRange
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module RadioMutexInterface
|
50
|
+
def init_radio_mutex
|
51
|
+
@radioGroup = RadioGroup.new
|
52
|
+
@radioGroup.on_event_selected { |r| event_selected(r) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_radio_option widget
|
56
|
+
@radioGroup << widget
|
57
|
+
end
|
58
|
+
|
59
|
+
def selected_radio
|
60
|
+
@radioGroup.selected
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# class definitions
|
65
|
+
class ArrowButton < Fox::FXArrowButton
|
66
|
+
def initialize(p, opts = 0)
|
67
|
+
super(p, nil, 0, opts | Fox::ARROW_NORMAL)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class Button < Fox::FXButton
|
72
|
+
include Responder
|
73
|
+
include RightBtn
|
74
|
+
include MiddleBtn
|
75
|
+
def initialize(p, opts = 0)
|
76
|
+
super(p, "Button", nil, nil, 0, Fox::BUTTON_NORMAL | opts)
|
77
|
+
handleMMB_Events
|
78
|
+
handleRMB_Events
|
79
|
+
end
|
80
|
+
|
81
|
+
def state=(x)
|
82
|
+
if x == true
|
83
|
+
setState(Fox::STATE_DOWN)
|
84
|
+
elsif x == false
|
85
|
+
setState(Fox::STATE_UP)
|
86
|
+
elsif x.class == Integer
|
87
|
+
setState(x)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def state
|
92
|
+
if getState == Fox::STATE_DOWN then return true
|
93
|
+
elsif getState == Fox::STATE_CHECKED then return true
|
94
|
+
end
|
95
|
+
false
|
96
|
+
end
|
97
|
+
alias_method :buttonButtonStyle=, :buttonStyle=
|
98
|
+
alias_method :buttonButtonStyle, :buttonStyle
|
99
|
+
end
|
100
|
+
# ~ class Calendar < Fox::FXCalendar
|
101
|
+
# ~ def initialize(p, opts=0)
|
102
|
+
# ~ super p, initial_date=Time.now, tgt=nil, sel=0, opts
|
103
|
+
|
104
|
+
# ~ end
|
105
|
+
# ~ end
|
106
|
+
class Canvas < Fox::FXCanvas
|
107
|
+
def initialize(p, opts = 0)
|
108
|
+
super(p)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class CheckButton < Fox::FXCheckButton
|
113
|
+
def initialize(p, opts = 0)
|
114
|
+
super(p, "CheckButton")
|
115
|
+
end
|
116
|
+
include CheckState
|
117
|
+
end
|
118
|
+
|
119
|
+
class ComboBox < Fox::FXComboBox
|
120
|
+
def initialize(p, opts = 0)
|
121
|
+
super(p, 10, nil, 0, opts | Fox::FRAME_SUNKEN)
|
122
|
+
end
|
123
|
+
|
124
|
+
def comboItems= string
|
125
|
+
c = currentItem
|
126
|
+
clearItems
|
127
|
+
array = string.split(/\r?\n/)
|
128
|
+
array.each { |s|
|
129
|
+
appendItem s
|
130
|
+
}
|
131
|
+
self.numVisible = array.size
|
132
|
+
begin
|
133
|
+
self.currentItem = c
|
134
|
+
rescue Exception
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def comboItems
|
139
|
+
array = []
|
140
|
+
each { |text, d|
|
141
|
+
array << text
|
142
|
+
}
|
143
|
+
array.join("\n")
|
144
|
+
end
|
145
|
+
|
146
|
+
def auto_resize
|
147
|
+
size = 0
|
148
|
+
each { |text, d|
|
149
|
+
size = text.size if size < text.size
|
150
|
+
}
|
151
|
+
self.numColumns = size
|
152
|
+
self.numVisible = numItems
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
class Dial < Fox::FXDial
|
157
|
+
def initialize(p, opts = 0)
|
158
|
+
super(p, nil, 0, opts | Fox::DIAL_NORMAL)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
class DialogBox < Fox::FXDialogBox
|
163
|
+
def initialize(p, opts = 0)
|
164
|
+
# @eventListeners=[]
|
165
|
+
super(p, "title", Fox::DECOR_ALL)
|
166
|
+
pad(0, 0, 0, 0)
|
167
|
+
handleMMB_Events
|
168
|
+
end
|
169
|
+
# attr_accessor :eventListeners
|
170
|
+
include Responder
|
171
|
+
include MiddleBtn
|
172
|
+
# ~ def show(*args)
|
173
|
+
# ~ #dbg
|
174
|
+
# ~ @eventListeners.each{|el| el.on_event "DialogBox.show", self }
|
175
|
+
# ~ create if $fxapp.created? and not created?
|
176
|
+
# ~ super
|
177
|
+
# ~ end
|
178
|
+
|
179
|
+
# ~ def hide(*args)
|
180
|
+
# ~ #dbg
|
181
|
+
# ~ @eventListeners.each{|el| el.on_event "DialogBox.hide", self }
|
182
|
+
# ~ super
|
183
|
+
# ~ end
|
184
|
+
|
185
|
+
# ~ def destroy(*args)
|
186
|
+
# ~ #dbg
|
187
|
+
# ~ @eventListeners.each{|el| el.on_event "DialogBox.destroy", self }
|
188
|
+
# ~ super
|
189
|
+
# ~ end
|
190
|
+
end
|
191
|
+
|
192
|
+
class DirBox < Fox::FXDirBox
|
193
|
+
def initialize(p, opts = 0)
|
194
|
+
super(p, nil, 0, opts | Fox::FRAME_SUNKEN | Fox::TREELISTBOX_NORMAL)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
class DirList < Fox::FXDirList
|
199
|
+
def initialize(p, opts = 0)
|
200
|
+
super(p, nil, 0, opts)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
class DriveBox < Fox::FXDriveBox
|
205
|
+
def initialize(p, opts = 0)
|
206
|
+
super(p, nil, 0, opts | Fox::FRAME_SUNKEN | Fox::LISTBOX_NORMAL)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
class FileList < Fox::FXFileList
|
211
|
+
def initialize(p, opts = 0)
|
212
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
class Header < Fox::FXHeader
|
217
|
+
def initialize(p, opts = 0)
|
218
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y | Fox::HEADER_NORMAL)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
class GroupBox < Fox::FXGroupBox
|
223
|
+
def initialize(p, opts = 0)
|
224
|
+
super(p, "GroupBox", opts | Fox::FRAME_GROOVE, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
class HorizontalFrame < Fox::FXHorizontalFrame
|
229
|
+
def initialize(p, opts = 0)
|
230
|
+
super(p, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
class HorizontalSeparator < Fox::FXHorizontalSeparator
|
235
|
+
def initialize(p, opts = Fox::SEPARATOR_GROOVE)
|
236
|
+
super(p, Fox::LAYOUT_FILL_X | opts)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
class IconList < Fox::FXIconList
|
241
|
+
def initialize(p, opts = 0)
|
242
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y | Fox::HEADER_NORMAL)
|
243
|
+
end
|
244
|
+
alias_method :iconListStyle=, :listStyle=
|
245
|
+
alias_method :iconListStyle, :listStyle
|
246
|
+
|
247
|
+
def addItems names, imagefiles
|
248
|
+
names.size.times do |i|
|
249
|
+
img = loadImage(imagefiles[i])
|
250
|
+
appendItem(names[i], nil, img)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
class Label < Fox::FXLabel
|
256
|
+
def initialize(p, opts = 0)
|
257
|
+
super(p, "Label")
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
class List < Fox::FXList
|
262
|
+
def initialize(p, opts = 0)
|
263
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y | Fox::LIST_NORMAL)
|
264
|
+
end
|
265
|
+
alias_method :listListStyle=, :listStyle=
|
266
|
+
alias_method :listListStyle, :listStyle
|
267
|
+
end
|
268
|
+
|
269
|
+
class ListBox < Fox::FXListBox
|
270
|
+
def initialize(p, opts = 0)
|
271
|
+
super(p, nil, 0, opts | Fox::FRAME_SUNKEN | Fox::LISTBOX_NORMAL)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
class MainWindow < Fox::FXMainWindow
|
276
|
+
# accepts app or any widget as parent
|
277
|
+
def initialize(p, opts = 0)
|
278
|
+
p = p.app if p.is_a? Fox::FXId
|
279
|
+
super(p, "MainWindow", nil, nil, Fox::DECOR_ALL)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
class Matrix < Fox::FXMatrix
|
284
|
+
def initialize(p, opts = 0)
|
285
|
+
super(p, 1, opts | Fox::MATRIX_BY_ROWS | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y)
|
286
|
+
@cols = self.numColumns = 1
|
287
|
+
@rows = self.numRows = 1
|
288
|
+
end
|
289
|
+
|
290
|
+
# update the dimension when switching matrix by rows/columns
|
291
|
+
def matrixStyle=code
|
292
|
+
super
|
293
|
+
numColumns = @cols
|
294
|
+
numRows = @rows
|
295
|
+
end
|
296
|
+
|
297
|
+
def numColumns=(int)
|
298
|
+
super(@cols = dim_check(int))
|
299
|
+
end
|
300
|
+
|
301
|
+
def numRows=(int)
|
302
|
+
super(@rows = dim_check(int))
|
303
|
+
end
|
304
|
+
|
305
|
+
def dim_check int
|
306
|
+
# dimension must be a Numeric > 0
|
307
|
+
return 1 if int < 1
|
308
|
+
return 1 unless int.is_a?(Numeric)
|
309
|
+
int
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
class MDIClient < Fox::FXMDIClient
|
314
|
+
def initialize(p, opts = 0)
|
315
|
+
super(p, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
class MenuButton < Fox::FXMenuButton
|
320
|
+
include Responder
|
321
|
+
include MiddleBtn
|
322
|
+
def initialize(p, opts = 0)
|
323
|
+
super(p, "MenuButton", nil, nil, opts | Fox::JUSTIFY_NORMAL | Fox::ICON_BEFORE_TEXT | Fox::MENUBUTTON_DOWN)
|
324
|
+
handleMMB_Events
|
325
|
+
end
|
326
|
+
alias_method :menuButtonStyle=, :buttonStyle=
|
327
|
+
alias_method :menuButtonStyle, :buttonStyle
|
328
|
+
end
|
329
|
+
|
330
|
+
class MenuCaption < Fox::FXMenuCaption
|
331
|
+
include Responder
|
332
|
+
include MiddleBtn
|
333
|
+
def initialize(p, opts = 0)
|
334
|
+
@text = text if Fox.fxrubyversion == "1.4.4"
|
335
|
+
super(p, "MenuCaption")
|
336
|
+
handleMMB_Events
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
class MenuCascade < Fox::FXMenuCascade
|
341
|
+
include Responder
|
342
|
+
include MiddleBtn
|
343
|
+
def initialize(p, text = "MenuCascade")
|
344
|
+
@text = text if Fox.fxrubyversion == "1.4.4"
|
345
|
+
super
|
346
|
+
handleMMB_Events
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
class MenuCheck < Fox::FXMenuCheck
|
351
|
+
include Responder
|
352
|
+
include MiddleBtn
|
353
|
+
include CheckState
|
354
|
+
def initialize(p, text = "MenuCheck")
|
355
|
+
@text = text if Fox.fxrubyversion == "1.4.4"
|
356
|
+
super
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
class MenuCommand < Fox::FXMenuCommand
|
361
|
+
include Responder
|
362
|
+
include MiddleBtn
|
363
|
+
def initialize(p, text = "MenuCommand")
|
364
|
+
@text = text if Fox.fxrubyversion == "1.4.4"
|
365
|
+
super
|
366
|
+
handleMMB_Events
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
class MenuPane < Fox::FXMenuPane
|
371
|
+
include Responder
|
372
|
+
include MiddleBtn
|
373
|
+
include RadioMutexInterface
|
374
|
+
def initialize(p, opts = 0)
|
375
|
+
init_radio_mutex
|
376
|
+
super(p)
|
377
|
+
p.menu = self
|
378
|
+
handleMMB_Events
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
class MenuRadio < Fox::FXMenuRadio
|
383
|
+
include Responder
|
384
|
+
include MiddleBtn
|
385
|
+
include CheckState
|
386
|
+
def initialize(p, text = "MenuRadio")
|
387
|
+
@text = text if Fox.fxrubyversion == "1.4.4"
|
388
|
+
super
|
389
|
+
parent.add_radio_option self if parent.respond_to? :add_radio_option
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
class MenuTitle < Fox::FXMenuTitle
|
394
|
+
include Responder
|
395
|
+
include MiddleBtn
|
396
|
+
def initialize(p, text = "MenuTitle")
|
397
|
+
@text = text if Fox.fxrubyversion == "1.4.4"
|
398
|
+
super
|
399
|
+
handleMMB_Events
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
class MenuBar < Fox::FXMenuBar
|
404
|
+
def initialize(p, opts = 0)
|
405
|
+
super(p, opts | Fox::LAYOUT_FILL_X)
|
406
|
+
handleMMB_Events
|
407
|
+
end
|
408
|
+
include Responder
|
409
|
+
include MiddleBtn
|
410
|
+
end
|
411
|
+
|
412
|
+
class MenuSeparator < Fox::FXMenuSeparator
|
413
|
+
def initialize(p, opts = 0)
|
414
|
+
super
|
415
|
+
handleMMB_Events
|
416
|
+
end
|
417
|
+
include Responder
|
418
|
+
include MiddleBtn
|
419
|
+
end
|
420
|
+
|
421
|
+
class Option < Fox::FXOption
|
422
|
+
def initialize(p, opts = 0)
|
423
|
+
super(p, "Option", nil, nil, 0, opts | Fox::JUSTIFY_NORMAL | Fox::ICON_BEFORE_TEXT)
|
424
|
+
handleMMB_Events
|
425
|
+
end
|
426
|
+
include Responder
|
427
|
+
include MiddleBtn
|
428
|
+
end
|
429
|
+
|
430
|
+
class OptionMenu < Fox::FXOptionMenu
|
431
|
+
def initialize(p, opts = 0)
|
432
|
+
super(p, nil, opts | Fox::JUSTIFY_NORMAL | Fox::ICON_BEFORE_TEXT)
|
433
|
+
handleMMB_Events
|
434
|
+
end
|
435
|
+
include Responder
|
436
|
+
include MiddleBtn
|
437
|
+
# alias :menu= :popup=
|
438
|
+
# alias :menu :popup
|
439
|
+
end
|
440
|
+
|
441
|
+
class Packer < Fox::FXPacker
|
442
|
+
def initialize(p, opts = 0)
|
443
|
+
super(p, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0)
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
class Popup < Fox::FXPopup
|
448
|
+
def initialize(p, opts = 0)
|
449
|
+
init_radio_mutex
|
450
|
+
super(p, opts | Fox::POPUP_VERTICAL | Fox::FRAME_RAISED | Fox::FRAME_THICK)
|
451
|
+
handleMMB_Events
|
452
|
+
end
|
453
|
+
include Responder
|
454
|
+
include MiddleBtn
|
455
|
+
include RadioMutexInterface
|
456
|
+
end
|
457
|
+
|
458
|
+
class ProgressBar < Fox::FXProgressBar
|
459
|
+
def initialize(p, opts = 0)
|
460
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X)
|
461
|
+
self.displayText = Fox::TRUE
|
462
|
+
end
|
463
|
+
|
464
|
+
def displayText=bool
|
465
|
+
@displaysText = bool
|
466
|
+
bool ? showNumber : hideNumber
|
467
|
+
end
|
468
|
+
|
469
|
+
def displayText
|
470
|
+
@displaysText = Fox::FALSE if @displaysText.nil?
|
471
|
+
@displaysText
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
class RadioButton < Fox::FXRadioButton
|
476
|
+
def initialize(p, opts = 0)
|
477
|
+
super(p, "RadioButton", nil, 0, opts | Fox::ICON_BEFORE_TEXT)
|
478
|
+
parent.add_radio_option self if parent.respond_to? :add_radio_option
|
479
|
+
end
|
480
|
+
include CheckState
|
481
|
+
end
|
482
|
+
|
483
|
+
class ScrollArea < Fox::FXScrollArea
|
484
|
+
def initialize(p, opts = 0)
|
485
|
+
super(p)
|
486
|
+
self.layoutHints = Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
class ScrollBar < Fox::FXScrollBar
|
491
|
+
def initialize(p, opts = 0)
|
492
|
+
super(p)
|
493
|
+
end
|
494
|
+
alias_method :contentSize, :range
|
495
|
+
alias_method :contentSize=, :range=
|
496
|
+
end
|
497
|
+
|
498
|
+
class ScrollWindow < Fox::FXScrollWindow
|
499
|
+
def initialize(p, opts = 0)
|
500
|
+
super(p)
|
501
|
+
self.layoutHints = Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
class Shutter < Fox::FXShutter
|
506
|
+
def initialize(p, opts = 0)
|
507
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y | Fox::LAYOUT_TOP | Fox::LAYOUT_LEFT | Fox::FRAME_SUNKEN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
508
|
+
handleMMB_Events
|
509
|
+
end
|
510
|
+
include Responder
|
511
|
+
include MiddleBtn
|
512
|
+
end
|
513
|
+
|
514
|
+
class ShutterItem < Fox::FXShutterItem
|
515
|
+
def initialize(p, opts = 0)
|
516
|
+
super(p, "ShutterItem", nil, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_TOP | Fox::LAYOUT_LEFT, 0, 0, 0, 0, 2, 2, 4, 4, 4, 4)
|
517
|
+
# ~ button.frameStyle=Fox::FRAME_NONE
|
518
|
+
# ~ content.frameStyle=Fox::FRAME_NONE
|
519
|
+
button.padBottom = 3
|
520
|
+
button.padTop = 3
|
521
|
+
button.padLeft = 5
|
522
|
+
button.padRight = 5
|
523
|
+
handleMMB_Events
|
524
|
+
end
|
525
|
+
|
526
|
+
def text=(text)
|
527
|
+
button.text = text
|
528
|
+
end
|
529
|
+
|
530
|
+
def text
|
531
|
+
button.text
|
532
|
+
end
|
533
|
+
include Responder
|
534
|
+
include MiddleBtn
|
535
|
+
end
|
536
|
+
|
537
|
+
class Slider < Fox::FXSlider
|
538
|
+
def initialize(p, opts = 0)
|
539
|
+
super(p, nil, 0, opts | Fox::SLIDER_NORMAL | Fox::LAYOUT_FILL_X)
|
540
|
+
end
|
541
|
+
include RangeAccessor
|
542
|
+
end
|
543
|
+
|
544
|
+
class Spinner < Fox::FXSpinner
|
545
|
+
def initialize(p, opts = 0)
|
546
|
+
super(p, 3, nil, 0, opts | Fox::FRAME_SUNKEN)
|
547
|
+
end
|
548
|
+
include RangeAccessor
|
549
|
+
end
|
550
|
+
|
551
|
+
class Splitter < Fox::FXSplitter
|
552
|
+
def initialize(p, opts = 0)
|
553
|
+
super(p)
|
554
|
+
self.layoutHints = Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
class Switcher < Fox::FXSwitcher
|
559
|
+
def initialize(p, opts = 0)
|
560
|
+
super
|
561
|
+
end
|
562
|
+
|
563
|
+
def current=(*args)
|
564
|
+
super
|
565
|
+
rescue Exception
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
class StatusBar < Fox::FXStatusBar
|
570
|
+
def initialize(p, opts = 0)
|
571
|
+
super(p, opts | Fox::LAYOUT_FILL_X)
|
572
|
+
end
|
573
|
+
end
|
574
|
+
|
575
|
+
class StatusLine < Fox::FXStatusLine
|
576
|
+
def initialize(p, opts = 0)
|
577
|
+
super(p)
|
578
|
+
end
|
579
|
+
end
|
580
|
+
|
581
|
+
module TabBarInterface
|
582
|
+
attr_reader :tabs
|
583
|
+
def create_tab(text = "TabItem")
|
584
|
+
@tabs ||= []
|
585
|
+
TabItem.new(self) { |i|
|
586
|
+
@tabs << i
|
587
|
+
i.text = text
|
588
|
+
}
|
589
|
+
end
|
590
|
+
|
591
|
+
def remove_tab tab
|
592
|
+
@tabs.delete tab
|
593
|
+
removeChild(tab)
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
class TabBar < Fox::FXTabBar
|
598
|
+
include TabBarInterface
|
599
|
+
def initialize(p, opts = 0)
|
600
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X)
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
604
|
+
class TabBook < Fox::FXTabBook
|
605
|
+
include TabBarInterface
|
606
|
+
def initialize(p, opts = 0)
|
607
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y)
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
611
|
+
class TabItem < Fox::FXTabItem
|
612
|
+
def initialize(p, opts = 0)
|
613
|
+
super(p, "TabItem")
|
614
|
+
end
|
615
|
+
|
616
|
+
def index
|
617
|
+
parent.tabs.index(self)
|
618
|
+
end
|
619
|
+
end
|
620
|
+
|
621
|
+
class Text < Fox::FXText
|
622
|
+
def initialize(p, opts = 0)
|
623
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y)
|
624
|
+
text = "Text"
|
625
|
+
end
|
626
|
+
alias_method :textTextStyle=, :textStyle=
|
627
|
+
alias_method :textTextStyle, :textStyle
|
628
|
+
end
|
629
|
+
|
630
|
+
class TextField < Fox::FXTextField
|
631
|
+
def initialize(p, opts = 0)
|
632
|
+
super(p, 10, nil, 0, opts | Fox::FRAME_SUNKEN)
|
633
|
+
text = "TextField"
|
634
|
+
end
|
635
|
+
|
636
|
+
def text=(*args)
|
637
|
+
args.collect! { |a| a.to_s }
|
638
|
+
super
|
639
|
+
end
|
640
|
+
|
641
|
+
alias_method :textFieldTextStyle=, :textStyle=
|
642
|
+
alias_method :textFieldTextStyle, :textStyle
|
643
|
+
end
|
644
|
+
|
645
|
+
class ToggleButton < Fox::FXToggleButton
|
646
|
+
def initialize p, opts = 0
|
647
|
+
super(p, "Toggle", "Button", nil, nil, nil, 0, opts | Fox::TOGGLEBUTTON_KEEPSTATE)
|
648
|
+
end
|
649
|
+
|
650
|
+
def altImg= filename
|
651
|
+
if filename.size > 0
|
652
|
+
setAltIcon loadImage(filename)
|
653
|
+
@alt_icon_filename = filename
|
654
|
+
end
|
655
|
+
end
|
656
|
+
|
657
|
+
def altImg
|
658
|
+
@alt_icon_filename.to_s
|
659
|
+
end
|
660
|
+
end
|
661
|
+
|
662
|
+
class ToolBar < Fox::FXToolBar
|
663
|
+
def initialize(p, opts = 0)
|
664
|
+
super(p, opts | Fox::LAYOUT_FILL_X)
|
665
|
+
end
|
666
|
+
end
|
667
|
+
|
668
|
+
class TreeList < Fox::FXTreeList
|
669
|
+
def initialize(p, opts = 0)
|
670
|
+
super(p, nil, 0, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y)
|
671
|
+
end
|
672
|
+
alias_method :treeListStyle=, :listStyle=
|
673
|
+
alias_method :treeListStyle, :listStyle
|
674
|
+
|
675
|
+
def initialize_language_ids
|
676
|
+
each { |ti|
|
677
|
+
ti.initialize_language_ids
|
678
|
+
}
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
class VerticalFrame < Fox::FXVerticalFrame
|
683
|
+
def initialize(p, opts = 0)
|
684
|
+
super(p, opts | Fox::LAYOUT_FILL_X | Fox::LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
685
|
+
end
|
686
|
+
end
|
687
|
+
|
688
|
+
class VerticalSeparator < Fox::FXVerticalSeparator
|
689
|
+
def initialize(p, opts = Fox::SEPARATOR_GROOVE)
|
690
|
+
super(p, Fox::LAYOUT_FILL_Y | opts)
|
691
|
+
end
|
692
|
+
end
|
693
|
+
|
694
|
+
class WidgetTable < GroupBox
|
695
|
+
def initialize(p, opts = 0)
|
696
|
+
@c = {}
|
697
|
+
@r = []
|
698
|
+
@nc = 0
|
699
|
+
super
|
700
|
+
self.text = ""
|
701
|
+
self.vSpacing = 0
|
702
|
+
self.frameStyle = FRAME_NONE
|
703
|
+
# ~ self.layoutHints=Fox::LAYOUT_FILL_X|Fox::LAYOUT_FILL_Y
|
704
|
+
pad 2, 2, 2, 2
|
705
|
+
end
|
706
|
+
|
707
|
+
def rows
|
708
|
+
@r.size
|
709
|
+
end
|
710
|
+
|
711
|
+
def cols
|
712
|
+
@nc
|
713
|
+
end
|
714
|
+
|
715
|
+
def size=(w, h)
|
716
|
+
# TODO implement
|
717
|
+
end
|
718
|
+
|
719
|
+
def add_col
|
720
|
+
@nc += 1
|
721
|
+
@r.each_with_index { |r, y|
|
722
|
+
VerticalFrame.new(r) { |f|
|
723
|
+
@c[[@nc - 1, y]] = f
|
724
|
+
f.pad 0, 0, 0, 0
|
725
|
+
}
|
726
|
+
}
|
727
|
+
end
|
728
|
+
|
729
|
+
def add_row
|
730
|
+
HorizontalFrame.new(self) { |h|
|
731
|
+
h.frameStyle = FRAME_NONE
|
732
|
+
h.pad 0, 0, 0, 0
|
733
|
+
h.layoutHints = Fox::LAYOUT_FILL_X # |Fox::LAYOUT_FILL_Y
|
734
|
+
@r << h
|
735
|
+
# new row has to have as many cols as other rows
|
736
|
+
@nc.times { |x|
|
737
|
+
VerticalFrame.new(h) { |f|
|
738
|
+
@c[[x, rows - 1]] = f
|
739
|
+
f.pad 0, 0, 0, 0
|
740
|
+
}
|
741
|
+
}
|
742
|
+
}
|
743
|
+
end
|
744
|
+
|
745
|
+
def cell(x, y)
|
746
|
+
# ~ puts [x,y].inspect
|
747
|
+
@c[[x, y]]
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
751
|
+
class RadioMutex < FX::VerticalFrame
|
752
|
+
__sends__ :event_selected
|
753
|
+
def initialize(p)
|
754
|
+
init_radio_mutex
|
755
|
+
super
|
756
|
+
self.layoutHints = 0
|
757
|
+
end
|
758
|
+
include RadioMutexInterface
|
759
|
+
end
|
760
|
+
|
761
|
+
# ~~~~~~~~~~~~~~~~~~~~~~~
|
762
|
+
# the following constant definitions are for backward compatibility
|
763
|
+
# they allow to load old rbins
|
764
|
+
Menubar = MenuBar
|
765
|
+
Toolbar = ToolBar
|
766
|
+
Scrollbar = ScrollBar
|
767
|
+
Statusbar = StatusBar
|
768
|
+
Statusline = StatusLine
|
769
|
+
# ToolbarShell=ToolBarShell
|
770
|
+
# ToolbarGrip=ToolBarGrip
|
771
|
+
# ~~~~~~~~~~~~~~~~~~~~~~~
|
772
|
+
end # module FX
|
773
|
+
|
774
|
+
class Fox::FXId
|
775
|
+
attr_accessor :wdg_name # a user-given name to identify the wdg
|
776
|
+
# overwriting app to return the type FX::App instead of the Fox::FXApp
|
777
|
+
def app
|
778
|
+
$fxapp
|
779
|
+
end
|
780
|
+
end
|
781
|
+
|
782
|
+
class Fox::FXWindow
|
783
|
+
def enabled=bool
|
784
|
+
bool ? enable : disable
|
785
|
+
end
|
786
|
+
alias_method :enabled, :enabled?
|
787
|
+
|
788
|
+
def visible=bool
|
789
|
+
bool ? show : hide
|
790
|
+
end
|
791
|
+
alias_method :visible?, :shown
|
792
|
+
alias_method :visible, :shown
|
793
|
+
|
794
|
+
def pad(*args)
|
795
|
+
args[0] ? self.padLeft = args[0] : nil
|
796
|
+
args[1] ? self.padRight = args[1] : nil
|
797
|
+
args[2] ? self.padTop = args[2] : nil
|
798
|
+
args[3] ? self.padBottom = args[3] : nil
|
799
|
+
end
|
800
|
+
|
801
|
+
def padding
|
802
|
+
[padLeft, padRight, padTop, padBottom]
|
803
|
+
end
|
804
|
+
|
805
|
+
# iterates recursively over all children and executes &block
|
806
|
+
# calls the block also for self
|
807
|
+
def recursive(&block) # {|wdg| ... }
|
808
|
+
if block
|
809
|
+
yield(self)
|
810
|
+
children.each { |child| child.recursive(&block) }
|
811
|
+
end
|
812
|
+
end
|
813
|
+
end
|
814
|
+
|
815
|
+
module ImgAccessors
|
816
|
+
def img= filename
|
817
|
+
raise TypeError unless filename.is_a? String
|
818
|
+
if filename.size > 0
|
819
|
+
setIcon loadImage(filename)
|
820
|
+
@icon_filename = filename
|
821
|
+
end
|
822
|
+
end
|
823
|
+
|
824
|
+
def img
|
825
|
+
@icon_filename.to_s
|
826
|
+
end
|
827
|
+
end
|
828
|
+
|
829
|
+
class Fox::FXLabel
|
830
|
+
include ImgAccessors
|
831
|
+
end
|
832
|
+
|
833
|
+
class Fox::FXMenuCaption
|
834
|
+
include ImgAccessors
|
835
|
+
end
|
836
|
+
|
837
|
+
if __FILE__ == $0
|
838
|
+
$stdout.sync = true
|
839
|
+
c = FX::Color.new 200, 10, 0, 50
|
840
|
+
c.from_s(c.to_s)
|
841
|
+
puts c.inspect
|
842
|
+
c.from_FXColor(c.to_FXColor)
|
843
|
+
puts c.inspect
|
844
|
+
fd = Fox::FXFontDesc.new.to_s
|
845
|
+
app = Fox::FXApp.new "", ""
|
846
|
+
mw = FX::DialogBox.new app
|
847
|
+
check = FX::CheckButton.new mw
|
848
|
+
mw.show(0)
|
849
|
+
check.connect(Fox::SEL_COMMAND) {
|
850
|
+
p check.checked?
|
851
|
+
}
|
852
|
+
check.state = true
|
853
|
+
app.create
|
854
|
+
app.run
|
855
|
+
end
|