wxruby 1.9.10-x86-mswin32-60 → 2.0.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +254 -0
- data/README +184 -283
- data/lib/wx/accessors.rb +19 -7
- data/lib/wx/classes/bitmap.rb +3 -0
- data/lib/wx/classes/clipboard.rb +28 -4
- data/lib/wx/classes/image.rb +5 -0
- data/lib/wx/classes/toolbar.rb +7 -4
- data/lib/wx/classes/validator.rb +7 -0
- data/lib/wx/keyword_defs.rb +19 -2
- data/lib/wx/version.rb +1 -1
- data/lib/wxruby2.exp +0 -0
- data/lib/wxruby2.lib +0 -0
- data/lib/wxruby2.so +0 -0
- data/samples/aui/aui.rb +21 -21
- data/samples/calendar/calendar.rb +1 -1
- data/samples/drawing/{images.rb → bitmap.rb} +10 -3
- data/samples/drawing/bitmap_image.rb +92 -0
- data/samples/drawing/maths_images.rb +265 -0
- data/samples/drawing/ruby-logo.jpg +0 -0
- data/samples/drawing/wxruby-logo.png +0 -0
- data/samples/text/document-open.png +0 -0
- data/samples/text/document-save.png +0 -0
- data/samples/text/edit-copy.png +0 -0
- data/samples/text/edit-cut.png +0 -0
- data/samples/text/edit-paste.png +0 -0
- data/samples/text/edit-redo.png +0 -0
- data/samples/text/edit-undo.png +0 -0
- data/samples/text/preferences-desktop-font.png +0 -0
- data/samples/text/rich_textctrl.rb +234 -42
- metadata +17 -4
- data/samples/drawing/paperclip.png +0 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -2,16 +2,22 @@
|
|
2
2
|
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
3
|
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
4
|
|
5
|
-
# RichTextCtrl sample by Chauk-Mean
|
5
|
+
# RichTextCtrl sample by Chauk-Mean Proum
|
6
6
|
#
|
7
|
-
# RichTextCtrl is a sophisticated styled text editing component.
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
7
|
+
# RichTextCtrl is a sophisticated styled text editing component.
|
8
|
+
# This sample illustrates a basic but functional rich editor featuring :
|
9
|
+
# - file loading/saving
|
10
|
+
# - text formatting
|
11
|
+
# - change undo/redo
|
12
|
+
# - selection copy/cut and clipboard paste
|
13
|
+
# - font preferences
|
14
|
+
# RichTextCtrl supports numerous other text characteristics (colour, super/subscript),
|
15
|
+
# as well as paragraph alignment and spacing, and bullets.
|
16
|
+
# It permits named text styles to be created and organised in stylesheets.
|
17
|
+
# Facilities are also provided for printing.
|
13
18
|
#
|
14
19
|
# Icons are taken from the Tango Icon Theme.
|
20
|
+
# Disabled icons are created at runtime as darkened grayscale versions.
|
15
21
|
|
16
22
|
begin
|
17
23
|
require 'rubygems'
|
@@ -22,69 +28,255 @@ require 'wx'
|
|
22
28
|
class RichTextFrame < Wx::Frame
|
23
29
|
|
24
30
|
def initialize
|
25
|
-
super( nil, :title => "RichTextCtrl
|
31
|
+
super( nil, :title => "RichTextCtrl Sample", :size => [900, 600] )
|
26
32
|
|
27
|
-
toolbar
|
28
|
-
|
29
|
-
toolbar.tool_bitmap_size = [ 32, 32 ]
|
33
|
+
# Initialize the toolbar with standard actions
|
34
|
+
initialize_toolbar
|
30
35
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
@editor = Wx::RichTextCtrl.new(self, :style => Wx::WANTS_CHARS)
|
37
|
+
|
38
|
+
# Add extra handlers (plain text is automatically added)
|
39
|
+
@editor.buffer.add_handler(Wx::RichTextXMLHandler.new)
|
40
|
+
@editor.buffer.add_handler(Wx::RichTextHTMLHandler.new)
|
41
|
+
file_wildcard = "Text File (*.txt)|*.txt|XML File (*.xml)|*.xml"
|
42
|
+
@file_open_wildcard = file_wildcard + "|All Supported File (*.*)|*.*"
|
43
|
+
@file_save_wildcard = file_wildcard + "|HTML File (*.html)|*.html"
|
44
|
+
|
45
|
+
@cur_dir = Dir.getwd
|
46
|
+
@cur_file = ""
|
47
|
+
@cur_filter_index = 1 # XML file
|
43
48
|
|
44
|
-
|
45
|
-
editor.
|
49
|
+
# Use the system's standard sans-serif font at 18 point
|
50
|
+
@editor.font = Wx::Font.new( 18,
|
51
|
+
Wx::FONTFAMILY_SWISS,
|
52
|
+
Wx::FONTSTYLE_NORMAL,
|
53
|
+
Wx::FONTWEIGHT_NORMAL )
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
initialize_text
|
56
|
+
|
57
|
+
# -- For complex event handling, use of a method call --
|
58
|
+
evt_tool Wx::ID_OPEN, :open_file
|
59
|
+
evt_tool Wx::ID_SAVE, :save_file
|
60
|
+
evt_tool Wx::ID_PREFERENCES, :select_font
|
61
|
+
|
62
|
+
# -- For simple event handling, use of a code block --
|
55
63
|
|
56
64
|
# Apply / unapply bold to selection
|
57
65
|
evt_tool(Wx::ID_BOLD) do
|
58
|
-
editor.apply_bold_to_selection
|
66
|
+
@editor.apply_bold_to_selection
|
59
67
|
end
|
60
68
|
|
61
69
|
# Keep the pressed / unpressed state of the button in sync with the
|
62
70
|
# current selection in the text ctrl
|
63
71
|
evt_update_ui(Wx::ID_BOLD) do |evt|
|
64
|
-
evt.check(editor.selection_bold?)
|
72
|
+
evt.check(@editor.selection_bold?)
|
65
73
|
end
|
66
74
|
|
67
75
|
evt_tool(Wx::ID_ITALIC) do
|
68
|
-
editor.apply_italic_to_selection
|
76
|
+
@editor.apply_italic_to_selection
|
69
77
|
end
|
70
78
|
|
71
79
|
evt_update_ui(Wx::ID_ITALIC) do |evt|
|
72
|
-
evt.check(editor.selection_italics?)
|
80
|
+
evt.check(@editor.selection_italics?)
|
73
81
|
end
|
74
82
|
|
75
83
|
evt_tool(Wx::ID_UNDERLINE) do
|
76
|
-
editor.apply_underline_to_selection
|
84
|
+
@editor.apply_underline_to_selection
|
77
85
|
end
|
78
86
|
|
79
87
|
evt_update_ui(Wx::ID_UNDERLINE) do |evt|
|
80
|
-
evt.check(editor.selection_underlined?)
|
88
|
+
evt.check(@editor.selection_underlined?)
|
89
|
+
end
|
90
|
+
|
91
|
+
evt_tool(Wx::ID_UNDO) do
|
92
|
+
@editor.undo
|
81
93
|
end
|
94
|
+
|
95
|
+
evt_update_ui(Wx::ID_UNDO) do |evt|
|
96
|
+
evt.enable(@editor.can_undo?)
|
97
|
+
end
|
98
|
+
|
99
|
+
evt_tool(Wx::ID_REDO) do
|
100
|
+
@editor.redo
|
101
|
+
end
|
102
|
+
|
103
|
+
evt_update_ui(Wx::ID_REDO) do |evt|
|
104
|
+
evt.enable(@editor.can_redo?)
|
105
|
+
end
|
106
|
+
|
107
|
+
evt_tool(Wx::ID_COPY) do
|
108
|
+
@editor.copy
|
109
|
+
end
|
110
|
+
|
111
|
+
evt_update_ui(Wx::ID_COPY) do |evt|
|
112
|
+
evt.enable(@editor.can_copy?)
|
113
|
+
end
|
114
|
+
|
115
|
+
evt_tool(Wx::ID_CUT) do
|
116
|
+
@editor.cut
|
117
|
+
end
|
118
|
+
|
119
|
+
evt_update_ui(Wx::ID_CUT) do |evt|
|
120
|
+
evt.enable(@editor.can_cut?)
|
121
|
+
end
|
122
|
+
|
123
|
+
evt_tool(Wx::ID_PASTE) do
|
124
|
+
# @editor.apply_bold_to_selection if @editor.selection_bold?
|
125
|
+
# @editor.apply_italic_to_selection if @editor.selection_italics?
|
126
|
+
# @editor.apply_underline_to_selection if @editor.selection_underlined?
|
127
|
+
@editor.paste
|
128
|
+
end
|
129
|
+
|
130
|
+
evt_update_ui(Wx::ID_PASTE) do |evt|
|
131
|
+
evt.enable(@editor.can_paste?)
|
132
|
+
end
|
133
|
+
# Shortcut keys for the editor
|
134
|
+
accel_keys = { "Z" => Wx::ID_UNDO,
|
135
|
+
"Y" => Wx::ID_REDO,
|
136
|
+
"C" => Wx::ID_COPY,
|
137
|
+
"X" => Wx::ID_CUT,
|
138
|
+
"V" => Wx::ID_PASTE }
|
139
|
+
accel_table = accel_keys.keys.map do | key |
|
140
|
+
[ Wx::MOD_CMD, key, accel_keys[key] ]
|
141
|
+
end
|
142
|
+
|
143
|
+
@editor.accelerator_table = Wx::AcceleratorTable[ *accel_table ]
|
82
144
|
end
|
83
145
|
|
84
|
-
|
85
|
-
|
146
|
+
|
147
|
+
# Return bitmaps corresponding to the specified PNG filename :
|
148
|
+
# - the first one is the original version (e.g. for an enabled icon)
|
149
|
+
# - the second one is a darkened grayscale version (e.g. for a disabled icon)
|
150
|
+
def bitmaps_from_png(filename, greyscale = true)
|
86
151
|
img_file = File.join( File.dirname(__FILE__), filename)
|
87
|
-
Wx::Bitmap.new(img_file, Wx::BITMAP_TYPE_PNG)
|
152
|
+
normal_bmp = Wx::Bitmap.new(img_file, Wx::BITMAP_TYPE_PNG)
|
153
|
+
if greyscale
|
154
|
+
greyscale_img = normal_bmp.convert_to_image.convert_to_greyscale(0.2, 0.2, 0.2)
|
155
|
+
greyscale_bmp = Wx::Bitmap.from_image(greyscale_img)
|
156
|
+
return normal_bmp, greyscale_bmp
|
157
|
+
else
|
158
|
+
normal_bmp
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
# Return a new bitmap corresponding to the specified PNG filename
|
164
|
+
def bitmap_from_png(filename)
|
165
|
+
bitmaps_from_png(filename, false)
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
# Initialize the toolbar
|
170
|
+
#
|
171
|
+
# As the toolbar contains only standard actions, use of stock/builtin IDs
|
172
|
+
# to avoid keeping references to each tool item.
|
173
|
+
def initialize_toolbar
|
174
|
+
toolbar = create_tool_bar( Wx::TB_HORIZONTAL|Wx::NO_BORDER|
|
175
|
+
Wx::TB_FLAT|Wx::TB_TEXT )
|
176
|
+
toolbar.tool_bitmap_size = [ 32, 32 ]
|
177
|
+
|
178
|
+
open_bmp = bitmap_from_png("document-open.png")
|
179
|
+
toolbar.add_item(open_bmp, :id => Wx::ID_OPEN,
|
180
|
+
:label => "Open", :short_help => "Open file")
|
181
|
+
|
182
|
+
save_bmp = bitmap_from_png("document-save.png")
|
183
|
+
toolbar.add_item(save_bmp, :id => Wx::ID_SAVE,
|
184
|
+
:label => "Save", :short_help => "Save file")
|
185
|
+
|
186
|
+
font_bmp = bitmap_from_png("preferences-desktop-font.png")
|
187
|
+
toolbar.add_item(font_bmp, :id => Wx::ID_PREFERENCES,
|
188
|
+
:label => "Font", :short_help => "Select font preferences")
|
189
|
+
|
190
|
+
toolbar.add_separator
|
191
|
+
|
192
|
+
copy_bmp, copy_disabled_bmp = bitmaps_from_png("edit-copy.png")
|
193
|
+
toolbar.add_item(copy_bmp, copy_disabled_bmp, :id => Wx::ID_COPY,
|
194
|
+
:label => "Copy", :short_help => "Copy selection (CMD+C)")
|
195
|
+
|
196
|
+
cut_bmp, cut_disabled_bmp = bitmaps_from_png("edit-cut.png")
|
197
|
+
toolbar.add_item(cut_bmp, cut_disabled_bmp, :id => Wx::ID_CUT,
|
198
|
+
:label => "Cut", :short_help => "Cut selection (CMD+X)")
|
199
|
+
|
200
|
+
paste_bmp, paste_disabled_bmp = bitmaps_from_png("edit-paste.png")
|
201
|
+
toolbar.add_item(paste_bmp, paste_disabled_bmp, :id => Wx::ID_PASTE,
|
202
|
+
:label => "Paste", :short_help => "Paste clipboard (CMD+V)")
|
203
|
+
|
204
|
+
undo_bmp, undo_disabled_bmp = bitmaps_from_png("edit-undo.png")
|
205
|
+
toolbar.add_item(undo_bmp, undo_disabled_bmp, :id => Wx::ID_UNDO,
|
206
|
+
:label => "Undo", :short_help => "Undo change (CMD+Z)")
|
207
|
+
|
208
|
+
redo_bmp, redo_disabled_bmp = bitmaps_from_png("edit-redo.png")
|
209
|
+
toolbar.add_item(redo_bmp, redo_disabled_bmp, :id => Wx::ID_REDO,
|
210
|
+
:label => "Redo", :short_help => "Redo change (CMD+Y)")
|
211
|
+
|
212
|
+
toolbar.add_separator
|
213
|
+
|
214
|
+
bold_bmp = bitmap_from_png("format-text-bold.png")
|
215
|
+
toolbar.add_item(bold_bmp, :id => Wx::ID_BOLD, :kind => Wx::ITEM_CHECK,
|
216
|
+
:label => "Bold", :short_help => "Apply bold")
|
217
|
+
|
218
|
+
italic_bmp = bitmap_from_png("format-text-italic.png")
|
219
|
+
toolbar.add_item(italic_bmp, :id => Wx::ID_ITALIC, :kind => Wx::ITEM_CHECK,
|
220
|
+
:label => "Italic", :short_help => "Apply italic")
|
221
|
+
|
222
|
+
underline_bmp = bitmap_from_png("format-text-underline.png")
|
223
|
+
toolbar.add_item(underline_bmp, :id => Wx::ID_UNDERLINE, :kind => Wx::ITEM_CHECK,
|
224
|
+
:label => "Underline", :short_help => "Apply underline")
|
225
|
+
|
226
|
+
toolbar.realize
|
227
|
+
end
|
228
|
+
|
229
|
+
def initialize_text
|
230
|
+
@editor.begin_suppress_undo
|
231
|
+
@editor.begin_bold
|
232
|
+
@editor.write_text "Simple RichTextCtrl sample"
|
233
|
+
@editor.end_bold
|
234
|
+
@editor.newline
|
235
|
+
@editor.begin_italic
|
236
|
+
@editor.write_text "Use the formatting buttons then type some text or "
|
237
|
+
@editor.write_text "select some text and use the buttons to apply the formatting.\n"
|
238
|
+
@editor.write_text "Save as an XML file in order to keep the text formatting.\n"
|
239
|
+
@editor.end_italic
|
240
|
+
@editor.newline
|
241
|
+
@editor.end_suppress_undo
|
242
|
+
end
|
243
|
+
|
244
|
+
def select_font
|
245
|
+
data = Wx::FontData.new
|
246
|
+
data.initial_font = @editor.font
|
247
|
+
# data.enable_effects(false)
|
248
|
+
|
249
|
+
dlg = Wx::FontDialog.new(self, data)
|
250
|
+
if dlg.show_modal() == Wx::ID_OK
|
251
|
+
data = dlg.font_data
|
252
|
+
@editor.font = data.chosen_font
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def open_file
|
257
|
+
dlg = Wx::FileDialog.new(self, "Open file", @cur_dir, @cur_file, @file_open_wildcard, Wx::OPEN)
|
258
|
+
dlg.filter_index = @cur_filter_index
|
259
|
+
if dlg.show_modal() == Wx::ID_OK
|
260
|
+
@editor.load_file(dlg.path, Wx::RICHTEXT_TYPE_ANY)
|
261
|
+
update_from_file dlg
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def save_file
|
266
|
+
dlg = Wx::FileDialog.new(self, "Save file as...", @cur_dir, @cur_file, @file_save_wildcard, Wx::SAVE)
|
267
|
+
dlg.filter_index = @cur_filter_index
|
268
|
+
if dlg.show_modal() == Wx::ID_OK
|
269
|
+
@editor.save_file(dlg.path, Wx::RICHTEXT_TYPE_ANY)
|
270
|
+
update_from_file dlg
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
# Update current file parameters
|
275
|
+
def update_from_file dlg
|
276
|
+
@cur_dir = dlg.directory
|
277
|
+
@cur_file = dlg.filename
|
278
|
+
@cur_filter_index = dlg.filter_index
|
279
|
+
self.title = "RichTextCtrl Sample - #{@cur_file}"
|
88
280
|
end
|
89
281
|
end
|
90
282
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wxruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: x86-mswin32-60
|
6
6
|
authors:
|
7
7
|
- wxRuby development team
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-27 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/wx/classes/toolbar.rb
|
87
87
|
- lib/wx/classes/toolbartool.rb
|
88
88
|
- lib/wx/classes/treectrl.rb
|
89
|
+
- lib/wx/classes/validator.rb
|
89
90
|
- lib/wx/classes/vboxsizer.rb
|
90
91
|
- lib/wx/classes/window.rb
|
91
92
|
- lib/wx/classes/xmlresource.rb
|
@@ -238,9 +239,12 @@ files:
|
|
238
239
|
- samples/dragdrop
|
239
240
|
- samples/dragdrop/dragdrop.rb
|
240
241
|
- samples/drawing
|
242
|
+
- samples/drawing/bitmap.rb
|
243
|
+
- samples/drawing/bitmap_image.rb
|
241
244
|
- samples/drawing/graphics_drawing.rb
|
242
|
-
- samples/drawing/
|
243
|
-
- samples/drawing/
|
245
|
+
- samples/drawing/maths_images.rb
|
246
|
+
- samples/drawing/ruby-logo.jpg
|
247
|
+
- samples/drawing/wxruby-logo.png
|
244
248
|
- samples/etc
|
245
249
|
- samples/etc/activation.rb
|
246
250
|
- samples/etc/choice.rb
|
@@ -287,11 +291,19 @@ files:
|
|
287
291
|
- samples/sockets/wxServer.rb
|
288
292
|
- samples/sockets/wxSocketGUI.rb
|
289
293
|
- samples/text
|
294
|
+
- samples/text/document-open.png
|
295
|
+
- samples/text/document-save.png
|
296
|
+
- samples/text/edit-copy.png
|
297
|
+
- samples/text/edit-cut.png
|
298
|
+
- samples/text/edit-paste.png
|
299
|
+
- samples/text/edit-redo.png
|
300
|
+
- samples/text/edit-undo.png
|
290
301
|
- samples/text/format-text-bold.png
|
291
302
|
- samples/text/format-text-italic.png
|
292
303
|
- samples/text/format-text-underline.png
|
293
304
|
- samples/text/mondrian.ico
|
294
305
|
- samples/text/mondrian.xpm
|
306
|
+
- samples/text/preferences-desktop-font.png
|
295
307
|
- samples/text/rich_textctrl.rb
|
296
308
|
- samples/text/scintilla.rb
|
297
309
|
- samples/text/textctrl.rb
|
@@ -308,6 +320,7 @@ files:
|
|
308
320
|
- samples/xrc/samples.xrc
|
309
321
|
- samples/xrc/xrc_sample.rb
|
310
322
|
- README
|
323
|
+
- INSTALL
|
311
324
|
- LICENSE
|
312
325
|
has_rdoc: false
|
313
326
|
homepage: http://wxruby.org/
|
Binary file
|