wxruby 1.9.0-powerpc-darwin8.10.0 → 1.9.2-powerpc-darwin8.10.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.
- data/LICENSE +53 -0
- data/README +299 -0
- data/lib/wx.rb +7 -0
- data/lib/wx/accessors.rb +52 -0
- data/lib/wx/classes/app.rb +15 -1
- data/lib/wx/classes/bitmap.rb +2 -2
- data/lib/wx/classes/checklistbox.rb +30 -0
- data/lib/wx/classes/clientdc.rb +1 -1
- data/lib/wx/classes/commandevent.rb +7 -0
- data/lib/wx/classes/controlwithitems.rb +10 -0
- data/lib/wx/classes/evthandler.rb +99 -39
- data/lib/wx/classes/grid.rb +13 -13
- data/lib/wx/classes/listctrl.rb +9 -0
- data/lib/wx/classes/menu.rb +62 -0
- data/lib/wx/classes/menuitem.rb +7 -0
- data/lib/wx/classes/paintdc.rb +1 -1
- data/lib/wx/classes/point.rb +43 -0
- data/lib/wx/classes/size.rb +44 -0
- data/lib/wx/classes/styledtextctrl.rb +92 -0
- data/lib/wx/classes/textctrl.rb +14 -0
- data/lib/wx/classes/timer.rb +2 -2
- data/lib/wx/classes/treectrl.rb +18 -0
- data/lib/wx/classes/window.rb +13 -2
- data/lib/wx/keyword_ctors.rb +205 -0
- data/lib/wx/keyword_defs.rb +465 -0
- data/lib/wx/version.rb +1 -1
- data/lib/wxruby2.bundle +0 -0
- data/samples/aui/aui.rb +6 -5
- data/samples/bigdemo/wxListCtrl_virtual.rbw +21 -21
- data/samples/bigdemo/wxScrolledWindow.rbw +8 -3
- data/samples/calendar/calendar.rb +1 -1
- data/samples/caret/caret.rb +29 -39
- data/samples/etc/threaded.rb +81 -0
- data/samples/etc/wizard.rb +22 -24
- data/samples/event/event.rb +184 -0
- data/samples/html/html.rb +25 -12
- data/samples/listbook/listbook.rb +65 -67
- data/samples/minimal/minimal.rb +40 -50
- data/samples/minimal/mondrian.png +0 -0
- data/samples/minimal/nothing.rb +5 -30
- data/samples/text/scintilla.rb +22 -28
- data/samples/text/unicode.rb +1 -1
- data/samples/treectrl/treectrl.rb +197 -226
- metadata +20 -4
- data/samples/minimal/mondrian.xpm +0 -44
- data/samples/minimal/text.rb +0 -35
data/lib/wx/version.rb
CHANGED
data/lib/wxruby2.bundle
CHANGED
Binary file
|
data/samples/aui/aui.rb
CHANGED
@@ -564,7 +564,8 @@ class AuiFrame < Wx::Frame
|
|
564
564
|
evt_update_ui(ID_VerticalGradient) { | e | on_update_ui(e) }
|
565
565
|
evt_update_ui(ID_HorizontalGradient) { | e | on_update_ui(e) }
|
566
566
|
evt_menu_range( ID_FirstPerspective,
|
567
|
-
ID_FirstPerspective +
|
567
|
+
ID_FirstPerspective +
|
568
|
+
@perspectives.length) { | e | on_restore_perspective(e) }
|
568
569
|
evt_aui_pane_close { | e | on_pane_close(e) }
|
569
570
|
evt_auinotebook_page_close(Wx::ID_ANY) { | e | on_notebook_page_close(e) }
|
570
571
|
end
|
@@ -800,7 +801,7 @@ class AuiFrame < Wx::Frame
|
|
800
801
|
def setup_perspectives
|
801
802
|
perspective_all = @mgr.save_perspective
|
802
803
|
|
803
|
-
@mgr.
|
804
|
+
@mgr.each_pane do | pane |
|
804
805
|
pane.hide unless pane.is_toolbar
|
805
806
|
end
|
806
807
|
|
@@ -935,7 +936,7 @@ class AuiFrame < Wx::Frame
|
|
935
936
|
end
|
936
937
|
|
937
938
|
|
938
|
-
@mgr.
|
939
|
+
@mgr.each_pane do | pane |
|
939
940
|
maybe_nb = pane.get_window
|
940
941
|
next unless maybe_nb.kind_of?(Wx::AuiNotebook)
|
941
942
|
if e_id == ID_NotebookArtGloss
|
@@ -1023,8 +1024,8 @@ class AuiFrame < Wx::Frame
|
|
1023
1024
|
def on_create_perspective
|
1024
1025
|
msg = "Enter a name for the new perspective:"
|
1025
1026
|
dlg = Wx::TextEntryDialog.new(self, msg, "Wx::AUI Test")
|
1026
|
-
dlg.set_value("Perspective %d" % @perspectives.length + 1)
|
1027
|
-
return unless dlg.show_modal
|
1027
|
+
dlg.set_value("Perspective %d" % [ @perspectives.length + 1 ] )
|
1028
|
+
return unless dlg.show_modal == Wx::ID_OK
|
1028
1029
|
if @perspectives.length.zero?
|
1029
1030
|
@perspectives_menu.append_separator
|
1030
1031
|
end
|
@@ -60,33 +60,33 @@ class TestVirtualList < Wx::ListCtrl
|
|
60
60
|
@log.write_text("on_item_deselected: %s" % event.get_index())
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
#
|
65
|
-
#
|
66
|
-
|
67
|
-
#
|
68
|
-
#
|
69
|
-
|
63
|
+
# These three following methods are callbacks for implementing the
|
64
|
+
# "virtualness" of the list; they *must* be defined by any ListCtrl
|
65
|
+
# object with the style LC_VIRTUAL.
|
66
|
+
|
67
|
+
# Normally you would determine the text, attributes and/or image
|
68
|
+
# based on values from some external data source, but for this demo
|
69
|
+
# we'll just calculate them based on order.
|
70
70
|
def on_get_item_text(item, col)
|
71
|
-
|
71
|
+
return "Item %d, column %d" % [item,col]
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
74
|
+
def on_get_item_column_image(item, col)
|
75
|
+
if item % 4 == 0
|
76
|
+
return @idx1
|
77
|
+
else
|
78
|
+
return -1
|
79
|
+
end
|
80
80
|
end
|
81
81
|
|
82
82
|
def on_get_item_attr(item)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
if item % 3 == 1
|
84
|
+
return @attr1
|
85
|
+
elsif item % 3 == 2
|
86
|
+
return @attr2
|
87
|
+
else
|
88
|
+
return nil
|
89
|
+
end
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -139,6 +139,8 @@ class MyCanvas < Wx::ScrolledWindow
|
|
139
139
|
if event.left_is_down() and !@drawing
|
140
140
|
set_focus()
|
141
141
|
set_XY(event)
|
142
|
+
@event_x_old = event.get_x # added this to save the current absolute...
|
143
|
+
@event_y_old = event.get_y # ... mouse position
|
142
144
|
@curLine = []
|
143
145
|
capture_mouse()
|
144
146
|
@drawing = true
|
@@ -167,11 +169,14 @@ class MyCanvas < Wx::ScrolledWindow
|
|
167
169
|
|
168
170
|
paint do | dc |
|
169
171
|
dc.set_pen(Wx::Pen.new("MEDIUM FOREST GREEN", 4, Wx::SOLID))
|
170
|
-
|
171
|
-
@
|
172
|
+
save_coords = [@x, @y] + convert_event_coords(event) # translate the absolute coords to save them in the array
|
173
|
+
coords = [@event_x_old, @event_y_old, event.get_x, event.get_y] # the absolute coords to use for the first draw
|
174
|
+
@curLine.push(save_coords) # use the translated coords here
|
172
175
|
coords.flatten!()
|
173
|
-
dc.draw_line(coords[0], coords[1], coords[2], coords[3])
|
176
|
+
dc.draw_line(coords[0], coords[1], coords[2], coords[3]) # and the absolute coords here
|
174
177
|
set_XY(event)
|
178
|
+
@event_x_old = event.get_x # saving the new ...
|
179
|
+
@event_y_old = event.get_y # ... absolute coords
|
175
180
|
end
|
176
181
|
end
|
177
182
|
end
|
data/samples/caret/caret.rb
CHANGED
@@ -15,8 +15,6 @@ end
|
|
15
15
|
include Wx
|
16
16
|
|
17
17
|
# menu items
|
18
|
-
Caret_Quit = ID_EXIT
|
19
|
-
Caret_About = ID_ABOUT
|
20
18
|
Caret_set_blink_time = 3
|
21
19
|
Caret_Move = 4
|
22
20
|
|
@@ -27,26 +25,22 @@ Caret_Text = 1000
|
|
27
25
|
# MyCanvas is a canvas on which you can type
|
28
26
|
class MyCanvas < ScrolledWindow
|
29
27
|
def initialize(parent)
|
30
|
-
super(parent,
|
31
|
-
DEFAULT_POSITION, DEFAULT_SIZE,
|
32
|
-
SUNKEN_BORDER )
|
28
|
+
super(parent, :style => SUNKEN_BORDER)
|
33
29
|
|
34
|
-
|
30
|
+
self.background_colour = WHITE
|
35
31
|
|
36
32
|
@font = Font.new(12, FONTFAMILY_TELETYPE,
|
37
33
|
FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL)
|
38
34
|
|
39
|
-
@x_caret = @y_caret =
|
40
|
-
@x_chars = @y_chars = 0
|
41
|
-
|
35
|
+
@x_caret = @y_caret = @x_chars = @y_chars = 0
|
42
36
|
@x_margin = @y_margin = 5
|
43
37
|
@text = nil
|
44
38
|
|
45
39
|
create_caret
|
46
40
|
|
47
|
-
evt_paint
|
48
|
-
evt_size
|
49
|
-
evt_char
|
41
|
+
evt_paint :on_paint
|
42
|
+
evt_size :on_size
|
43
|
+
evt_char :on_char
|
50
44
|
end
|
51
45
|
|
52
46
|
def [](x,y)
|
@@ -108,14 +102,14 @@ class MyCanvas < ScrolledWindow
|
|
108
102
|
|
109
103
|
def create_caret
|
110
104
|
paint do | dc |
|
111
|
-
dc.
|
112
|
-
@height_char = dc.
|
113
|
-
@width_char = dc.
|
105
|
+
dc.font = @font
|
106
|
+
@height_char = dc.char_height
|
107
|
+
@width_char = dc.char_width
|
114
108
|
|
115
|
-
|
116
|
-
|
109
|
+
my_caret = Caret.new(self, Size.new(@width_char, @height_char))
|
110
|
+
self.caret = my_caret
|
117
111
|
|
118
|
-
caret.move
|
112
|
+
caret.move [ @x_margin, @y_margin ]
|
119
113
|
caret.show
|
120
114
|
end
|
121
115
|
end
|
@@ -130,13 +124,13 @@ class MyCanvas < ScrolledWindow
|
|
130
124
|
def do_move_caret
|
131
125
|
log_status("Caret is at (%d, %d)", @x_caret, @y_caret)
|
132
126
|
|
133
|
-
|
134
|
-
|
127
|
+
caret.move_xy( @x_margin + @x_caret * @width_char,
|
128
|
+
@y_margin + @y_caret * @height_char)
|
135
129
|
end
|
136
130
|
|
137
131
|
def on_size(event)
|
138
|
-
@x_chars = (event.
|
139
|
-
@y_chars = (event.
|
132
|
+
@x_chars = (event.size.x - 2 * @x_margin) / @width_char
|
133
|
+
@y_chars = (event.size.y - 2 * @y_margin) / @height_char
|
140
134
|
if @x_chars <= 0
|
141
135
|
@x_chars = 1
|
142
136
|
end
|
@@ -152,17 +146,15 @@ class MyCanvas < ScrolledWindow
|
|
152
146
|
|
153
147
|
@text = " " * @x_chars * @y_chars
|
154
148
|
|
155
|
-
|
156
|
-
if frame && frame.get_status_bar
|
149
|
+
if parent && parent.status_bar
|
157
150
|
msg = sprintf("Panel size is (%d, %d)", @x_chars, @y_chars)
|
158
|
-
|
159
|
-
|
151
|
+
parent.set_status_text(msg, 1)
|
152
|
+
parent.refresh
|
160
153
|
end
|
161
154
|
event.skip
|
162
155
|
end
|
163
156
|
|
164
157
|
def on_paint
|
165
|
-
caret = get_caret
|
166
158
|
if caret
|
167
159
|
caret.hide
|
168
160
|
end
|
@@ -180,7 +172,6 @@ class MyCanvas < ScrolledWindow
|
|
180
172
|
if caret
|
181
173
|
caret.show
|
182
174
|
end
|
183
|
-
|
184
175
|
end
|
185
176
|
|
186
177
|
def on_char(event)
|
@@ -212,15 +203,14 @@ class MyCanvas < ScrolledWindow
|
|
212
203
|
end
|
213
204
|
do_move_caret
|
214
205
|
end
|
215
|
-
|
216
206
|
end
|
217
207
|
|
218
208
|
class MyFrame < Frame
|
219
|
-
def initialize(title,pos,size)
|
209
|
+
def initialize(title, pos, size)
|
220
210
|
super(nil, -1, title, pos, size)
|
221
211
|
# set the frame icon
|
222
212
|
icon_file = File.join(File.dirname(__FILE__), 'mondrian.xpm')
|
223
|
-
|
213
|
+
self.icon = Icon.new(icon_file, BITMAP_TYPE_XPM)
|
224
214
|
|
225
215
|
# create a menu bar
|
226
216
|
menu_file = Menu.new
|
@@ -228,16 +218,16 @@ class MyFrame < Frame
|
|
228
218
|
menu_file.append(Caret_set_blink_time, "&Blink time...\tCtrl-B")
|
229
219
|
menu_file.append(Caret_Move, "&Move caret\tCtrl-C")
|
230
220
|
menu_file.append_separator
|
231
|
-
menu_file.append(
|
221
|
+
menu_file.append(Wx::ID_ABOUT, "&About...\tCtrl-A", "Show about dialog")
|
232
222
|
menu_file.append_separator
|
233
|
-
menu_file.append(
|
223
|
+
menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit self program")
|
234
224
|
|
235
225
|
# now append the freshly created menu to the menu bar...
|
236
226
|
menu_bar = MenuBar.new
|
237
227
|
menu_bar.append(menu_file, "&File")
|
238
228
|
|
239
229
|
# ... and attach self menu bar to the frame
|
240
|
-
|
230
|
+
self.menu_bar = menu_bar
|
241
231
|
|
242
232
|
@canvas = MyCanvas.new(self)
|
243
233
|
|
@@ -247,12 +237,12 @@ class MyFrame < Frame
|
|
247
237
|
|
248
238
|
# create a status bar just for fun (by default with 1 pane only)
|
249
239
|
create_status_bar(2)
|
250
|
-
|
240
|
+
self.status_text = "Welcome to Windows!"
|
251
241
|
|
252
|
-
evt_menu
|
253
|
-
evt_menu
|
254
|
-
evt_menu
|
255
|
-
evt_menu
|
242
|
+
evt_menu Wx::ID_EXIT, :on_quit
|
243
|
+
evt_menu Wx::ID_ABOUT, :on_about
|
244
|
+
evt_menu Caret_set_blink_time, :on_set_blink_time
|
245
|
+
evt_menu Caret_Move, :on_caret_move
|
256
246
|
end
|
257
247
|
|
258
248
|
def on_quit
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2006 Kevin B. Smith
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'wx'
|
7
|
+
rescue LoadError => no_wx_err
|
8
|
+
begin
|
9
|
+
require 'rubygems'
|
10
|
+
require 'wx'
|
11
|
+
rescue LoadError
|
12
|
+
raise no_wx_err
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# This simple sample demonstrates how to use Ruby 1.8's lightweight
|
17
|
+
# (green) threads to execute non-GUI code in parallel with a wxRuby
|
18
|
+
# GUI. This strategy is useful in a number of situations:
|
19
|
+
#
|
20
|
+
# * To keep the GUI responsive whilst computationally intensive
|
21
|
+
# operations are carried out in the background
|
22
|
+
# * To keep the GUI responsive while waiting for networking operations
|
23
|
+
# to complete
|
24
|
+
#
|
25
|
+
# The basic problem is that, as with other Ruby GUI toolkits, non-GUI
|
26
|
+
# threads will not, by default, get allocated time to run while Ruby is
|
27
|
+
# busy in Wx code - the main wxRuby event loop. Strategies to deal with
|
28
|
+
# this include using non-blocking IO, and, more generically, using
|
29
|
+
# wxRuby's Timer class to explicitly allocate time for non-GUI threads
|
30
|
+
# to run. The latter technique is shown here.
|
31
|
+
|
32
|
+
# This frame shows a set of progress bars which monitor progress of
|
33
|
+
# long-running tasks. In this example, this long-running task is
|
34
|
+
# emulated by simply sleep-ing for random periods, but could equally be
|
35
|
+
# downloading from a socket or parsing a file.
|
36
|
+
class ProgressFrame < Wx::Frame
|
37
|
+
STEPS = 20
|
38
|
+
def initialize
|
39
|
+
super(nil, :title => 'Threading demo')
|
40
|
+
@gauges = []
|
41
|
+
panel = Wx::Panel.new(self)
|
42
|
+
sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
43
|
+
# show ten gauges
|
44
|
+
10.times do
|
45
|
+
gauge = Wx::Gauge.new(panel, :range => STEPS)
|
46
|
+
# For each gauge, start a new thread in which the task runs
|
47
|
+
Thread.new do
|
48
|
+
# The long-running task
|
49
|
+
STEPS.times do | i |
|
50
|
+
sleep rand(100) / 50.0
|
51
|
+
# Update the main GUI
|
52
|
+
gauge.value = i + 1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
@gauges << gauge
|
56
|
+
sizer.add(gauge, 0, Wx::GROW|Wx::ALL, 2)
|
57
|
+
end
|
58
|
+
panel.sizer = sizer
|
59
|
+
sizer.fit(panel)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# This app class creates a frame, and, importantly, a timer to allow
|
64
|
+
class GaugeApp < Wx::App
|
65
|
+
# Get a guaranteed-unique id
|
66
|
+
THREAD_TIMER_ID = Wx::ID_HIGHEST + 1
|
67
|
+
def on_init
|
68
|
+
# Create a global application timer
|
69
|
+
t = Wx::Timer.new(self, THREAD_TIMER_ID)
|
70
|
+
# When the timer "ticks", switch control to other ruby threads
|
71
|
+
evt_timer(THREAD_TIMER_ID) { Thread.pass }
|
72
|
+
# Start the timer to run every 1/40 second (25ms); higher values
|
73
|
+
# will make the other threads run more often, but will eventually
|
74
|
+
# degrade the responsiveness of the GUI.
|
75
|
+
t.start(25)
|
76
|
+
prog = ProgressFrame.new
|
77
|
+
prog.show
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
GaugeApp.new.main_loop
|
data/samples/etc/wizard.rb
CHANGED
@@ -14,42 +14,41 @@ rescue LoadError => no_wx_err
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class MyFrame < Wx::Frame
|
17
|
-
def initialize(title, pos, size
|
18
|
-
super(nil,
|
17
|
+
def initialize(title, pos, size)
|
18
|
+
super(nil, :title => title, :position => pos, :size => size)
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
helpMenu = Wx::Menu.new()
|
20
|
+
menuFile = Wx::Menu.new
|
21
|
+
helpMenu = Wx::Menu.new
|
23
22
|
helpMenu.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
|
24
23
|
menuFile.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
|
25
|
-
menuBar = Wx::MenuBar.new
|
24
|
+
menuBar = Wx::MenuBar.new
|
26
25
|
menuBar.append(menuFile, "&File")
|
27
26
|
menuBar.append(helpMenu, "&Help")
|
28
|
-
|
29
|
-
|
30
|
-
create_status_bar(2)
|
31
|
-
set_status_text("Welcome to wxRuby!")
|
32
|
-
s = Wx::StaticText.new(self, -1, 'The Wizard has completed')
|
27
|
+
self.menu_bar = menuBar
|
33
28
|
|
29
|
+
create_status_bar(1)
|
30
|
+
self.status_text = "Welcome to wxRuby!"
|
31
|
+
s = Wx::StaticText.new(self, :label => 'The Wizard has completed')
|
32
|
+
evt_menu Wx::ID_EXIT, :on_quit
|
33
|
+
evt_menu Wx::ID_ABOUT, :on_about
|
34
34
|
|
35
|
-
|
36
|
-
evt_menu(Wx::ID_ABOUT) { on_about }
|
37
|
-
w = Wx::Wizard.new(self, -1, 'The WxRuby Wizard')
|
35
|
+
w = Wx::Wizard.new(self, :title => 'The WxRuby Wizard')
|
38
36
|
p1 = Wx::WizardPageSimple.new(w)
|
39
|
-
s = Wx::StaticText.new(p1,
|
37
|
+
s = Wx::StaticText.new(p1, :label => 'This is the first page')
|
38
|
+
|
40
39
|
p2 = Wx::WizardPageSimple.new(w, p1)
|
41
40
|
p1.set_next(p2)
|
42
|
-
s = Wx::StaticText.new(p2,
|
41
|
+
s = Wx::StaticText.new(p2, :label => 'This is the second page')
|
42
|
+
|
43
43
|
p3 = Wx::WizardPageSimple.new(w, p2)
|
44
44
|
p2.set_next(p3)
|
45
|
-
s = Wx::StaticText.new(p3,
|
46
|
-
|
47
|
-
evt_wizard_page_changed(w.get_id) { p "page changed" }
|
48
|
-
evt_wizard_page_changing(w.get_id) { p "page changing" }
|
49
|
-
evt_wizard_help(w.get_id) { p "wizard help" }
|
50
|
-
evt_wizard_cancel(w.get_id) { p "wizard cancelled" }
|
51
|
-
evt_wizard_finished(w.get_id) { p "wizard finished" }
|
45
|
+
s = Wx::StaticText.new(p3, :label => 'This is the final page')
|
52
46
|
|
47
|
+
evt_wizard_page_changed(w) { p "page changed" }
|
48
|
+
evt_wizard_page_changing(w) { p "page changing" }
|
49
|
+
evt_wizard_help(w) { p "wizard help" }
|
50
|
+
evt_wizard_cancel(w) { p "wizard cancelled" }
|
51
|
+
evt_wizard_finished(w) { p "wizard finished" }
|
53
52
|
|
54
53
|
w.run_wizard(p1)
|
55
54
|
end
|
@@ -70,7 +69,6 @@ class RbApp < Wx::App
|
|
70
69
|
frame = MyFrame.new("Wizard wxRuby App",
|
71
70
|
Wx::Point.new(50, 50),
|
72
71
|
Wx::Size.new(450, 340))
|
73
|
-
|
74
72
|
frame.show(true)
|
75
73
|
|
76
74
|
end
|