wxruby 1.9.6-x86-mingw32 → 1.9.8-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wx/classes/auinotebook.rb +9 -0
- data/lib/wx/classes/controlwithitems.rb +1 -1
- data/lib/wx/classes/evthandler.rb +47 -4
- data/lib/wx/classes/helpcontrollerhelpprovider.rb +23 -0
- data/lib/wx/classes/helpprovider.rb +15 -0
- data/lib/wx/classes/mediactrl.rb +29 -3
- data/lib/wx/classes/notebook.rb +9 -0
- data/lib/wx/classes/object.rb +8 -1
- data/lib/wx/classes/simplehelpprovider.rb +38 -0
- data/lib/wx/classes/sizer.rb +22 -0
- data/lib/wx/classes/toolbar.rb +29 -0
- data/lib/wx/helpers.rb +30 -0
- data/lib/wx/keyword_ctors.rb +1 -20
- data/lib/wx/keyword_defs.rb +15 -0
- data/lib/wx/version.rb +1 -1
- data/lib/wx.rb +12 -1
- data/lib/wxruby2.so +0 -0
- data/samples/aui/aui.rb +1 -1
- data/samples/dragdrop/dragdrop.rb +177 -0
- data/samples/mdi/mdi.rb +35 -40
- data/samples/media/mediactrl.rb +3 -3
- data/samples/printing/printing.rb +177 -0
- metadata +217 -207
data/samples/mdi/mdi.rb
CHANGED
@@ -7,60 +7,56 @@ rescue LoadError
|
|
7
7
|
end
|
8
8
|
require 'wx'
|
9
9
|
|
10
|
-
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
ID_TILE = 4
|
18
|
-
ID_CREATE = 5
|
19
|
-
ID_CLOSE = 6
|
20
|
-
ID_EXIT = 99
|
21
|
-
|
10
|
+
# Simple MDI-based parent frame with menus to create, cycle through and
|
11
|
+
# close child frames within in.
|
12
|
+
#
|
13
|
+
# NB: MDI is only properly implemented on Windows, and is simulated by
|
14
|
+
# using a Notebook on Linux and OS X. Therefore its use is not
|
15
|
+
# recommended for cross-platform applications. An alternative interface
|
16
|
+
# strategy may be to use separate frames, or possibly the AUI classes.
|
22
17
|
class MyFrame < Wx::MDIParentFrame
|
23
18
|
def initialize(title)
|
24
|
-
super(nil,
|
19
|
+
super(nil, :title => title, :size => [ 500, 400 ] )
|
25
20
|
|
26
21
|
@child_number = 0
|
27
22
|
|
28
23
|
menuFile = Wx::Menu.new
|
29
|
-
menuFile.append(ID_EXIT, "E&xit\tAlt-X")
|
24
|
+
menuFile.append(Wx::ID_EXIT, "E&xit\tAlt-X")
|
25
|
+
evt_menu Wx::ID_EXIT, :close
|
26
|
+
|
30
27
|
menuMDI = Wx::Menu.new
|
31
|
-
menuMDI.append(
|
32
|
-
|
33
|
-
menuMDI.
|
34
|
-
|
35
|
-
menuMDI.
|
36
|
-
|
37
|
-
menuMDI.append(
|
38
|
-
|
28
|
+
menuMDI.append(Wx::ID_FORWARD, "&Next Child\tCtrl-F6")
|
29
|
+
evt_menu Wx::ID_FORWARD, :activate_next
|
30
|
+
menuMDI.append(Wx::ID_BACKWARD, "&Previous Child")
|
31
|
+
evt_menu Wx::ID_BACKWARD, :activate_previous
|
32
|
+
menuMDI.append_separator
|
33
|
+
|
34
|
+
mi_cascade = menuMDI.append("&Cascade")
|
35
|
+
evt_menu mi_cascade, :cascade
|
36
|
+
mi_tile = menuMDI.append("&Tile")
|
37
|
+
evt_menu mi_tile, :tile
|
38
|
+
menuMDI.append_separator
|
39
|
+
|
40
|
+
menuMDI.append(Wx::ID_NEW, "&Add Child")
|
41
|
+
evt_menu Wx::ID_NEW, :create_child
|
42
|
+
menuMDI.append(Wx::ID_CLOSE, "&Remove Child\tCtrl-F4")
|
43
|
+
evt_menu Wx::ID_CLOSE, :on_close_child
|
44
|
+
|
39
45
|
menuBar = Wx::MenuBar.new
|
40
46
|
menuBar.append(menuFile, "&File")
|
41
47
|
menuBar.append(menuMDI, "&Window")
|
42
|
-
|
43
|
-
|
44
|
-
evt_menu(ID_EXIT) { close }
|
45
|
-
evt_menu(ID_NEXT) { activate_next }
|
46
|
-
evt_menu(ID_PREVIOUS) { activate_previous }
|
47
|
-
evt_menu(ID_CASCADE) { cascade }
|
48
|
-
evt_menu(ID_TILE) { tile }
|
49
|
-
evt_menu(ID_CREATE) { create_child }
|
50
|
-
evt_menu(ID_CLOSE) { on_close_child }
|
48
|
+
|
49
|
+
self.menu_bar = menuBar
|
51
50
|
|
52
51
|
create_status_bar(2).set_status_widths([100, -1])
|
53
52
|
set_status_text("Some features only work on MS Windows", 1)
|
54
53
|
|
55
|
-
create_child
|
56
|
-
create_child
|
57
|
-
create_child
|
54
|
+
3.times { create_child }
|
58
55
|
end
|
59
56
|
|
60
57
|
def on_close_child
|
61
|
-
|
62
|
-
|
63
|
-
active.close
|
58
|
+
if active_child
|
59
|
+
active_child.close
|
64
60
|
end
|
65
61
|
end
|
66
62
|
|
@@ -71,12 +67,11 @@ class MyFrame < Wx::MDIParentFrame
|
|
71
67
|
end
|
72
68
|
end
|
73
69
|
|
74
|
-
class
|
70
|
+
class MDIApp < Wx::App
|
75
71
|
def on_init
|
76
72
|
frame = MyFrame.new("MDI App")
|
77
73
|
frame.show
|
78
74
|
end
|
79
75
|
end
|
80
76
|
|
81
|
-
|
82
|
-
a.main_loop()
|
77
|
+
MDIApp.new.main_loop
|
data/samples/media/mediactrl.rb
CHANGED
@@ -9,12 +9,13 @@ require 'wx'
|
|
9
9
|
|
10
10
|
# This sample demonstrates the use of Wx::MediaCtrl, which can be used
|
11
11
|
# to playback sounds or movies using a platform-native player.
|
12
|
-
class MediaPanel<Wx::Panel
|
12
|
+
class MediaPanel < Wx::Panel
|
13
13
|
def initialize(parent)
|
14
14
|
super(parent, :style => Wx::TAB_TRAVERSAL|Wx::CLIP_CHILDREN)
|
15
15
|
|
16
16
|
# The actual media player control
|
17
|
-
@mc = Wx::MediaCtrl.new(self
|
17
|
+
@mc = Wx::MediaCtrl.new(self)
|
18
|
+
|
18
19
|
evt_media_loaded @mc,:on_media_loaded
|
19
20
|
|
20
21
|
# Some buttons to control playback
|
@@ -102,7 +103,6 @@ class MediaPanel<Wx::Panel
|
|
102
103
|
if dlg.show_modal == Wx::ID_OK
|
103
104
|
do_load_file(dlg.path)
|
104
105
|
end
|
105
|
-
dlg.destroy
|
106
106
|
end
|
107
107
|
|
108
108
|
# Move the media to a position in the file, using the slider
|
@@ -7,6 +7,183 @@ rescue LoadError
|
|
7
7
|
end
|
8
8
|
require 'wx'
|
9
9
|
|
10
|
+
WXPRINT_QUIT = Wx::ID_EXIT
|
11
|
+
WXPRINT_PRINT = Wx::ID_PRINT
|
12
|
+
WXPRINT_PAGE_SETUP = Wx::ID_PRINT_SETUP
|
13
|
+
WXPRINT_PREVIEW = Wx::ID_PREVIEW
|
14
|
+
|
15
|
+
WXPRINT_PRINT_PS = 105
|
16
|
+
WXPRINT_PAGE_SETUP_PS = 107
|
17
|
+
WXPRINT_PREVIEW_PS = 108
|
18
|
+
|
19
|
+
WXPRINT_ABOUT = Wx::ID_ABOUT
|
20
|
+
|
21
|
+
WXPRINT_ANGLEUP = 110
|
22
|
+
WXPRINT_ANGLEDOWN = 111
|
23
|
+
|
24
|
+
class MyFrame < Wx::Frame
|
25
|
+
|
26
|
+
attr_accessor :canvas
|
27
|
+
|
28
|
+
def initialize(parent,title,pos,size)
|
29
|
+
super(parent,-1,title,pos,size)
|
30
|
+
@canvas = nil
|
31
|
+
@bitmap = Wx::Bitmap.new
|
32
|
+
@angle = 30
|
33
|
+
|
34
|
+
# map events
|
35
|
+
evt_menu(WXPRINT_QUIT) {|e| on_exit(e)}
|
36
|
+
evt_menu(WXPRINT_PRINT) {|e| on_print(e)}
|
37
|
+
evt_menu(WXPRINT_PREVIEW) {|e| on_print_preview(e)}
|
38
|
+
evt_menu(WXPRINT_PAGE_SETUP) {|e| on_page_setup(e)}
|
39
|
+
evt_menu(WXPRINT_ABOUT) {|e| on_print_about(e)}
|
40
|
+
evt_menu(WXPRINT_ANGLEUP) {|e| on_angle_up(e)}
|
41
|
+
evt_menu(WXPRINT_ANGLEDOWN) {|e| on_angle_down(e)}
|
42
|
+
end
|
43
|
+
|
44
|
+
def draw(dc)
|
45
|
+
dc.set_background(Wx::WHITE_BRUSH)
|
46
|
+
dc.clear()
|
47
|
+
dc.set_font(Wx::get_app.test_font)
|
48
|
+
|
49
|
+
dc.set_background_mode(Wx::TRANSPARENT)
|
50
|
+
|
51
|
+
dc.set_brush(Wx::CYAN_BRUSH)
|
52
|
+
dc.set_pen(Wx::RED_PEN)
|
53
|
+
|
54
|
+
dc.draw_rounded_rectangle(0, 20, 200, 80, 20)
|
55
|
+
|
56
|
+
dc.draw_text( "Rectangle 200 by 80", 40, 40)
|
57
|
+
|
58
|
+
dc.set_pen( Wx::Pen.new(Wx::BLACK,0,Wx::DOT_DASH) )
|
59
|
+
dc.draw_ellipse(50, 140, 100, 50)
|
60
|
+
dc.set_pen(Wx::RED_PEN)
|
61
|
+
|
62
|
+
dc.draw_text( "Test message: this is in 10 point text", 10, 180)
|
63
|
+
|
64
|
+
test = "Hebrew שלום -- Japanese (日本語)"
|
65
|
+
dc.draw_text( test, 10, 200 )
|
66
|
+
|
67
|
+
points = []
|
68
|
+
points << Wx::Point.new(0,0)
|
69
|
+
points << Wx::Point.new(20,0)
|
70
|
+
points << Wx::Point.new(20,20)
|
71
|
+
points << Wx::Point.new(10,20)
|
72
|
+
points << Wx::Point.new(10,-20)
|
73
|
+
|
74
|
+
dc.draw_polygon( points, 20, 250, Wx::ODDEVEN_RULE )
|
75
|
+
dc.draw_polygon( points, 50, 250, Wx::WINDING_RULE )
|
76
|
+
|
77
|
+
dc.draw_elliptic_arc( 80, 250, 60, 30, 0.0, 270.0 )
|
78
|
+
|
79
|
+
points[0].x = 150
|
80
|
+
points[0].y = 250
|
81
|
+
points[1].x = 180
|
82
|
+
points[1].y = 250
|
83
|
+
points[2].x = 180
|
84
|
+
points[2].y = 220
|
85
|
+
points[3].x = 200
|
86
|
+
points[3].y = 220
|
87
|
+
points.pop
|
88
|
+
dc.draw_spline( points )
|
89
|
+
|
90
|
+
dc.draw_arc( 20,10, 10,10, 25,40 )
|
91
|
+
|
92
|
+
str = ""
|
93
|
+
i = 0
|
94
|
+
str = "---- Text at angle #{i} ----"
|
95
|
+
dc.draw_rotated_text( str, 100, 300, i )
|
96
|
+
|
97
|
+
i = @angle;
|
98
|
+
str = "---- Text at angle #{i} ----"
|
99
|
+
dc.draw_rotated_text( str, 100, 300, i )
|
100
|
+
|
101
|
+
dc.set_pen(Wx::BLACK_PEN)
|
102
|
+
dc.draw_line(0, 0, 200, 200)
|
103
|
+
dc.draw_line(200, 0, 0, 200)
|
104
|
+
|
105
|
+
# Load icon
|
106
|
+
if Wx::PLATFORM == "WXMSW"
|
107
|
+
icon_file = File.join(File.dirname(__FILE__), 'mondrian.ico')
|
108
|
+
my_icon = Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_ICO)
|
109
|
+
else
|
110
|
+
icon_file = File.join(File.dirname(__FILE__), 'mondrian.xpm')
|
111
|
+
my_icon = Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_XPM)
|
112
|
+
end
|
113
|
+
|
114
|
+
dc.draw_icon( my_icon, 100, 100)
|
115
|
+
|
116
|
+
if @bitmap.is_ok
|
117
|
+
dc.draw_bitmap( @bitmap, 10, 10 )
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def on_angle_up(event)
|
122
|
+
@angle += 5
|
123
|
+
canvas.refresh
|
124
|
+
end
|
125
|
+
|
126
|
+
def on_angle_down(event)
|
127
|
+
@angle -= 5
|
128
|
+
canvas.refresh
|
129
|
+
end
|
130
|
+
|
131
|
+
def on_size(event)
|
132
|
+
super(event)
|
133
|
+
end
|
134
|
+
|
135
|
+
def on_print(event)
|
136
|
+
print_dialog_data = Wx::PrintDialogData.new(Wx::get_app.print_data)
|
137
|
+
|
138
|
+
printer = Wx::Printer.new(print_dialog_data)
|
139
|
+
printout = MyPrintout.new("My printout")
|
140
|
+
if (!printer.print(self, printout, true))
|
141
|
+
if (Wx::Printer.get_last_error == Wx::PRINTER_ERROR)
|
142
|
+
Wx::message_box("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", Wx::OK)
|
143
|
+
else
|
144
|
+
Wx::message_box("You canceled printing", "Printing", Wx::OK)
|
145
|
+
end
|
146
|
+
else
|
147
|
+
Wx::get_app.print_data = printer.get_print_dialog_data.get_print_data
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def on_print_preview(event)
|
152
|
+
# Pass two printout objects: for preview, and possible printing.
|
153
|
+
print_dialog_data = Wx::PrintDialogData.new(Wx::get_app.print_data)
|
154
|
+
preview = Wx::PrintPreview.new(MyPrintout.new, MyPrintout.new, print_dialog_data)
|
155
|
+
if not preview.is_ok
|
156
|
+
#delete preview;
|
157
|
+
Wx::message_box("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", Wx::OK)
|
158
|
+
return
|
159
|
+
end
|
160
|
+
|
161
|
+
prev_frame = Wx::PreviewFrame.new(preview, self, "Demo Print Preview", Wx::Point.new(100, 100), Wx::Size.new(600, 650))
|
162
|
+
prev_frame.centre(Wx::BOTH)
|
163
|
+
prev_frame.init
|
164
|
+
prev_frame.show
|
165
|
+
end
|
166
|
+
|
167
|
+
def on_page_setup(event)
|
168
|
+
Wx::get_app.page_setup_data = Wx::PageSetupDialogData.new(Wx::get_app.print_data)
|
169
|
+
page_setup_dialog = Wx::PageSetupDialog.new(self, Wx::get_app.page_setup_data)
|
170
|
+
page_setup_dialog.show_modal
|
171
|
+
|
172
|
+
Wx::get_app.print_data = page_setup_dialog.get_page_setup_data.get_print_data
|
173
|
+
Wx::get_app.page_setup_data = Wx::PageSetupDialogData.new(Wx::get_app.print_data)
|
174
|
+
end
|
175
|
+
|
176
|
+
def on_exit(event)
|
177
|
+
close(true)
|
178
|
+
end
|
179
|
+
|
180
|
+
def on_print_about(event)
|
181
|
+
Wx::message_box("wxWidgets printing demo\nAuthor: Julian Smart\nAdapted to wxRuby by Sean Long",
|
182
|
+
"About wxRuby printing demo", Wx::OK|Wx::CENTRE)
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
10
187
|
class MyCanvas < Wx::ScrolledWindow
|
11
188
|
#attr_accessor :frame
|
12
189
|
|