fxruby 1.6.5 → 1.6.6
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.
- data/doc/apes02.html +2 -2
- data/doc/apes03.html +1 -1
- data/doc/book.html +1 -1
- data/doc/changes.html +55 -21
- data/doc/differences.html +9 -9
- data/doc/implementation.html +1 -1
- data/doc/library.html +5 -5
- data/doc/opengl.html +5 -5
- data/doc/pt02.html +1 -1
- data/doc/scintilla.html +4 -4
- data/doc/subversion.html +1 -1
- data/examples/accell.rb +36 -0
- data/examples/babelfish.rb +6 -9
- data/examples/bounce.rb +5 -4
- data/examples/button.rb +19 -21
- data/examples/datatarget.rb +9 -8
- data/examples/dctest.rb +7 -13
- data/examples/dialog.rb +12 -16
- data/examples/dilbert.rb +4 -4
- data/examples/dirlist.rb +6 -5
- data/examples/dragdrop.rb +30 -33
- data/examples/dragsource.rb +22 -22
- data/examples/dropsite.rb +16 -17
- data/examples/foursplit.rb +8 -13
- data/examples/gltest.rb +21 -24
- data/examples/glviewer.rb +56 -58
- data/examples/header.rb +25 -25
- data/examples/iconlist.rb +12 -8
- data/examples/image.rb +36 -34
- data/examples/imageviewer.rb +44 -43
- data/examples/inputs.rb +15 -15
- data/examples/mditest.rb +6 -5
- data/examples/pig.rb +1 -0
- data/examples/raabrowser.rb +31 -40
- data/examples/ratio.rb +27 -16
- data/examples/rulerview.rb +4 -3
- data/examples/scribble.rb +14 -17
- data/examples/shutter.rb +10 -9
- data/examples/splitter.rb +7 -6
- data/examples/tabbook.rb +59 -17
- data/examples/table.rb +12 -16
- data/ext/fox16/FXRuby.cpp +2 -2
- data/lib/fox16/glshapes.rb +6 -6
- data/lib/fox16/iterators.rb +13 -8
- data/lib/fox16/kwargs.rb +604 -380
- data/lib/fox16/version.rb +1 -1
- data/tests/TC_FXTreeList.rb +13 -13
- data/tests/TC_FXTreeListBox.rb +3 -3
- metadata +4 -3
data/examples/header.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'fox16'
|
4
|
+
require 'fox16/kwargs'
|
4
5
|
|
5
6
|
include Fox
|
6
7
|
|
@@ -13,7 +14,7 @@ class HeaderWindow < FXMainWindow
|
|
13
14
|
|
14
15
|
def initialize(app)
|
15
16
|
# Invoke base class initializer first
|
16
|
-
super(app, "Header Control Test",
|
17
|
+
super(app, "Header Control Test", :opts => DECOR_ALL, :width => 800, :height => 600)
|
17
18
|
|
18
19
|
# Menu bar stretched along the top of the main window
|
19
20
|
menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
|
@@ -29,34 +30,35 @@ class HeaderWindow < FXMainWindow
|
|
29
30
|
|
30
31
|
# Help menu
|
31
32
|
helpmenu = FXMenuPane.new(self)
|
32
|
-
FXMenuCommand.new(helpmenu, "&About Header...").connect(SEL_COMMAND)
|
33
|
+
FXMenuCommand.new(helpmenu, "&About Header...").connect(SEL_COMMAND) do
|
33
34
|
FXMessageBox.information(self, MBOX_OK, "About Header",
|
34
35
|
"An example of how to work with the header control.")
|
35
|
-
|
36
|
+
end
|
36
37
|
FXMenuTitle.new(menubar, "&Help", nil, helpmenu, LAYOUT_RIGHT)
|
37
38
|
|
38
39
|
# Make Main Window contents
|
39
40
|
contents = FXVerticalFrame.new(self,
|
40
41
|
FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
41
|
-
0,0,
|
42
|
+
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0,
|
43
|
+
:hSpacing => 0, :vSpacing => 0)
|
42
44
|
|
43
45
|
# Make header control
|
44
|
-
@header1 = FXHeader.new(contents,
|
45
|
-
HEADER_BUTTON|HEADER_RESIZE|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X)
|
46
|
-
@header1.connect(SEL_CHANGED)
|
46
|
+
@header1 = FXHeader.new(contents,
|
47
|
+
:opts => HEADER_BUTTON|HEADER_RESIZE|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X)
|
48
|
+
@header1.connect(SEL_CHANGED) do |sender, sel, which|
|
47
49
|
@lists[which].width = @header1.getItemSize(which)
|
48
|
-
|
49
|
-
@header1.connect(SEL_COMMAND)
|
50
|
+
end
|
51
|
+
@header1.connect(SEL_COMMAND) do |sender, sel, which|
|
50
52
|
@lists[which].numItems.times do |i|
|
51
53
|
@lists[which].selectItem(i)
|
52
54
|
end
|
53
|
-
|
55
|
+
end
|
54
56
|
|
55
57
|
# Document icon
|
56
58
|
doc = nil
|
57
|
-
File.open(File.join("icons", "minidoc.png"), "rb")
|
59
|
+
File.open(File.join("icons", "minidoc.png"), "rb") do |f|
|
58
60
|
doc = FXPNGIcon.new(getApp(), f.read)
|
59
|
-
|
61
|
+
end
|
60
62
|
|
61
63
|
@header1.appendItem("Name", doc, 150)
|
62
64
|
@header1.appendItem("Type", nil, 140)
|
@@ -66,18 +68,15 @@ class HeaderWindow < FXMainWindow
|
|
66
68
|
# Below header
|
67
69
|
panes = FXHorizontalFrame.new(contents,
|
68
70
|
FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
69
|
-
0,0,
|
71
|
+
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0,
|
72
|
+
:hSpacing => 0, :vSpacing => 0)
|
70
73
|
|
71
74
|
# Make 4 lists
|
72
75
|
@lists = []
|
73
|
-
@lists.push(FXList.new(panes,
|
74
|
-
|
75
|
-
@lists.push(FXList.new(panes,
|
76
|
-
|
77
|
-
@lists.push(FXList.new(panes, nil, 0,
|
78
|
-
LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_MULTIPLESELECT, 0, 0, 230, 0))
|
79
|
-
@lists.push(FXList.new(panes, nil, 0,
|
80
|
-
LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_EXTENDEDSELECT, 0, 0, 80, 0))
|
76
|
+
@lists.push(FXList.new(panes, :opts => LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_BROWSESELECT, :width => 150))
|
77
|
+
@lists.push(FXList.new(panes, :opts => LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_SINGLESELECT, :width => 140))
|
78
|
+
@lists.push(FXList.new(panes, :opts => LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_MULTIPLESELECT, :width => 230))
|
79
|
+
@lists.push(FXList.new(panes, :opts => LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_EXTENDEDSELECT, :width => 80))
|
81
80
|
|
82
81
|
@lists[0].backColor = FXRGB(255, 240, 240)
|
83
82
|
@lists[1].backColor = FXRGB(240, 255, 240)
|
@@ -113,8 +112,8 @@ class HeaderWindow < FXMainWindow
|
|
113
112
|
@lists[3].appendItem("E")
|
114
113
|
@lists[3].appendItem("F")
|
115
114
|
|
116
|
-
@header2 = FXHeader.new(panes,
|
117
|
-
HEADER_VERTICAL|HEADER_BUTTON|HEADER_RESIZE|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_Y)
|
115
|
+
@header2 = FXHeader.new(panes,
|
116
|
+
:opts => HEADER_VERTICAL|HEADER_BUTTON|HEADER_RESIZE|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_Y)
|
118
117
|
@header2.appendItem("Example", nil, 30)
|
119
118
|
@header2.appendItem("Of", nil, 30)
|
120
119
|
@header2.appendItem("Vertical", nil, 30)
|
@@ -125,10 +124,11 @@ class HeaderWindow < FXMainWindow
|
|
125
124
|
GROUPBOX_TITLE_CENTER|LAYOUT_FILL_X|LAYOUT_FILL_Y)
|
126
125
|
check = FXCheckButton.new(groupie,
|
127
126
|
"Continuous Tracking\tContinuous\tTrack Header continuously",
|
128
|
-
|
127
|
+
:opts => ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
|
128
|
+
check.connect(SEL_COMMAND) do
|
129
129
|
@header1.headerStyle ^= HEADER_TRACKING
|
130
130
|
@header2.headerStyle ^= HEADER_TRACKING
|
131
|
-
|
131
|
+
end
|
132
132
|
|
133
133
|
# Whip out a tooltip control, jeez, that's hard
|
134
134
|
FXToolTip.new(getApp())
|
data/examples/iconlist.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
require 'fox16'
|
2
|
+
require 'fox16/kwargs'
|
2
3
|
|
3
4
|
include Fox
|
4
5
|
|
5
6
|
class IconListWindow < FXMainWindow
|
7
|
+
|
6
8
|
# Load the named PNG icon from a file
|
7
9
|
def loadIcon(filename)
|
8
10
|
begin
|
9
11
|
filename = File.join("icons", filename)
|
10
12
|
icon = nil
|
11
|
-
File.open(filename, "rb")
|
13
|
+
File.open(filename, "rb") do |f|
|
12
14
|
icon = FXPNGIcon.new(getApp(), f.read)
|
13
|
-
|
15
|
+
end
|
14
16
|
icon
|
15
17
|
rescue
|
16
18
|
raise RuntimeError, "Couldn't load icon: #{filename}"
|
@@ -20,7 +22,7 @@ class IconListWindow < FXMainWindow
|
|
20
22
|
# Main window constructor
|
21
23
|
def initialize(app)
|
22
24
|
# Initialize base class first
|
23
|
-
super(app, "Icon List Test",
|
25
|
+
super(app, "Icon List Test", :opts => DECOR_ALL, :width => 800, :height => 600)
|
24
26
|
|
25
27
|
# Menu bar
|
26
28
|
menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
|
@@ -34,14 +36,16 @@ class IconListWindow < FXMainWindow
|
|
34
36
|
status = FXStatusBar.new(self, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|STATUSBAR_WITH_DRAGCORNER)
|
35
37
|
|
36
38
|
# Main window interior
|
37
|
-
group = FXVerticalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
39
|
+
group = FXVerticalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
40
|
+
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0)
|
38
41
|
|
39
42
|
# Files
|
40
43
|
FXLabel.new(group, "Icon List Widget", nil, LAYOUT_TOP|LAYOUT_FILL_X|FRAME_SUNKEN)
|
41
|
-
subgroup = FXVerticalFrame.new(group, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
44
|
+
subgroup = FXVerticalFrame.new(group, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
45
|
+
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0)
|
42
46
|
|
43
47
|
# Icon list on the right
|
44
|
-
iconlist = FXIconList.new(subgroup,
|
48
|
+
iconlist = FXIconList.new(subgroup, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|ICONLIST_BIG_ICONS|ICONLIST_EXTENDEDSELECT)
|
45
49
|
|
46
50
|
iconlist.appendHeader("Name", nil, 200)
|
47
51
|
iconlist.appendHeader("Type", nil, 100)
|
@@ -54,9 +58,9 @@ class IconListWindow < FXMainWindow
|
|
54
58
|
mini_folder = loadIcon("minifolder.png")
|
55
59
|
|
56
60
|
iconlist.appendItem("Really BIG and wide item to test\tDocument\t10000\tJune 13, 1999\tUser\tSoftware", big_folder, mini_folder)
|
57
|
-
1.upto(400)
|
61
|
+
1.upto(400) do |i|
|
58
62
|
iconlist.appendItem("Filename_#{i}\tDocument\t10000\tJune 13, 1999\tUser\tSoftware", big_folder, mini_folder)
|
59
|
-
|
63
|
+
end
|
60
64
|
iconlist.currentItem = iconlist.numItems - 1
|
61
65
|
|
62
66
|
# Arrange menu
|
data/examples/image.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'fox16'
|
4
4
|
require 'fox16/colors'
|
5
|
+
require 'fox16/kwargs'
|
5
6
|
|
6
7
|
include Fox
|
7
8
|
|
@@ -9,34 +10,36 @@ class ImageWindow < FXMainWindow
|
|
9
10
|
|
10
11
|
def initialize(app)
|
11
12
|
# Invoke base class initializer first
|
12
|
-
super(app, "Image Application",
|
13
|
+
super(app, "Image Application", :opts => DECOR_ALL, :width => 800, :height => 600)
|
13
14
|
|
14
15
|
# Create a color dialog for later use
|
15
16
|
colordlg = FXColorDialog.new(self, "Color Dialog")
|
16
17
|
|
17
18
|
contents = FXHorizontalFrame.new(self,
|
18
|
-
LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
19
|
+
LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
20
|
+
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0)
|
19
21
|
|
20
22
|
# LEFT pane to contain the canvas
|
21
23
|
canvasFrame = FXVerticalFrame.new(contents,
|
22
24
|
FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT,
|
23
|
-
|
25
|
+
:padLeft => 10, :padRight => 10, :padTop => 10, :padBottom => 10)
|
24
26
|
|
25
27
|
# Label above the canvas
|
26
|
-
FXLabel.new(canvasFrame, "Canvas Frame",
|
27
|
-
JUSTIFY_CENTER_X|LAYOUT_FILL_X)
|
28
|
+
FXLabel.new(canvasFrame, "Canvas Frame", :opts => JUSTIFY_CENTER_X|LAYOUT_FILL_X)
|
28
29
|
|
29
30
|
# Horizontal divider line
|
30
31
|
FXHorizontalSeparator.new(canvasFrame, SEPARATOR_GROOVE|LAYOUT_FILL_X)
|
31
32
|
|
32
33
|
# Drawing canvas
|
33
|
-
@canvas = FXCanvas.new(canvasFrame,
|
34
|
+
@canvas = FXCanvas.new(canvasFrame, :opts => (FRAME_SUNKEN|
|
34
35
|
FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT))
|
35
36
|
@canvas.connect(SEL_PAINT, method(:onCanvasRepaint))
|
36
37
|
|
37
38
|
# RIGHT pane for the buttons
|
38
|
-
buttonFrame = FXVerticalFrame.new(contents,
|
39
|
-
LAYOUT_TOP|LAYOUT_LEFT
|
39
|
+
buttonFrame = FXVerticalFrame.new(contents,
|
40
|
+
:opts => FRAME_SUNKEN|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT,
|
41
|
+
:padLeft => 10, :padRight => 10, :padTop => 10, :padBottom => 10)
|
42
|
+
|
40
43
|
|
41
44
|
# Label above the buttons
|
42
45
|
FXLabel.new(buttonFrame, "Button Frame", nil,
|
@@ -45,43 +48,42 @@ class ImageWindow < FXMainWindow
|
|
45
48
|
# Horizontal divider line
|
46
49
|
FXHorizontalSeparator.new(buttonFrame, SEPARATOR_RIDGE|LAYOUT_FILL_X)
|
47
50
|
|
48
|
-
FXLabel.new(buttonFrame, "&Background\nColor well",
|
49
|
-
JUSTIFY_CENTER_X|LAYOUT_FILL_X)
|
51
|
+
FXLabel.new(buttonFrame, "&Background\nColor well", :opts => JUSTIFY_CENTER_X|LAYOUT_FILL_X)
|
50
52
|
@backwell = FXColorWell.new(buttonFrame, FXColor::White,
|
51
|
-
|
52
|
-
|
53
|
+
:opts => LAYOUT_CENTER_X|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,
|
54
|
+
:width => 100, :height => 30)
|
53
55
|
@backwell.connect(SEL_COMMAND, method(:onCmdWell))
|
54
56
|
|
55
|
-
FXLabel.new(buttonFrame, "B&order\nColor well",
|
56
|
-
JUSTIFY_CENTER_X|LAYOUT_FILL_X)
|
57
|
+
FXLabel.new(buttonFrame, "B&order\nColor well", :opts => JUSTIFY_CENTER_X|LAYOUT_FILL_X)
|
57
58
|
@borderwell = FXColorWell.new(buttonFrame, FXColor::Black,
|
58
|
-
|
59
|
-
|
59
|
+
:opts => LAYOUT_CENTER_X|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,
|
60
|
+
:width => 100, :height => 30)
|
60
61
|
@borderwell.connect(SEL_COMMAND, method(:onCmdWell))
|
61
62
|
|
62
|
-
FXLabel.new(buttonFrame, "&Text\nColor well",
|
63
|
-
JUSTIFY_CENTER_X|LAYOUT_FILL_X)
|
63
|
+
FXLabel.new(buttonFrame, "&Text\nColor well", :opts => JUSTIFY_CENTER_X|LAYOUT_FILL_X)
|
64
64
|
@textwell = FXColorWell.new(buttonFrame, FXColor::Black,
|
65
|
-
|
66
|
-
|
65
|
+
:opts => LAYOUT_CENTER_X|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,
|
66
|
+
:width => 100, :height => 30)
|
67
67
|
@textwell.connect(SEL_COMMAND, method(:onCmdWell))
|
68
68
|
|
69
69
|
# Button to draw
|
70
70
|
FXButton.new(buttonFrame, "&Colors...\tPop the color dialog", nil,
|
71
|
-
colordlg, FXWindow::ID_SHOW,
|
72
|
-
LAYOUT_TOP|LAYOUT_LEFT
|
71
|
+
colordlg, FXWindow::ID_SHOW,
|
72
|
+
:opts => FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT,
|
73
|
+
:padLeft => 10, :padRight => 10, :padTop => 5, :padBottom => 5)
|
73
74
|
|
74
75
|
# Button to draw
|
75
76
|
saveBtn = FXButton.new(buttonFrame,
|
76
77
|
"Save Image...\tRead back image and save to file",
|
77
|
-
|
78
|
-
|
78
|
+
:opts => FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT,
|
79
|
+
:padLeft => 10, :padRight => 10, :padTop => 5, :padBottom => 5)
|
79
80
|
saveBtn.connect(SEL_COMMAND, method(:onCmdRestore))
|
80
81
|
|
81
82
|
# Exit button
|
82
83
|
FXButton.new(buttonFrame, "E&xit\tQuit ImageApp", nil,
|
83
|
-
getApp(), FXApp::ID_QUIT,
|
84
|
-
LAYOUT_TOP|LAYOUT_LEFT
|
84
|
+
getApp(), FXApp::ID_QUIT,
|
85
|
+
:opts => FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT,
|
86
|
+
:padLeft => 10, :padRight => 10, :padTop => 5, :padBottom => 5)
|
85
87
|
|
86
88
|
# Allocate the color arrays
|
87
89
|
imgWidth = 512
|
@@ -122,15 +124,15 @@ class ImageWindow < FXMainWindow
|
|
122
124
|
(0...512).each { |x|
|
123
125
|
halfX = x >> 1
|
124
126
|
(0...50).each { |y|
|
125
|
-
|
127
|
+
z = (y << 9) + x
|
126
128
|
grey_data[z] = FXRGB(halfX, halfX, halfX)
|
127
|
-
|
129
|
+
grey_nodither_data[z] = grey_data[z]
|
128
130
|
red_data[z] = FXRGB(halfX, 0, 0)
|
129
|
-
|
131
|
+
red_nodither_data[z] = red_data[z]
|
130
132
|
green_data[z] = FXRGB(0, halfX, 0)
|
131
|
-
|
133
|
+
green_nodither_data[z] = green_data[z]
|
132
134
|
blue_data[z] = FXRGB(0, 0, halfX)
|
133
|
-
|
135
|
+
blue_nodither_data[z] = blue_data[z]
|
134
136
|
}
|
135
137
|
}
|
136
138
|
|
@@ -168,7 +170,7 @@ class ImageWindow < FXMainWindow
|
|
168
170
|
end
|
169
171
|
|
170
172
|
def onCanvasRepaint(sender, sel, event)
|
171
|
-
if event.synthetic
|
173
|
+
if event.synthetic?
|
172
174
|
dc = FXDCWindow.new(@picture)
|
173
175
|
|
174
176
|
# Erase the canvas, color comes from well
|
@@ -190,10 +192,10 @@ class ImageWindow < FXMainWindow
|
|
190
192
|
dc.fillStyle = FILL_OPAQUESTIPPLED
|
191
193
|
dc.foreground = FXColor::Black
|
192
194
|
dc.background = FXColor::White
|
193
|
-
(STIPPLE_0..STIPPLE_16).each
|
195
|
+
(STIPPLE_0..STIPPLE_16).each do |pat|
|
194
196
|
dc.stipple = pat
|
195
197
|
dc.fillRectangle(10 + (512*pat)/17, 490, 31, 50)
|
196
|
-
|
198
|
+
end
|
197
199
|
dc.fillStyle = FILL_SOLID
|
198
200
|
|
199
201
|
# Draw borders
|
data/examples/imageviewer.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'fox16'
|
4
|
+
require 'fox16/kwargs'
|
4
5
|
|
5
6
|
include Fox
|
6
7
|
|
@@ -10,8 +11,7 @@ class ImageWindow < FXMainWindow
|
|
10
11
|
|
11
12
|
def initialize(app)
|
12
13
|
# Invoke base class initialize first
|
13
|
-
super(app, "FOX Image Viewer: - untitled",
|
14
|
-
0, 0, 850, 600, 0, 0)
|
14
|
+
super(app, "FOX Image Viewer: - untitled", :opts => DECOR_ALL, :width => 850, :height => 600)
|
15
15
|
|
16
16
|
# Recently used files list
|
17
17
|
@mrufiles = FXRecentFiles.new
|
@@ -74,22 +74,22 @@ class ImageWindow < FXMainWindow
|
|
74
74
|
# Sunken border for image widget
|
75
75
|
imagebox = FXHorizontalFrame.new(splitter,
|
76
76
|
FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
77
|
-
|
77
|
+
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0)
|
78
78
|
|
79
79
|
# Make image widget
|
80
|
-
@imageview = FXImageView.new(imagebox,
|
81
|
-
LAYOUT_FILL_X|LAYOUT_FILL_Y)
|
80
|
+
@imageview = FXImageView.new(imagebox, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
|
82
81
|
|
83
82
|
# Sunken border for file list
|
84
|
-
@filebox = FXHorizontalFrame.new(splitter,
|
85
|
-
|
83
|
+
@filebox = FXHorizontalFrame.new(splitter,
|
84
|
+
LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
85
|
+
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0)
|
86
86
|
|
87
87
|
# Make file list
|
88
88
|
fileframe = FXHorizontalFrame.new(@filebox,
|
89
89
|
FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,
|
90
|
-
|
91
|
-
@filelist = FXFileList.new(fileframe,
|
92
|
-
LAYOUT_FILL_X|LAYOUT_FILL_Y|ICONLIST_MINI_ICONS|ICONLIST_AUTOSIZE)
|
90
|
+
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0. :hSpacing => 0, :vSpacing => 0)
|
91
|
+
@filelist = FXFileList.new(fileframe,
|
92
|
+
:opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|ICONLIST_MINI_ICONS|ICONLIST_AUTOSIZE)
|
93
93
|
@filelist.connect(SEL_DOUBLECLICKED, method(:onCmdFileList))
|
94
94
|
FXButton.new(@filebox, "\tUp one level\tGo up to higher directory.",
|
95
95
|
uplevelicon, @filelist, FXFileList::ID_DIRECTORY_UP,
|
@@ -97,19 +97,19 @@ class ImageWindow < FXMainWindow
|
|
97
97
|
|
98
98
|
# Toobar buttons: File manipulation
|
99
99
|
openBtn = FXButton.new(toolbar, "&Open\tOpen Image\tOpen image file.", fileopenicon,
|
100
|
-
|
100
|
+
:opts => ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED)
|
101
101
|
openBtn.connect(SEL_COMMAND, method(:onCmdOpen))
|
102
102
|
saveBtn = FXButton.new(toolbar, "&Save\tSave Image\tSave image file.", filesaveicon,
|
103
|
-
|
103
|
+
:opts => ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED)
|
104
104
|
saveBtn.connect(SEL_COMMAND, method(:onCmdSave))
|
105
105
|
|
106
106
|
# Toobar buttons: Editing
|
107
|
-
FXButton.new(toolbar, "Cut\tCut", cuticon,
|
108
|
-
ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED)
|
109
|
-
FXButton.new(toolbar, "Copy\tCopy", copyicon,
|
110
|
-
ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED)
|
111
|
-
FXButton.new(toolbar, "Paste\tPaste", pasteicon,
|
112
|
-
ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED)
|
107
|
+
FXButton.new(toolbar, "Cut\tCut", cuticon,
|
108
|
+
:opts => ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED)
|
109
|
+
FXButton.new(toolbar, "Copy\tCopy", copyicon,
|
110
|
+
:opts => ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED)
|
111
|
+
FXButton.new(toolbar, "Paste\tPaste", pasteicon,
|
112
|
+
:opts => ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED)
|
113
113
|
|
114
114
|
# Color
|
115
115
|
FXButton.new(toolbar, "&Colors\tColors\tDisplay color dialog.", paletteicon,
|
@@ -145,13 +145,10 @@ class ImageWindow < FXMainWindow
|
|
145
145
|
# Edit Menu entries
|
146
146
|
FXMenuCommand.new(editmenu, "&Undo\tCtl-Z\tUndo last change.")
|
147
147
|
FXMenuCommand.new(editmenu, "&Redo\tCtl-R\tRedo last undo.")
|
148
|
-
FXMenuCommand.new(editmenu, "&Copy\tCtl-C\tCopy selection to clipboard.",
|
149
|
-
|
150
|
-
FXMenuCommand.new(editmenu, "
|
151
|
-
|
152
|
-
FXMenuCommand.new(editmenu, "&Paste\tCtl-V\tPaste from clipboard.",
|
153
|
-
pasteicon, nil, 0)
|
154
|
-
FXMenuCommand.new(editmenu, "&Delete\t\tDelete selection.", nil, nil, 0)
|
148
|
+
FXMenuCommand.new(editmenu, "&Copy\tCtl-C\tCopy selection to clipboard.", copyicon)
|
149
|
+
FXMenuCommand.new(editmenu, "C&ut\tCtl-X\tCut selection to clipboard.", cuticon)
|
150
|
+
FXMenuCommand.new(editmenu, "&Paste\tCtl-V\tPaste from clipboard.", pasteicon)
|
151
|
+
FXMenuCommand.new(editmenu, "&Delete\t\tDelete selection.")
|
155
152
|
|
156
153
|
# Manipulation Menu entries
|
157
154
|
rotate90Cmd = FXMenuCommand.new(manipmenu, "Rotate 90\t\tRotate 90 degrees.")
|
@@ -247,44 +244,44 @@ class ImageWindow < FXMainWindow
|
|
247
244
|
begin
|
248
245
|
filename = File.join("icons", filename)
|
249
246
|
icon = nil
|
250
|
-
File.open(filename, "rb")
|
247
|
+
File.open(filename, "rb") do |f|
|
251
248
|
icon = FXPNGIcon.new(getApp(), f.read)
|
252
|
-
|
249
|
+
end
|
253
250
|
icon
|
254
251
|
rescue
|
255
252
|
raise RuntimeError, "Couldn't load icon: #{filename}"
|
256
253
|
end
|
257
254
|
end
|
258
255
|
|
259
|
-
def hasExtension(filename, ext)
|
256
|
+
def hasExtension?(filename, ext)
|
260
257
|
File.basename(filename, ext) != File.basename(filename)
|
261
258
|
end
|
262
259
|
|
263
260
|
# Load the named image file
|
264
261
|
def loadImage(file)
|
265
262
|
img = nil
|
266
|
-
if hasExtension(file, ".gif")
|
263
|
+
if hasExtension?(file, ".gif")
|
267
264
|
img = FXGIFImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
|
268
|
-
elsif hasExtension(file, ".bmp")
|
265
|
+
elsif hasExtension?(file, ".bmp")
|
269
266
|
img = FXBMPImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
|
270
|
-
elsif hasExtension(file, ".xpm")
|
267
|
+
elsif hasExtension?(file, ".xpm")
|
271
268
|
img = FXXPMImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
|
272
|
-
elsif hasExtension(file, ".png")
|
269
|
+
elsif hasExtension?(file, ".png")
|
273
270
|
img = FXPNGImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
|
274
|
-
elsif hasExtension(file, ".jpg")
|
271
|
+
elsif hasExtension?(file, ".jpg")
|
275
272
|
img = FXJPGImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
|
276
|
-
elsif hasExtension(file, ".pcx")
|
273
|
+
elsif hasExtension?(file, ".pcx")
|
277
274
|
img = FXPCXImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
|
278
|
-
elsif hasExtension(file, ".tif")
|
275
|
+
elsif hasExtension?(file, ".tif")
|
279
276
|
img = FXTIFImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
|
280
|
-
elsif hasExtension(file, ".tga")
|
277
|
+
elsif hasExtension?(file, ".tga")
|
281
278
|
img = FXTGAImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
|
282
|
-
elsif hasExtension(file, ".ico")
|
279
|
+
elsif hasExtension?(file, ".ico")
|
283
280
|
img = FXICOImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
|
284
281
|
end
|
285
282
|
|
286
283
|
# Perhaps failed?
|
287
|
-
if
|
284
|
+
if img.nil?
|
288
285
|
FXMessageBox.error(self, MBOX_OK, "Error loading image",
|
289
286
|
"Unsupported image type: #{file}")
|
290
287
|
return
|
@@ -340,7 +337,7 @@ class ImageWindow < FXMainWindow
|
|
340
337
|
if MBOX_CLICKED_NO == FXMessageBox.question(self, MBOX_YES_NO,
|
341
338
|
"Overwrite Image", "Overwrite existing image?")
|
342
339
|
return 1
|
343
|
-
|
340
|
+
end
|
344
341
|
end
|
345
342
|
@filename = saveDialog.filename
|
346
343
|
@filelist.currentFile = @filename
|
@@ -400,9 +397,11 @@ class ImageWindow < FXMainWindow
|
|
400
397
|
FXTextField.new(frame, 5, sy, FXDataTarget::ID_VALUE,
|
401
398
|
LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK|JUSTIFY_RIGHT)
|
402
399
|
FXButton.new(frame, "Cancel", nil, scalepanel, FXDialogBox::ID_CANCEL,
|
403
|
-
LAYOUT_CENTER_Y|FRAME_RAISED|FRAME_THICK,
|
400
|
+
LAYOUT_CENTER_Y|FRAME_RAISED|FRAME_THICK,
|
401
|
+
:padLeft => 20, :padRight => 20, :padTop => 4, :padBottom => 4)
|
404
402
|
FXButton.new(frame, "OK", nil, scalepanel, FXDialogBox::ID_ACCEPT,
|
405
|
-
LAYOUT_CENTER_Y|FRAME_RAISED|FRAME_THICK,
|
403
|
+
LAYOUT_CENTER_Y|FRAME_RAISED|FRAME_THICK,
|
404
|
+
:padLeft => 30, :padRight => 30, :padTop => 4, :padBottom => 4)
|
406
405
|
return 1 if (scalepanel.execute == 0)
|
407
406
|
return 1 if (sx.value < 1 || sy.value < 1)
|
408
407
|
image.scale(sx.value, sy.value)
|
@@ -432,9 +431,11 @@ class ImageWindow < FXMainWindow
|
|
432
431
|
FXTextField.new(frame, 5, ch, FXDataTarget::ID_VALUE,
|
433
432
|
LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK|JUSTIFY_RIGHT)
|
434
433
|
FXButton.new(frame, "Cancel", nil, croppanel, FXDialogBox::ID_CANCEL,
|
435
|
-
LAYOUT_CENTER_Y|FRAME_RAISED|FRAME_THICK,
|
434
|
+
LAYOUT_CENTER_Y|FRAME_RAISED|FRAME_THICK,
|
435
|
+
:padLeft => 20, :padRight => 20, :padTop => 4, :padBottom => 4)
|
436
436
|
FXButton.new(frame, "OK", nil, croppanel, FXDialogBox::ID_ACCEPT,
|
437
|
-
LAYOUT_CENTER_Y|FRAME_RAISED|FRAME_THICK,
|
437
|
+
LAYOUT_CENTER_Y|FRAME_RAISED|FRAME_THICK,
|
438
|
+
:padLeft => 30, :padRight => 30, :padTop => 4, :padBottom => 4)
|
438
439
|
return 1 if (croppanel.execute == 0)
|
439
440
|
return 1 if (cx.value < 0 || cy.value < 0 ||
|
440
441
|
cx.value+cw.value > image.width ||
|