wxruby64 2.0.1-x64-mingw32
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
- data/INSTALL +254 -0
- data/LICENSE +53 -0
- data/README +198 -0
- data/art/wxruby-128x128.png +0 -0
- data/art/wxruby-256x256.png +0 -0
- data/art/wxruby-64x64.png +0 -0
- data/art/wxruby.png +0 -0
- data/lib/wx.rb +53 -0
- data/lib/wx/accessors.rb +68 -0
- data/lib/wx/classes/acceleratortable.rb +28 -0
- data/lib/wx/classes/animation.rb +18 -0
- data/lib/wx/classes/app.rb +51 -0
- data/lib/wx/classes/artprovider.rb +31 -0
- data/lib/wx/classes/auinotebook.rb +9 -0
- data/lib/wx/classes/bitmap.rb +59 -0
- data/lib/wx/classes/busycursor.rb +12 -0
- data/lib/wx/classes/checklistbox.rb +46 -0
- data/lib/wx/classes/choice.rb +4 -0
- data/lib/wx/classes/clientdc.rb +13 -0
- data/lib/wx/classes/clipboard.rb +56 -0
- data/lib/wx/classes/colour.rb +49 -0
- data/lib/wx/classes/combobox.rb +4 -0
- data/lib/wx/classes/commandevent.rb +7 -0
- data/lib/wx/classes/controlwithitems.rb +10 -0
- data/lib/wx/classes/data_object.rb +14 -0
- data/lib/wx/classes/data_object_simple.rb +6 -0
- data/lib/wx/classes/dataformat.rb +23 -0
- data/lib/wx/classes/dc.rb +57 -0
- data/lib/wx/classes/event.rb +5 -0
- data/lib/wx/classes/evthandler.rb +1039 -0
- data/lib/wx/classes/font.rb +118 -0
- data/lib/wx/classes/functions.rb +44 -0
- data/lib/wx/classes/gauge.rb +12 -0
- data/lib/wx/classes/genericdirctrl.rb +36 -0
- data/lib/wx/classes/grid.rb +146 -0
- data/lib/wx/classes/hboxsizer.rb +6 -0
- data/lib/wx/classes/helpcontroller.rb +5 -0
- data/lib/wx/classes/helpcontrollerhelpprovider.rb +23 -0
- data/lib/wx/classes/helpprovider.rb +15 -0
- data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
- data/lib/wx/classes/htmlwindow.rb +14 -0
- data/lib/wx/classes/icon.rb +32 -0
- data/lib/wx/classes/iconbundle.rb +3 -0
- data/lib/wx/classes/image.rb +53 -0
- data/lib/wx/classes/imagelist.rb +3 -0
- data/lib/wx/classes/listbox.rb +4 -0
- data/lib/wx/classes/listctrl.rb +33 -0
- data/lib/wx/classes/locale.rb +28 -0
- data/lib/wx/classes/mediactrl.rb +48 -0
- data/lib/wx/classes/menu.rb +62 -0
- data/lib/wx/classes/menuitem.rb +7 -0
- data/lib/wx/classes/notebook.rb +9 -0
- data/lib/wx/classes/object.rb +14 -0
- data/lib/wx/classes/paintdc.rb +12 -0
- data/lib/wx/classes/point.rb +56 -0
- data/lib/wx/classes/previewframe.rb +13 -0
- data/lib/wx/classes/rect.rb +19 -0
- data/lib/wx/classes/richtextctrl.rb +63 -0
- data/lib/wx/classes/simplehelpprovider.rb +38 -0
- data/lib/wx/classes/size.rb +58 -0
- data/lib/wx/classes/sizer.rb +43 -0
- data/lib/wx/classes/sound.rb +23 -0
- data/lib/wx/classes/splitterwindow.rb +10 -0
- data/lib/wx/classes/standardpaths.rb +9 -0
- data/lib/wx/classes/styledtextctrl.rb +92 -0
- data/lib/wx/classes/textctrl.rb +14 -0
- data/lib/wx/classes/texturlevent.rb +18 -0
- data/lib/wx/classes/timer.rb +96 -0
- data/lib/wx/classes/toolbar.rb +36 -0
- data/lib/wx/classes/toolbartool.rb +4 -0
- data/lib/wx/classes/treectrl.rb +44 -0
- data/lib/wx/classes/validator.rb +7 -0
- data/lib/wx/classes/vboxsizer.rb +6 -0
- data/lib/wx/classes/window.rb +89 -0
- data/lib/wx/classes/xmlresource.rb +54 -0
- data/lib/wx/helpers.rb +54 -0
- data/lib/wx/keyword_ctors.rb +204 -0
- data/lib/wx/keyword_defs.rb +585 -0
- data/lib/wx/version.rb +3 -0
- data/lib/wxruby2.so +0 -0
- data/samples/SAMPLES-LICENSE.TXT +18 -0
- data/samples/aui/aui.rb +1356 -0
- data/samples/bigdemo/About.rbw +39 -0
- data/samples/bigdemo/ColorPanel.rbw +23 -0
- data/samples/bigdemo/GridSimple.rbw +78 -0
- data/samples/bigdemo/MDIDemo.rbw +57 -0
- data/samples/bigdemo/PopupMenu.rbw +149 -0
- data/samples/bigdemo/ShapedWindow.rbw +128 -0
- data/samples/bigdemo/Sizers.rbw +543 -0
- data/samples/bigdemo/bigdemo.rb +823 -0
- data/samples/bigdemo/demoTemplate.rbw +33 -0
- data/samples/bigdemo/helpfile.htb +0 -0
- data/samples/bigdemo/icons/Test 015.jpg +0 -0
- data/samples/bigdemo/icons/Test 015.png +0 -0
- data/samples/bigdemo/icons/choice.bmp +0 -0
- data/samples/bigdemo/icons/choice.xpm +27 -0
- data/samples/bigdemo/icons/combo.bmp +0 -0
- data/samples/bigdemo/icons/combo.xpm +27 -0
- data/samples/bigdemo/icons/copy.xpm +25 -0
- data/samples/bigdemo/icons/cut.xpm +24 -0
- data/samples/bigdemo/icons/gauge.bmp +0 -0
- data/samples/bigdemo/icons/gauge.xpm +27 -0
- data/samples/bigdemo/icons/help.xpm +25 -0
- data/samples/bigdemo/icons/list.bmp +0 -0
- data/samples/bigdemo/icons/list.xpm +27 -0
- data/samples/bigdemo/icons/mondrian.ico +0 -0
- data/samples/bigdemo/icons/mondrian.xpm +44 -0
- data/samples/bigdemo/icons/new.xpm +24 -0
- data/samples/bigdemo/icons/ogl.ico +0 -0
- data/samples/bigdemo/icons/ogl.xpm +45 -0
- data/samples/bigdemo/icons/open.xpm +26 -0
- data/samples/bigdemo/icons/paste.bmp +0 -0
- data/samples/bigdemo/icons/paste.xpm +38 -0
- data/samples/bigdemo/icons/pointy.png +0 -0
- data/samples/bigdemo/icons/preview.xpm +26 -0
- data/samples/bigdemo/icons/print.xpm +26 -0
- data/samples/bigdemo/icons/radio.bmp +0 -0
- data/samples/bigdemo/icons/radio.xpm +27 -0
- data/samples/bigdemo/icons/robert.xpm +415 -0
- data/samples/bigdemo/icons/sashtest.ico +0 -0
- data/samples/bigdemo/icons/save.xpm +25 -0
- data/samples/bigdemo/icons/smiles.bmp +0 -0
- data/samples/bigdemo/icons/smiles.xpm +39 -0
- data/samples/bigdemo/icons/smiley.ico +0 -0
- data/samples/bigdemo/icons/smiley.xpm +42 -0
- data/samples/bigdemo/icons/stattext.xpm +24 -0
- data/samples/bigdemo/icons/test2.bmp +0 -0
- data/samples/bigdemo/icons/test2.png +0 -0
- data/samples/bigdemo/icons/test2.xpm +79 -0
- data/samples/bigdemo/icons/text.bmp +0 -0
- data/samples/bigdemo/icons/text.xpm +27 -0
- data/samples/bigdemo/icons/tog1.bmp +0 -0
- data/samples/bigdemo/icons/tog1.xpm +38 -0
- data/samples/bigdemo/icons/tog2.bmp +0 -0
- data/samples/bigdemo/icons/tog2.xpm +38 -0
- data/samples/bigdemo/icons/wxruby-128x128.png +0 -0
- data/samples/bigdemo/icons/wxwin.ico +0 -0
- data/samples/bigdemo/icons/wxwin16x16.png +0 -0
- data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
- data/samples/bigdemo/icons/wxwin32x32.png +0 -0
- data/samples/bigdemo/icons/wxwin48x48.png +0 -0
- data/samples/bigdemo/run.rb +90 -0
- data/samples/bigdemo/tips.txt +7 -0
- data/samples/bigdemo/utils.rb +12 -0
- data/samples/bigdemo/wxArtProvider.rbw +281 -0
- data/samples/bigdemo/wxBitmapButton.rbw +65 -0
- data/samples/bigdemo/wxButton.rbw +64 -0
- data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
- data/samples/bigdemo/wxCheckBox.rbw +50 -0
- data/samples/bigdemo/wxCheckListBox.rbw +65 -0
- data/samples/bigdemo/wxChoice.rbw +47 -0
- data/samples/bigdemo/wxChoicebook.rbw +78 -0
- data/samples/bigdemo/wxColourDialog.rbw +31 -0
- data/samples/bigdemo/wxComboBox.rbw +77 -0
- data/samples/bigdemo/wxCursor.rbw +136 -0
- data/samples/bigdemo/wxDialog.rbw +74 -0
- data/samples/bigdemo/wxDirDialog.rbw +29 -0
- data/samples/bigdemo/wxDragImage.rbw +70 -0
- data/samples/bigdemo/wxFileDialog.rbw +37 -0
- data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
- data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
- data/samples/bigdemo/wxFontDialog.rbw +173 -0
- data/samples/bigdemo/wxFrame.rbw +53 -0
- data/samples/bigdemo/wxGauge.rbw +71 -0
- data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
- data/samples/bigdemo/wxGrid.rbw +66 -0
- data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
- data/samples/bigdemo/wxListBox.rbw +140 -0
- data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -0
- data/samples/bigdemo/wxMDIWindows.rbw +50 -0
- data/samples/bigdemo/wxMenu.rbw +236 -0
- data/samples/bigdemo/wxMessageDialog.rbw +27 -0
- data/samples/bigdemo/wxMiniFrame.rbw +70 -0
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
- data/samples/bigdemo/wxNotebook.rbw +136 -0
- data/samples/bigdemo/wxProgressDialog.rbw +43 -0
- data/samples/bigdemo/wxRadioBox.rbw +72 -0
- data/samples/bigdemo/wxRadioButton.rbw +125 -0
- data/samples/bigdemo/wxSashWindow.rbw +141 -0
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
- data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
- data/samples/bigdemo/wxSlider.rbw +42 -0
- data/samples/bigdemo/wxSpinButton.rbw +50 -0
- data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
- data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
- data/samples/bigdemo/wxStaticBitmap.rbw +47 -0
- data/samples/bigdemo/wxStaticText.rbw +55 -0
- data/samples/bigdemo/wxStatusBar.rbw +126 -0
- data/samples/bigdemo/wxTextCtrl.rbw +149 -0
- data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
- data/samples/bigdemo/wxToggleButton.rbw +49 -0
- data/samples/bigdemo/wxToolBar.rbw +131 -0
- data/samples/bigdemo/wxTreeCtrl.rbw +191 -0
- data/samples/calendar/calendar.rb +348 -0
- data/samples/caret/caret.rb +282 -0
- data/samples/caret/mondrian.xpm +44 -0
- data/samples/controls/controls.rb +1136 -0
- data/samples/controls/get_item_sample.rb +87 -0
- data/samples/controls/icons/choice.xpm +27 -0
- data/samples/controls/icons/combo.xpm +27 -0
- data/samples/controls/icons/gauge.xpm +27 -0
- data/samples/controls/icons/list.xpm +27 -0
- data/samples/controls/icons/radio.xpm +27 -0
- data/samples/controls/icons/stattext.xpm +24 -0
- data/samples/controls/icons/text.xpm +27 -0
- data/samples/controls/mondrian.ico +0 -0
- data/samples/controls/mondrian.xpm +44 -0
- data/samples/controls/test2.bmp +0 -0
- data/samples/dialogs/dialogs.rb +797 -0
- data/samples/dialogs/tips.txt +18 -0
- data/samples/dragdrop/dragdrop.rb +177 -0
- data/samples/drawing/bitmap.rb +49 -0
- data/samples/drawing/bitmap_image.rb +92 -0
- data/samples/drawing/graphics_drawing.rb +235 -0
- data/samples/drawing/maths_images.rb +265 -0
- data/samples/drawing/rmagic_bitmap_image.rb +110 -0
- data/samples/drawing/ruby-logo.jpg +0 -0
- data/samples/etc/activation.rb +102 -0
- data/samples/etc/choice.rb +67 -0
- data/samples/etc/miniframe.rb +79 -0
- data/samples/etc/sash.rb +130 -0
- data/samples/etc/scrollwin.rb +110 -0
- data/samples/etc/system_settings.rb +252 -0
- data/samples/etc/threaded.rb +72 -0
- data/samples/etc/toolbar_sizer_additem.rb +55 -0
- data/samples/etc/wizard.rb +74 -0
- data/samples/event/event.rb +182 -0
- data/samples/event/update_ui_event.rb +70 -0
- data/samples/grid/grid.rb +198 -0
- data/samples/grid/gridtablebase.rb +148 -0
- data/samples/html/html.rb +262 -0
- data/samples/listbook/listbook.rb +174 -0
- data/samples/listbook/listbook.xrc +370 -0
- data/samples/mdi/mdi.rb +85 -0
- data/samples/media/mediactrl.rb +167 -0
- data/samples/minimal/minimal.rb +77 -0
- data/samples/minimal/mondrian.ico +0 -0
- data/samples/minimal/mondrian.png +0 -0
- data/samples/minimal/nothing.rb +16 -0
- data/samples/opengl/cube.rb +130 -0
- data/samples/opengl/cube_anim_lighting.rb +191 -0
- data/samples/printing/mondrian.ico +0 -0
- data/samples/printing/mondrian.xpm +44 -0
- data/samples/printing/printing.rb +487 -0
- data/samples/sockets/SocketPackets.rb +27 -0
- data/samples/sockets/res/message-new.png +0 -0
- data/samples/sockets/res/user.png +0 -0
- data/samples/sockets/wxClient.rb +395 -0
- data/samples/sockets/wxServer.rb +422 -0
- data/samples/sockets/wxSocketGUI.rb +97 -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/format-text-bold.png +0 -0
- data/samples/text/format-text-italic.png +0 -0
- data/samples/text/format-text-underline.png +0 -0
- data/samples/text/mondrian.ico +0 -0
- data/samples/text/mondrian.xpm +44 -0
- data/samples/text/preferences-desktop-font.png +0 -0
- data/samples/text/rich_textctrl.rb +290 -0
- data/samples/text/scintilla.rb +169 -0
- data/samples/text/textctrl.rb +111 -0
- data/samples/text/unicode.rb +242 -0
- data/samples/text/utf8.txt +15 -0
- data/samples/treectrl/icon1.xpm +79 -0
- data/samples/treectrl/icon2.xpm +53 -0
- data/samples/treectrl/icon3.xpm +79 -0
- data/samples/treectrl/icon4.xpm +43 -0
- data/samples/treectrl/icon5.xpm +79 -0
- data/samples/treectrl/treectrl.rb +1166 -0
- data/samples/xrc/samples.xrc +46 -0
- data/samples/xrc/xrc_sample.rb +76 -0
- metadata +330 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
# wxRuby2 Sample Code. Copyright (c) 2007-???? Mario J. Steele
|
2
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
3
|
+
|
4
|
+
if /darwin/ =~ RUBY_PLATFORM
|
5
|
+
$LOCALHOST_NAME = "127.0.0.1"
|
6
|
+
else
|
7
|
+
$LOCALHOST_NAME = "localhost"
|
8
|
+
end
|
9
|
+
|
10
|
+
class SocketGUI < Wx::Frame
|
11
|
+
@@constants = []
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
icon_file = File.join( File.dirname(__FILE__), 'res', 'message-new.png')
|
16
|
+
self.icon = Wx::Icon.new(icon_file,Wx::BITMAP_TYPE_PNG)
|
17
|
+
|
18
|
+
@il = Wx::ImageList.new(16,16)
|
19
|
+
# User icon courtesy of http://www.famfamfam.com/lab/icons/silk/
|
20
|
+
icon_file = File.join( File.dirname(__FILE__), 'res', 'user.png')
|
21
|
+
@il.add( Wx::Bitmap.new(icon_file, Wx::BITMAP_TYPE_PNG) )
|
22
|
+
hbox = Wx::BoxSizer.new(Wx::HORIZONTAL)
|
23
|
+
vbox = Wx::BoxSizer.new(Wx::VERTICAL)
|
24
|
+
|
25
|
+
# For display of Text Events
|
26
|
+
@output = Wx::TextCtrl.new( self, :style => Wx::TE_RICH2|
|
27
|
+
Wx::TE_READONLY|Wx::SUNKEN_BORDER|
|
28
|
+
Wx::TE_MULTILINE|Wx::TE_AUTO_URL)
|
29
|
+
# List of Users
|
30
|
+
@users = Wx::ListCtrl.new( self, :style => Wx::LC_REPORT|
|
31
|
+
Wx::LC_NO_HEADER|Wx::LC_SINGLE_SEL)
|
32
|
+
@users.set_image_list(@il,Wx::IMAGE_LIST_SMALL)
|
33
|
+
@users.insert_column(0,"Users")
|
34
|
+
# For Input from the User
|
35
|
+
@input = Wx::TextCtrl.new(self, :style => Wx::TE_PROCESS_ENTER)
|
36
|
+
vbox.add(@output,2,Wx::EXPAND)
|
37
|
+
vbox.add(@input,0,Wx::GROW)
|
38
|
+
hbox.add(vbox,2,Wx::EXPAND)
|
39
|
+
hbox.add(@users,0,Wx::GROW)
|
40
|
+
self.sizer = hbox
|
41
|
+
@@constants.each_with_index do |const,i|
|
42
|
+
self.class.const_set(const,1001+i)
|
43
|
+
end
|
44
|
+
create_menus()
|
45
|
+
create_status_bar()
|
46
|
+
on_init()
|
47
|
+
@font = Wx::Font.new(10,Wx::FONTFAMILY_TELETYPE,Wx::NORMAL,Wx::NORMAL)
|
48
|
+
@progStyle = Wx::TextAttr.new(Wx::BLUE, Wx::YELLOW, @font)
|
49
|
+
@defStyle = Wx::TextAttr.new(Wx::BLACK, Wx::WHITE, @font)
|
50
|
+
@errStyle = Wx::TextAttr.new(Wx::RED, Wx::GREEN, @font)
|
51
|
+
self.set_size([640,480])
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_user(user)
|
55
|
+
#@users.append_item(@root,user,0)
|
56
|
+
@users.insert_item(0,user,0)
|
57
|
+
end
|
58
|
+
|
59
|
+
def clear_users()
|
60
|
+
@users.delete_all_items
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_menus()
|
64
|
+
# Holder Function
|
65
|
+
end
|
66
|
+
|
67
|
+
def on_init()
|
68
|
+
# Holder Function
|
69
|
+
end
|
70
|
+
|
71
|
+
def append_text(msg)
|
72
|
+
@output.freeze
|
73
|
+
c, sl = @output.position_to_xy(@output.get_last_position)
|
74
|
+
@output.append_text(msg)
|
75
|
+
@output.thaw
|
76
|
+
c, el = @output.position_to_xy(@output.get_last_position)
|
77
|
+
@output.scroll_lines((el-sl)+2) unless sl == nil || el == nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def append_prog_msg(msg)
|
81
|
+
@output.set_default_style(@progStyle)
|
82
|
+
msg += "\n" if msg[-1].chr != "\n"
|
83
|
+
append_text(msg)
|
84
|
+
end
|
85
|
+
|
86
|
+
def append_msg(msg)
|
87
|
+
@output.set_default_style(@defStyle)
|
88
|
+
msg += "\n" if msg[-1].chr != "\n"
|
89
|
+
append_text(msg)
|
90
|
+
end
|
91
|
+
|
92
|
+
def append_error(msg)
|
93
|
+
@output.set_default_style(@errStyle)
|
94
|
+
msg += "\n" if msg[-1].chr != "\n"
|
95
|
+
append_text(msg)
|
96
|
+
end
|
97
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char *mondrian_xpm[] = {
|
3
|
+
/* columns rows colors chars-per-pixel */
|
4
|
+
"32 32 6 1",
|
5
|
+
" c Black",
|
6
|
+
". c Blue",
|
7
|
+
"X c #00bf00",
|
8
|
+
"o c Red",
|
9
|
+
"O c Yellow",
|
10
|
+
"+ c Gray100",
|
11
|
+
/* pixels */
|
12
|
+
" ",
|
13
|
+
" oooooo +++++++++++++++++++++++ ",
|
14
|
+
" oooooo +++++++++++++++++++++++ ",
|
15
|
+
" oooooo +++++++++++++++++++++++ ",
|
16
|
+
" oooooo +++++++++++++++++++++++ ",
|
17
|
+
" oooooo +++++++++++++++++++++++ ",
|
18
|
+
" oooooo +++++++++++++++++++++++ ",
|
19
|
+
" oooooo +++++++++++++++++++++++ ",
|
20
|
+
" ",
|
21
|
+
" ++++++ ++++++++++++++++++ .... ",
|
22
|
+
" ++++++ ++++++++++++++++++ .... ",
|
23
|
+
" ++++++ ++++++++++++++++++ .... ",
|
24
|
+
" ++++++ ++++++++++++++++++ .... ",
|
25
|
+
" ++++++ ++++++++++++++++++ .... ",
|
26
|
+
" ++++++ ++++++++++++++++++ ",
|
27
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
28
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
29
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
30
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
31
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
32
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
33
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
34
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
35
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
36
|
+
" ++++++ ++++ ",
|
37
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
38
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
39
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
40
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
41
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
42
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
43
|
+
" "
|
44
|
+
};
|
Binary file
|
@@ -0,0 +1,290 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
+
|
5
|
+
# RichTextCtrl sample by Chauk-Mean Proum
|
6
|
+
#
|
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.
|
18
|
+
#
|
19
|
+
# Icons are taken from the Tango Icon Theme.
|
20
|
+
# Disabled icons are created at runtime as darkened grayscale versions.
|
21
|
+
|
22
|
+
begin
|
23
|
+
require 'rubygems'
|
24
|
+
rescue LoadError
|
25
|
+
end
|
26
|
+
require 'wx'
|
27
|
+
|
28
|
+
class RichTextFrame < Wx::Frame
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
super( nil, :title => "RichTextCtrl Sample", :size => [900, 600] )
|
32
|
+
|
33
|
+
# Initialize the toolbar with standard actions
|
34
|
+
initialize_toolbar
|
35
|
+
|
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
|
48
|
+
|
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 )
|
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 --
|
63
|
+
|
64
|
+
# Apply / unapply bold to selection
|
65
|
+
evt_tool(Wx::ID_BOLD) do
|
66
|
+
@editor.apply_bold_to_selection
|
67
|
+
end
|
68
|
+
|
69
|
+
# Keep the pressed / unpressed state of the button in sync with the
|
70
|
+
# current selection in the text ctrl
|
71
|
+
evt_update_ui(Wx::ID_BOLD) do |evt|
|
72
|
+
evt.check(@editor.selection_bold?)
|
73
|
+
end
|
74
|
+
|
75
|
+
evt_tool(Wx::ID_ITALIC) do
|
76
|
+
@editor.apply_italic_to_selection
|
77
|
+
end
|
78
|
+
|
79
|
+
evt_update_ui(Wx::ID_ITALIC) do |evt|
|
80
|
+
evt.check(@editor.selection_italics?)
|
81
|
+
end
|
82
|
+
|
83
|
+
evt_tool(Wx::ID_UNDERLINE) do
|
84
|
+
@editor.apply_underline_to_selection
|
85
|
+
end
|
86
|
+
|
87
|
+
evt_update_ui(Wx::ID_UNDERLINE) do |evt|
|
88
|
+
evt.check(@editor.selection_underlined?)
|
89
|
+
end
|
90
|
+
|
91
|
+
evt_tool(Wx::ID_UNDO) do
|
92
|
+
@editor.undo
|
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 ]
|
144
|
+
end
|
145
|
+
|
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)
|
151
|
+
img_file = File.join( File.dirname(__FILE__), filename)
|
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}"
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
|
284
|
+
# The Application
|
285
|
+
Wx::App.run do
|
286
|
+
self.app_name = 'RichTextCtrl sample'
|
287
|
+
frame = RichTextFrame.new
|
288
|
+
frame.centre
|
289
|
+
frame.show
|
290
|
+
end
|