wxruby 1.9.0-i686-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wx.rb +35 -0
- data/lib/wx/classes/app.rb +25 -0
- data/lib/wx/classes/artprovider.rb +31 -0
- data/lib/wx/classes/bitmap.rb +23 -0
- data/lib/wx/classes/choice.rb +4 -0
- data/lib/wx/classes/clientdc.rb +13 -0
- data/lib/wx/classes/colour.rb +47 -0
- data/lib/wx/classes/combobox.rb +4 -0
- data/lib/wx/classes/evthandler.rb +824 -0
- data/lib/wx/classes/font.rb +118 -0
- data/lib/wx/classes/grid.rb +130 -0
- data/lib/wx/classes/helpcontroller.rb +5 -0
- data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
- data/lib/wx/classes/htmlwindow.rb +6 -0
- data/lib/wx/classes/icon.rb +14 -0
- data/lib/wx/classes/image.rb +14 -0
- data/lib/wx/classes/listbox.rb +4 -0
- data/lib/wx/classes/locale.rb +28 -0
- data/lib/wx/classes/object.rb +7 -0
- data/lib/wx/classes/paintdc.rb +12 -0
- data/lib/wx/classes/point.rb +5 -0
- data/lib/wx/classes/previewframe.rb +13 -0
- data/lib/wx/classes/rect.rb +5 -0
- data/lib/wx/classes/size.rb +5 -0
- data/lib/wx/classes/texturlevent.rb +6 -0
- data/lib/wx/classes/timer.rb +69 -0
- data/lib/wx/classes/window.rb +38 -0
- data/lib/wx/classes/xmlresource.rb +16 -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 +1352 -0
- data/samples/bigdemo/About.rbw +39 -0
- data/samples/bigdemo/ColorPanel.rbw +25 -0
- data/samples/bigdemo/GridSimple.rbw +80 -0
- data/samples/bigdemo/MDIDemo.rbw +59 -0
- data/samples/bigdemo/PopupMenu.rbw +151 -0
- data/samples/bigdemo/ShapedWindow.rbw +135 -0
- data/samples/bigdemo/Sizers.rbw +545 -0
- data/samples/bigdemo/bigdemo.rb +826 -0
- data/samples/bigdemo/demoTemplate.rbw +37 -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/ruby.png +0 -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/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 +94 -0
- data/samples/bigdemo/tips.txt +7 -0
- data/samples/bigdemo/utils.rb +12 -0
- data/samples/bigdemo/wxArtProvider.rbw +285 -0
- data/samples/bigdemo/wxBitmapButton.rbw +64 -0
- data/samples/bigdemo/wxButton.rbw +66 -0
- data/samples/bigdemo/wxCalendarCtrl.rbw +72 -0
- data/samples/bigdemo/wxCheckBox.rbw +52 -0
- data/samples/bigdemo/wxCheckListBox.rbw +77 -0
- data/samples/bigdemo/wxChoice.rbw +49 -0
- data/samples/bigdemo/wxChoicebook.rbw +80 -0
- data/samples/bigdemo/wxColourDialog.rbw +34 -0
- data/samples/bigdemo/wxComboBox.rbw +79 -0
- data/samples/bigdemo/wxCursor.rbw +140 -0
- data/samples/bigdemo/wxDialog.rbw +92 -0
- data/samples/bigdemo/wxDirDialog.rbw +32 -0
- data/samples/bigdemo/wxDragImage.rbw +74 -0
- data/samples/bigdemo/wxFileDialog.rbw +39 -0
- data/samples/bigdemo/wxFileDialog_Save.rbw +38 -0
- data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -0
- data/samples/bigdemo/wxFontDialog.rbw +176 -0
- data/samples/bigdemo/wxFrame.rbw +55 -0
- data/samples/bigdemo/wxGauge.rbw +73 -0
- data/samples/bigdemo/wxGenericDirCtrl.rbw +78 -0
- data/samples/bigdemo/wxGrid.rbw +68 -0
- data/samples/bigdemo/wxHtmlHelpController.rbw +57 -0
- data/samples/bigdemo/wxListBox.rbw +142 -0
- data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -0
- data/samples/bigdemo/wxMDIWindows.rbw +52 -0
- data/samples/bigdemo/wxMenu.rbw +238 -0
- data/samples/bigdemo/wxMessageDialog.rbw +30 -0
- data/samples/bigdemo/wxMiniFrame.rbw +74 -0
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -0
- data/samples/bigdemo/wxNotebook.rbw +138 -0
- data/samples/bigdemo/wxProgressDialog.rbw +45 -0
- data/samples/bigdemo/wxRadioBox.rbw +74 -0
- data/samples/bigdemo/wxRadioButton.rbw +127 -0
- data/samples/bigdemo/wxSashWindow.rbw +155 -0
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -0
- data/samples/bigdemo/wxScrolledWindow.rbw +196 -0
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -0
- data/samples/bigdemo/wxSlider.rbw +44 -0
- data/samples/bigdemo/wxSpinButton.rbw +52 -0
- data/samples/bigdemo/wxSpinCtrl.rbw +53 -0
- data/samples/bigdemo/wxSplitterWindow.rbw +65 -0
- data/samples/bigdemo/wxStaticBitmap.rbw +53 -0
- data/samples/bigdemo/wxStaticText.rbw +57 -0
- data/samples/bigdemo/wxStatusBar.rbw +128 -0
- data/samples/bigdemo/wxTextCtrl.rbw +151 -0
- data/samples/bigdemo/wxTextEntryDialog.rbw +34 -0
- data/samples/bigdemo/wxToggleButton.rbw +51 -0
- data/samples/bigdemo/wxToolBar.rbw +133 -0
- data/samples/bigdemo/wxTreeCtrl.rbw +192 -0
- data/samples/calendar/calendar.rb +275 -0
- data/samples/caret/caret.rb +296 -0
- data/samples/caret/mondrian.xpm +44 -0
- data/samples/controls/controls.rb +1140 -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 +724 -0
- data/samples/dialogs/tips.txt +18 -0
- data/samples/etc/activation.rb +108 -0
- data/samples/etc/choice.rb +72 -0
- data/samples/etc/miniframe.rb +84 -0
- data/samples/etc/sash.rb +135 -0
- data/samples/etc/scrollwin.rb +116 -0
- data/samples/etc/system_settings.rb +258 -0
- data/samples/etc/wizard.rb +81 -0
- data/samples/grid/grid.rb +201 -0
- data/samples/html/html.rb +251 -0
- data/samples/images/Thumbs.db +0 -0
- data/samples/images/images.rb +48 -0
- data/samples/images/paperclip.png +0 -0
- data/samples/listbook/listbook.rb +183 -0
- data/samples/listbook/listbook.xrc +370 -0
- data/samples/mdi/mdi.rb +87 -0
- data/samples/minimal/minimal.rb +95 -0
- data/samples/minimal/mondrian.ico +0 -0
- data/samples/minimal/mondrian.xpm +44 -0
- data/samples/minimal/nothing.rb +46 -0
- data/samples/minimal/text.rb +35 -0
- data/samples/printing/mondrian.ico +0 -0
- data/samples/printing/mondrian.xpm +44 -0
- data/samples/printing/printing.rb +484 -0
- data/samples/text/mondrian.ico +0 -0
- data/samples/text/mondrian.xpm +44 -0
- data/samples/text/scintilla.rb +180 -0
- data/samples/text/textctrl.rb +124 -0
- data/samples/text/unicode.rb +238 -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 +1210 -0
- data/samples/xrc/samples.xrc +46 -0
- data/samples/xrc/xrc_sample.rb +107 -0
- metadata +264 -0
@@ -0,0 +1,95 @@
|
|
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
|
+
load 'wx'
|
11
|
+
rescue
|
12
|
+
raise no_wx_err
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# The frame or self-contained window for this application
|
17
|
+
class MinimalFrame < Wx::Frame
|
18
|
+
def initialize(title, pos, size, style = Wx::DEFAULT_FRAME_STYLE)
|
19
|
+
|
20
|
+
# A main application frame has no parent (nil)
|
21
|
+
# -1 means this frame will be supplied a default id
|
22
|
+
super(nil, -1, title, pos, size, style)
|
23
|
+
|
24
|
+
# Set the frame's icon - use .ico on windows, else .xpm
|
25
|
+
if Wx::PLATFORM == "WXMSW"
|
26
|
+
set_icon( Wx::Icon.new(local_icon_file("mondrian.ico"),
|
27
|
+
Wx::BITMAP_TYPE_ICO) )
|
28
|
+
else
|
29
|
+
set_icon( Wx::Icon.new(local_icon_file("mondrian.xpm"),
|
30
|
+
Wx::BITMAP_TYPE_XPM) )
|
31
|
+
end
|
32
|
+
|
33
|
+
menu_file = Wx::Menu.new()
|
34
|
+
menu_help = Wx::Menu.new()
|
35
|
+
# Using Wx::ID_ABOUT default id means the menu item will be placed
|
36
|
+
# in the correct platform-specific place
|
37
|
+
menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
|
38
|
+
menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
|
39
|
+
menu_bar = Wx::MenuBar.new()
|
40
|
+
menu_bar.append(menu_file, "&File")
|
41
|
+
menu_bar.append(menu_help, "&Help")
|
42
|
+
# Assign the menus to this frame
|
43
|
+
set_menu_bar(menu_bar)
|
44
|
+
|
45
|
+
create_status_bar(2)
|
46
|
+
set_status_text("Welcome to wxRuby!")
|
47
|
+
|
48
|
+
# handle menu events
|
49
|
+
evt_menu(Wx::ID_EXIT) { on_quit }
|
50
|
+
evt_menu(Wx::ID_ABOUT) { on_about }
|
51
|
+
end
|
52
|
+
|
53
|
+
# End the application; it should finish automatically when the last
|
54
|
+
# window is closed.
|
55
|
+
def on_quit
|
56
|
+
close()
|
57
|
+
end
|
58
|
+
|
59
|
+
# show an 'About' dialog
|
60
|
+
def on_about
|
61
|
+
msg = sprintf("This is the About dialog of the minimal sample.\n" \
|
62
|
+
"Welcome to wxRuby, version %s", Wx::WXRUBY_VERSION)
|
63
|
+
|
64
|
+
# create a simple message dialog with OK button
|
65
|
+
about_dlg = Wx::MessageDialog.new( self, msg, 'About Minimal',
|
66
|
+
Wx::OK|Wx::ICON_INFORMATION )
|
67
|
+
about_dlg.show_modal
|
68
|
+
end
|
69
|
+
|
70
|
+
# utility function to find an icon relative to this ruby script
|
71
|
+
def local_icon_file(icon_name)
|
72
|
+
File.join( File.dirname(__FILE__), icon_name)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Wx::App is the container class for any wxruby app - only a single
|
77
|
+
# instance is required
|
78
|
+
class MinimalApp < Wx::App
|
79
|
+
# This method is called when main_loop is entered; it should set up
|
80
|
+
# the application's and display initial GUI windows.
|
81
|
+
def on_init
|
82
|
+
frame = MinimalFrame.new("Minimal wxRuby App",
|
83
|
+
Wx::Point.new(50, 50),
|
84
|
+
Wx::Size.new(450, 340))
|
85
|
+
set_app_name('Minimal')
|
86
|
+
# This is required, and on_init must return a true value else the
|
87
|
+
# app will not start
|
88
|
+
frame.show()
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Create an instance ...
|
93
|
+
app = MinimalApp.new
|
94
|
+
# ... and run the application
|
95
|
+
app.main_loop()
|
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
|
+
};
|
@@ -0,0 +1,46 @@
|
|
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
|
+
class MyFrame < Wx::Frame
|
17
|
+
def initialize(title)
|
18
|
+
super(nil, -1, title)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class NothingApp < Wx::App
|
23
|
+
def on_init
|
24
|
+
puts("in on_init")
|
25
|
+
$frame = MyFrame.new("Minimal wxRuby App")
|
26
|
+
puts("about to call show")
|
27
|
+
$frame.show
|
28
|
+
puts("returning from on_init")
|
29
|
+
return true
|
30
|
+
end
|
31
|
+
|
32
|
+
def on_fatal_exception
|
33
|
+
puts("on_fatal_exception")
|
34
|
+
end
|
35
|
+
|
36
|
+
def on_exit
|
37
|
+
puts("on_exit")
|
38
|
+
return super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
a = NothingApp.new
|
43
|
+
a.main_loop()
|
44
|
+
puts("back from main_loop...")
|
45
|
+
GC.start
|
46
|
+
puts("survived gc")
|
@@ -0,0 +1,35 @@
|
|
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
|
+
include Wx
|
16
|
+
|
17
|
+
class MyFrame < Frame
|
18
|
+
def initialize()
|
19
|
+
super(nil,-1,'test')
|
20
|
+
|
21
|
+
panel = self#Panel.new(self)
|
22
|
+
@m_spintext = TextCtrl.new( panel, -1, '')
|
23
|
+
#@m_spintext.destroy
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class RbApp < App
|
28
|
+
def on_init
|
29
|
+
frame = MyFrame.new
|
30
|
+
frame.show(TRUE)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
a = RbApp.new
|
35
|
+
a.main_loop()
|
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
|
+
};
|
@@ -0,0 +1,484 @@
|
|
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
|
+
require 'wx'
|
6
|
+
|
7
|
+
WXPRINT_QUIT = Wx::ID_EXIT
|
8
|
+
WXPRINT_PRINT = Wx::ID_PRINT
|
9
|
+
WXPRINT_PAGE_SETUP = Wx::ID_PRINT_SETUP
|
10
|
+
WXPRINT_PREVIEW = Wx::ID_PREVIEW
|
11
|
+
|
12
|
+
WXPRINT_PRINT_PS = 105
|
13
|
+
WXPRINT_PAGE_SETUP_PS = 107
|
14
|
+
WXPRINT_PREVIEW_PS = 108
|
15
|
+
|
16
|
+
WXPRINT_ABOUT = Wx::ID_ABOUT
|
17
|
+
|
18
|
+
WXPRINT_ANGLEUP = 110
|
19
|
+
WXPRINT_ANGLEDOWN = 111
|
20
|
+
|
21
|
+
class MyFrame < Wx::Frame
|
22
|
+
|
23
|
+
attr_accessor :canvas
|
24
|
+
|
25
|
+
def initialize(parent,title,pos,size)
|
26
|
+
super(parent,-1,title,pos,size)
|
27
|
+
@canvas = nil
|
28
|
+
@bitmap = Wx::Bitmap.new
|
29
|
+
@angle = 30
|
30
|
+
|
31
|
+
# map events
|
32
|
+
evt_menu(WXPRINT_QUIT) {|e| on_exit(e)}
|
33
|
+
evt_menu(WXPRINT_PRINT) {|e| on_print(e)}
|
34
|
+
evt_menu(WXPRINT_PREVIEW) {|e| on_print_preview(e)}
|
35
|
+
evt_menu(WXPRINT_PAGE_SETUP) {|e| on_page_setup(e)}
|
36
|
+
evt_menu(WXPRINT_ABOUT) {|e| on_print_about(e)}
|
37
|
+
evt_menu(WXPRINT_ANGLEUP) {|e| on_angle_up(e)}
|
38
|
+
evt_menu(WXPRINT_ANGLEDOWN) {|e| on_angle_down(e)}
|
39
|
+
end
|
40
|
+
|
41
|
+
def draw(dc)
|
42
|
+
dc.set_background(Wx::WHITE_BRUSH)
|
43
|
+
dc.clear()
|
44
|
+
dc.set_font(Wx::get_app.test_font)
|
45
|
+
|
46
|
+
dc.set_background_mode(Wx::TRANSPARENT)
|
47
|
+
|
48
|
+
dc.set_brush(Wx::CYAN_BRUSH)
|
49
|
+
dc.set_pen(Wx::RED_PEN)
|
50
|
+
|
51
|
+
dc.draw_rounded_rectangle(0, 20, 200, 80, 20)
|
52
|
+
|
53
|
+
dc.draw_text( "Rectangle 200 by 80", 40, 40)
|
54
|
+
|
55
|
+
dc.set_pen( Wx::Pen.new(Wx::BLACK,0,Wx::DOT_DASH) )
|
56
|
+
dc.draw_ellipse(50, 140, 100, 50)
|
57
|
+
dc.set_pen(Wx::RED_PEN)
|
58
|
+
|
59
|
+
dc.draw_text( "Test message: this is in 10 point text", 10, 180)
|
60
|
+
|
61
|
+
test = "Hebrew שלום -- Japanese (日本語)"
|
62
|
+
dc.draw_text( test, 10, 200 )
|
63
|
+
|
64
|
+
points = []
|
65
|
+
points << Wx::Point.new(0,0)
|
66
|
+
points << Wx::Point.new(20,0)
|
67
|
+
points << Wx::Point.new(20,20)
|
68
|
+
points << Wx::Point.new(10,20)
|
69
|
+
points << Wx::Point.new(10,-20)
|
70
|
+
|
71
|
+
dc.draw_polygon( points, 20, 250, Wx::ODDEVEN_RULE )
|
72
|
+
dc.draw_polygon( points, 50, 250, Wx::WINDING_RULE )
|
73
|
+
|
74
|
+
dc.draw_elliptic_arc( 80, 250, 60, 30, 0.0, 270.0 )
|
75
|
+
|
76
|
+
points[0].x = 150
|
77
|
+
points[0].y = 250
|
78
|
+
points[1].x = 180
|
79
|
+
points[1].y = 250
|
80
|
+
points[2].x = 180
|
81
|
+
points[2].y = 220
|
82
|
+
points[3].x = 200
|
83
|
+
points[3].y = 220
|
84
|
+
points.pop
|
85
|
+
dc.draw_spline( points )
|
86
|
+
|
87
|
+
dc.draw_arc( 20,10, 10,10, 25,40 )
|
88
|
+
|
89
|
+
str = ""
|
90
|
+
i = 0
|
91
|
+
str = "---- Text at angle #{i} ----"
|
92
|
+
dc.draw_rotated_text( str, 100, 300, i )
|
93
|
+
|
94
|
+
i = @angle;
|
95
|
+
str = "---- Text at angle #{i} ----"
|
96
|
+
dc.draw_rotated_text( str, 100, 300, i )
|
97
|
+
|
98
|
+
dc.set_pen(Wx::BLACK_PEN)
|
99
|
+
dc.draw_line(0, 0, 200, 200)
|
100
|
+
dc.draw_line(200, 0, 0, 200)
|
101
|
+
|
102
|
+
# Load icon
|
103
|
+
if Wx::PLATFORM == "WXMSW"
|
104
|
+
icon_file = File.join(File.dirname(__FILE__), 'mondrian.ico')
|
105
|
+
my_icon = Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_ICO)
|
106
|
+
else
|
107
|
+
icon_file = File.join(File.dirname(__FILE__), 'mondrian.xpm')
|
108
|
+
my_icon = Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_XPM)
|
109
|
+
end
|
110
|
+
|
111
|
+
dc.draw_icon( my_icon, 100, 100)
|
112
|
+
|
113
|
+
if @bitmap.is_ok
|
114
|
+
dc.draw_bitmap( @bitmap, 10, 10 )
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def on_angle_up(event)
|
119
|
+
@angle += 5
|
120
|
+
canvas.refresh
|
121
|
+
end
|
122
|
+
|
123
|
+
def on_angle_down(event)
|
124
|
+
@angle -= 5
|
125
|
+
canvas.refresh
|
126
|
+
end
|
127
|
+
|
128
|
+
def on_size(event)
|
129
|
+
super(event)
|
130
|
+
end
|
131
|
+
|
132
|
+
def on_print(event)
|
133
|
+
print_dialog_data = Wx::PrintDialogData.new(Wx::get_app.print_data)
|
134
|
+
|
135
|
+
printer = Wx::Printer.new(print_dialog_data)
|
136
|
+
printout = MyPrintout.new("My printout")
|
137
|
+
if (!printer.print(self, printout, true))
|
138
|
+
if (Wx::Printer.get_last_error == Wx::PRINTER_ERROR)
|
139
|
+
Wx::message_box("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", Wx::OK)
|
140
|
+
else
|
141
|
+
Wx::message_box("You canceled printing", "Printing", Wx::OK)
|
142
|
+
end
|
143
|
+
else
|
144
|
+
Wx::get_app.print_data = printer.get_print_dialog_data.get_print_data
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def on_print_preview(event)
|
149
|
+
# Pass two printout objects: for preview, and possible printing.
|
150
|
+
print_dialog_data = Wx::PrintDialogData.new(Wx::get_app.print_data)
|
151
|
+
preview = Wx::PrintPreview.new(MyPrintout.new, MyPrintout.new, print_dialog_data)
|
152
|
+
if not preview.is_ok
|
153
|
+
#delete preview;
|
154
|
+
Wx::message_box("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", Wx::OK)
|
155
|
+
return
|
156
|
+
end
|
157
|
+
|
158
|
+
prev_frame = Wx::PreviewFrame.new(preview, self, "Demo Print Preview", Wx::Point.new(100, 100), Wx::Size.new(600, 650))
|
159
|
+
prev_frame.centre(Wx::BOTH)
|
160
|
+
prev_frame.init
|
161
|
+
prev_frame.show
|
162
|
+
end
|
163
|
+
|
164
|
+
def on_page_setup(event)
|
165
|
+
Wx::get_app.page_setup_data = Wx::PageSetupDialogData.new(Wx::get_app.print_data)
|
166
|
+
page_setup_dialog = Wx::PageSetupDialog.new(self, Wx::get_app.page_setup_data)
|
167
|
+
page_setup_dialog.show_modal
|
168
|
+
|
169
|
+
Wx::get_app.print_data = page_setup_dialog.get_page_setup_data.get_print_data
|
170
|
+
Wx::get_app.page_setup_data = Wx::PageSetupDialogData.new(Wx::get_app.print_data)
|
171
|
+
end
|
172
|
+
|
173
|
+
def on_exit(event)
|
174
|
+
close(true)
|
175
|
+
end
|
176
|
+
|
177
|
+
def on_print_about(event)
|
178
|
+
Wx::message_box("wxWidgets printing demo\nAuthor: Julian Smart\nAdapted to wxRuby by Sean Long",
|
179
|
+
"About wxRuby printing demo", Wx::OK|Wx::CENTRE)
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
class MyCanvas < Wx::ScrolledWindow
|
185
|
+
#attr_accessor :frame
|
186
|
+
|
187
|
+
def initialize(parent,pos,size,style = Wx::RETAINED)
|
188
|
+
super(parent,-1,pos,size,style)
|
189
|
+
@frame = parent
|
190
|
+
set_background_colour(Wx::WHITE)
|
191
|
+
evt_mouse_events() {|e| on_event(e)}
|
192
|
+
end
|
193
|
+
|
194
|
+
def on_draw(dc)
|
195
|
+
@frame.draw(dc)
|
196
|
+
end
|
197
|
+
|
198
|
+
def on_event(event)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
class MyPrintout < Wx::Printout
|
203
|
+
def initialize(title = "My printout")
|
204
|
+
super(title)
|
205
|
+
end
|
206
|
+
|
207
|
+
def on_print_page(page)
|
208
|
+
dc = get_dc
|
209
|
+
if dc
|
210
|
+
if page == 1
|
211
|
+
draw_page_one(dc)
|
212
|
+
elsif (page == 2)
|
213
|
+
draw_page_two(dc)
|
214
|
+
end
|
215
|
+
dc.set_device_origin(0, 0)
|
216
|
+
dc.set_user_scale(1.0, 1.0)
|
217
|
+
|
218
|
+
buf = "PAGE #{page}"
|
219
|
+
dc.draw_text(buf, 10, 10)
|
220
|
+
|
221
|
+
return true
|
222
|
+
else
|
223
|
+
return false
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def on_begin_document(start_page,end_page)
|
228
|
+
go_ahead = super(start_page, end_page)
|
229
|
+
if (!go_ahead)
|
230
|
+
return false
|
231
|
+
end
|
232
|
+
return true
|
233
|
+
end
|
234
|
+
|
235
|
+
def has_page(page)
|
236
|
+
return (page == 1 || page == 2)
|
237
|
+
end
|
238
|
+
|
239
|
+
def get_page_info
|
240
|
+
min_page = 1
|
241
|
+
max_page = 2
|
242
|
+
sel_page_from = 1
|
243
|
+
sel_page_to = 2
|
244
|
+
[min_page,max_page,sel_page_from,sel_page_to]
|
245
|
+
end
|
246
|
+
|
247
|
+
def draw_page_one(dc)
|
248
|
+
# You might use THIS code if you were scaling
|
249
|
+
# graphics of known size to fit on the page.
|
250
|
+
|
251
|
+
# We know the graphic is 200x200. If we didn't know this,
|
252
|
+
# we'd need to calculate it.
|
253
|
+
max_x = 200
|
254
|
+
max_y = 200
|
255
|
+
|
256
|
+
# Let's have at least 50 device units margin
|
257
|
+
margin_x = 50
|
258
|
+
margin_y = 50
|
259
|
+
|
260
|
+
# Add the margin to the graphic size
|
261
|
+
max_x += (2*margin_x)
|
262
|
+
max_y += (2*margin_y)
|
263
|
+
|
264
|
+
# Get the size of the DC in pixels
|
265
|
+
size = dc.get_size
|
266
|
+
w = size.get_width
|
267
|
+
h = size.get_height
|
268
|
+
|
269
|
+
# Calculate a suitable scaling factor
|
270
|
+
scale_x=(w/max_x)
|
271
|
+
scale_y=(h/max_y)
|
272
|
+
|
273
|
+
# Use x or y scaling factor, whichever fits on the DC
|
274
|
+
#actualScale = Wx::min(scaleX,scaleY)
|
275
|
+
if scale_x < scale_y
|
276
|
+
actual_scale = scale_x
|
277
|
+
else
|
278
|
+
actual_scale = scale_y
|
279
|
+
end
|
280
|
+
|
281
|
+
# Calculate the position on the DC for centring the graphic
|
282
|
+
pos_x = ((w - (200*actual_scale))/2.0)
|
283
|
+
pos_y = ((h - (200*actual_scale))/2.0)
|
284
|
+
|
285
|
+
# Set the scale and origin
|
286
|
+
dc.set_user_scale(actual_scale, actual_scale)
|
287
|
+
dc.set_device_origin( pos_x.to_i, pos_y.to_i )
|
288
|
+
|
289
|
+
Wx::get_app.frame.draw(dc)
|
290
|
+
end
|
291
|
+
|
292
|
+
def draw_page_two(dc)
|
293
|
+
# You might use THIS code to set the printer DC to ROUGHLY reflect
|
294
|
+
# the screen text size. This page also draws lines of actual length
|
295
|
+
# 5cm on the page.
|
296
|
+
|
297
|
+
# Get the logical pixels per inch of screen and printer
|
298
|
+
ppi_screen_x, ppi_screen_y = get_ppi_screen
|
299
|
+
ppi_printer_x, ppi_printer_y = get_ppi_printer
|
300
|
+
|
301
|
+
# This scales the DC so that the printout roughly represents the
|
302
|
+
# the screen scaling. The text point size _should_ be the right size
|
303
|
+
# but in fact is too small for some reason. This is a detail that will
|
304
|
+
# need to be addressed at some point but can be fudged for the
|
305
|
+
# moment.
|
306
|
+
scale = ( ppi_printer_x.to_f / ppi_screen_x.to_f )
|
307
|
+
|
308
|
+
# Now we have to check in case our real page size is reduced
|
309
|
+
# (e.g. because we're drawing to a print preview memory DC)
|
310
|
+
page_width, page_height = get_page_size_pixels
|
311
|
+
size = dc.get_size
|
312
|
+
w = size.get_width
|
313
|
+
h = size.get_height
|
314
|
+
|
315
|
+
# If printer pageWidth == current DC width, then this doesn't
|
316
|
+
# change. But w might be the preview bitmap width, so scale down.
|
317
|
+
overall_scale = scale * (w/page_width)
|
318
|
+
dc.set_user_scale(overall_scale, overall_scale)
|
319
|
+
|
320
|
+
# Calculate conversion factor for converting millimetres into
|
321
|
+
# logical units.
|
322
|
+
# There are approx. 25.4 mm to the inch. There are ppi
|
323
|
+
# device units to the inch. Therefore 1 mm corresponds to
|
324
|
+
# ppi/25.4 device units. We also divide by the
|
325
|
+
# screen-to-printer scaling factor, because we need to
|
326
|
+
# unscale to pass logical units to DrawLine.
|
327
|
+
|
328
|
+
# Draw 50 mm by 50 mm L shape
|
329
|
+
log_units_factor = (ppi_printer_x/(scale*25.4))
|
330
|
+
log_units = (50*log_units_factor)
|
331
|
+
dc.set_pen(Wx::BLACK_PEN)
|
332
|
+
dc.draw_line(50, 250, (50.0 + log_units).to_i, 250)
|
333
|
+
dc.draw_line(50, 250, 50, (250.0 + log_units).to_i)
|
334
|
+
|
335
|
+
dc.set_background_mode(Wx::TRANSPARENT)
|
336
|
+
dc.set_brush(Wx::TRANSPARENT_BRUSH)
|
337
|
+
|
338
|
+
# GetTextExtent demo:
|
339
|
+
words = ["This ", "is ", "GetTextExtent ", "testing ", "string. ", "Enjoy ", "it!"]
|
340
|
+
w, h = 0,0
|
341
|
+
x = 200
|
342
|
+
y= 250
|
343
|
+
fnt = Wx::Font.new(15, Wx::SWISS, Wx::NORMAL, Wx::NORMAL)
|
344
|
+
|
345
|
+
dc.set_font(fnt)
|
346
|
+
|
347
|
+
words.each do |word|
|
348
|
+
w,h = dc.get_text_extent(word)
|
349
|
+
dc.draw_rectangle(x, y, w.to_i, h.to_i)
|
350
|
+
w,h = dc.get_text_extent(word)
|
351
|
+
dc.draw_text(word, x, y)
|
352
|
+
x += w
|
353
|
+
end
|
354
|
+
|
355
|
+
dc.set_font(Wx::get_app.test_font)
|
356
|
+
|
357
|
+
dc.draw_text("Some test text", 200, 300 )
|
358
|
+
|
359
|
+
left_margin = 20
|
360
|
+
right_margin = 20
|
361
|
+
top_margin = 20
|
362
|
+
bottom_margin = 20
|
363
|
+
|
364
|
+
page_width_mm, page_height_mm = get_page_size_mm
|
365
|
+
|
366
|
+
left_margin_logical = (log_units_factor*left_margin).to_i
|
367
|
+
top_margin_logical = (log_units_factor*top_margin).to_i
|
368
|
+
bottom_margin_logical = (log_units_factor*(page_height_mm - bottom_margin)).to_i
|
369
|
+
right_margin_logical = (log_units_factor*(page_width_mm - right_margin)).to_i
|
370
|
+
|
371
|
+
dc.set_pen(Wx::RED_PEN)
|
372
|
+
dc.draw_line( left_margin_logical, top_margin_logical,
|
373
|
+
right_margin_logical, top_margin_logical)
|
374
|
+
dc.draw_line( left_margin_logical, bottom_margin_logical,
|
375
|
+
right_margin_logical, bottom_margin_logical)
|
376
|
+
|
377
|
+
write_page_header(self, dc, "A header", log_units_factor)
|
378
|
+
end
|
379
|
+
|
380
|
+
# Writes a header on a page. Margin units are in millimetres.
|
381
|
+
def write_page_header(printout, dc, text, mm_to_logical)
|
382
|
+
page_width_mm, page_height_mm = printout.get_page_size_mm
|
383
|
+
|
384
|
+
left_margin = 10
|
385
|
+
top_margin = 10
|
386
|
+
right_margin = 10
|
387
|
+
|
388
|
+
left_margin_logical = (mm_to_logical*left_margin).to_i
|
389
|
+
top_margin_logical = (mm_to_logical*top_margin).to_i
|
390
|
+
right_margin_logical = (mm_to_logical*(page_width_mm - right_margin)).to_i
|
391
|
+
|
392
|
+
x_extent, y_extent= dc.get_text_extent(text)
|
393
|
+
x_pos = (((((page_width_mm - left_margin - right_margin)/2.0)+left_margin)*mm_to_logical) - (x_extent/2.0))
|
394
|
+
dc.draw_text(text, x_pos.to_i, top_margin_logical)
|
395
|
+
|
396
|
+
dc.set_pen(Wx::BLACK_PEN)
|
397
|
+
dc.draw_line( left_margin_logical, (top_margin_logical + y_extent).to_i,
|
398
|
+
right_margin_logical, (top_margin_logical + y_extent).to_i )
|
399
|
+
|
400
|
+
return true
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
class MyApp < Wx::App
|
405
|
+
attr_accessor :frame,:test_font,:print_data,:page_setup_data
|
406
|
+
|
407
|
+
def on_init
|
408
|
+
@test_font = Wx::Font.new(10, Wx::SWISS, Wx::NORMAL, Wx::NORMAL)
|
409
|
+
|
410
|
+
# Create the main frame window
|
411
|
+
@frame = MyFrame.new(nil, "wxRuby Printing Demo", Wx::Point.new(0, 0), Wx::Size.new(400, 400))
|
412
|
+
|
413
|
+
# Give it a status line
|
414
|
+
@frame.create_status_bar(2)
|
415
|
+
|
416
|
+
|
417
|
+
# Load icon and bitmap
|
418
|
+
if Wx::PLATFORM == "WXMSW"
|
419
|
+
icon_file = File.join(File.dirname(__FILE__), 'mondrian.ico')
|
420
|
+
@frame.set_icon( Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_ICO) )
|
421
|
+
else
|
422
|
+
icon_file = File.join(File.dirname(__FILE__), 'mondrian.xpm')
|
423
|
+
@frame.set_icon( Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_XPM) )
|
424
|
+
end
|
425
|
+
|
426
|
+
# Make a menubar
|
427
|
+
file_menu = Wx::Menu.new
|
428
|
+
|
429
|
+
file_menu.append(WXPRINT_PRINT, "&Print...","Print")
|
430
|
+
file_menu.append(WXPRINT_PAGE_SETUP, "Page Set&up...","Page setup")
|
431
|
+
file_menu.append(WXPRINT_PREVIEW, "Print Pre&view","Preview")
|
432
|
+
|
433
|
+
=begin
|
434
|
+
# Accelerators
|
435
|
+
wxAcceleratorEntry entries[1];
|
436
|
+
entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW);
|
437
|
+
wxAcceleratorTable accel(1, entries);
|
438
|
+
frame->SetAcceleratorTable(accel);
|
439
|
+
=end
|
440
|
+
|
441
|
+
file_menu.append_separator()
|
442
|
+
file_menu.append(WXPRINT_ANGLEUP, "Angle up\tAlt-U","Raise rotated text angle")
|
443
|
+
file_menu.append(WXPRINT_ANGLEDOWN, "Angle down\tAlt-D","Lower rotated text angle")
|
444
|
+
file_menu.append_separator()
|
445
|
+
file_menu.append(WXPRINT_QUIT, "E&xit","Exit program")
|
446
|
+
|
447
|
+
help_menu = Wx::Menu.new
|
448
|
+
help_menu.append(WXPRINT_ABOUT, "&About","About this demo")
|
449
|
+
|
450
|
+
menu_bar = Wx::MenuBar.new
|
451
|
+
|
452
|
+
menu_bar.append(file_menu, "&File")
|
453
|
+
menu_bar.append(help_menu, "&Help")
|
454
|
+
|
455
|
+
# Associate the menu bar with the frame
|
456
|
+
@frame.set_menu_bar(menu_bar)
|
457
|
+
|
458
|
+
canvas = MyCanvas.new(@frame, Wx::Point.new(0, 0), Wx::Size.new(100, 100), Wx::RETAINED|Wx::HSCROLL|Wx::VSCROLL)
|
459
|
+
|
460
|
+
# Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction
|
461
|
+
canvas.set_scrollbars(20, 20, 50, 50)
|
462
|
+
|
463
|
+
@frame.canvas = canvas
|
464
|
+
|
465
|
+
@frame.centre(Wx::BOTH)
|
466
|
+
@frame.show()
|
467
|
+
|
468
|
+
@frame.set_status_text("Printing demo")
|
469
|
+
|
470
|
+
set_top_window(@frame)
|
471
|
+
|
472
|
+
@print_data = Wx::PrintData.new
|
473
|
+
@page_setup_data = Wx::PageSetupDialogData.new
|
474
|
+
|
475
|
+
return true
|
476
|
+
end
|
477
|
+
|
478
|
+
def on_exit
|
479
|
+
return true
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
|
484
|
+
MyApp.new.main_loop()
|