wxruby 1.9.2-i686-darwin8.8.2
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 +42 -0
- data/lib/wx/accessors.rb +52 -0
- data/lib/wx/classes/app.rb +39 -0
- data/lib/wx/classes/artprovider.rb +31 -0
- data/lib/wx/classes/bitmap.rb +23 -0
- data/lib/wx/classes/checklistbox.rb +30 -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/commandevent.rb +7 -0
- data/lib/wx/classes/controlwithitems.rb +10 -0
- data/lib/wx/classes/evthandler.rb +884 -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/listctrl.rb +9 -0
- data/lib/wx/classes/locale.rb +28 -0
- data/lib/wx/classes/menu.rb +62 -0
- data/lib/wx/classes/menuitem.rb +7 -0
- data/lib/wx/classes/object.rb +7 -0
- data/lib/wx/classes/paintdc.rb +12 -0
- data/lib/wx/classes/point.rb +48 -0
- data/lib/wx/classes/previewframe.rb +13 -0
- data/lib/wx/classes/rect.rb +5 -0
- data/lib/wx/classes/size.rb +49 -0
- data/lib/wx/classes/styledtextctrl.rb +92 -0
- data/lib/wx/classes/textctrl.rb +14 -0
- data/lib/wx/classes/texturlevent.rb +6 -0
- data/lib/wx/classes/timer.rb +69 -0
- data/lib/wx/classes/treectrl.rb +18 -0
- data/lib/wx/classes/window.rb +49 -0
- data/lib/wx/classes/xmlresource.rb +16 -0
- data/lib/wx/keyword_ctors.rb +205 -0
- data/lib/wx/keyword_defs.rb +465 -0
- data/lib/wx/version.rb +3 -0
- data/lib/wxruby2.bundle +0 -0
- data/samples/SAMPLES-LICENSE.TXT +18 -0
- data/samples/aui/aui.rb +1353 -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 +201 -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 +286 -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/threaded.rb +81 -0
- data/samples/etc/wizard.rb +79 -0
- data/samples/event/event.rb +184 -0
- data/samples/grid/grid.rb +201 -0
- data/samples/html/html.rb +264 -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 +181 -0
- data/samples/listbook/listbook.xrc +370 -0
- data/samples/mdi/mdi.rb +87 -0
- data/samples/minimal/minimal.rb +85 -0
- data/samples/minimal/mondrian.ico +0 -0
- data/samples/minimal/mondrian.png +0 -0
- data/samples/minimal/nothing.rb +21 -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 +174 -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 +1181 -0
- data/samples/xrc/samples.xrc +46 -0
- data/samples/xrc/xrc_sample.rb +107 -0
- metadata +280 -0
data/samples/mdi/mdi.rb
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
# MDI sample for wxRuby
|
|
17
|
+
# slapped together quickly by Kevin Smith
|
|
18
|
+
|
|
19
|
+
ID_NEXT = 1
|
|
20
|
+
ID_PREVIOUS = 2
|
|
21
|
+
ID_CASCADE = 3
|
|
22
|
+
ID_TILE = 4
|
|
23
|
+
ID_CREATE = 5
|
|
24
|
+
ID_CLOSE = 6
|
|
25
|
+
ID_EXIT = 99
|
|
26
|
+
|
|
27
|
+
class MyFrame < Wx::MDIParentFrame
|
|
28
|
+
def initialize(title)
|
|
29
|
+
super(nil, -1, title,Wx::DEFAULT_POSITION,Wx::Size.new(500,400))
|
|
30
|
+
|
|
31
|
+
@child_number = 0
|
|
32
|
+
|
|
33
|
+
menuFile = Wx::Menu.new
|
|
34
|
+
menuFile.append(ID_EXIT, "E&xit\tAlt-X")
|
|
35
|
+
menuMDI = Wx::Menu.new
|
|
36
|
+
menuMDI.append(ID_NEXT, "&Next Child\tCtrl-F6")
|
|
37
|
+
menuMDI.append(ID_PREVIOUS, "&Previous Child")
|
|
38
|
+
menuMDI.append_separator()
|
|
39
|
+
menuMDI.append(ID_CASCADE, "&Cascade")
|
|
40
|
+
menuMDI.append(ID_TILE, "&Tile")
|
|
41
|
+
menuMDI.append_separator()
|
|
42
|
+
menuMDI.append(ID_CREATE, "&Add Child")
|
|
43
|
+
menuMDI.append(ID_CLOSE, "&Remove Child\tCtrl-F4")
|
|
44
|
+
menuBar = Wx::MenuBar.new
|
|
45
|
+
menuBar.append(menuFile, "&File")
|
|
46
|
+
menuBar.append(menuMDI, "&Window")
|
|
47
|
+
set_menu_bar(menuBar)
|
|
48
|
+
|
|
49
|
+
evt_menu(ID_EXIT) { close }
|
|
50
|
+
evt_menu(ID_NEXT) { activate_next }
|
|
51
|
+
evt_menu(ID_PREVIOUS) { activate_previous }
|
|
52
|
+
evt_menu(ID_CASCADE) { cascade }
|
|
53
|
+
evt_menu(ID_TILE) { tile }
|
|
54
|
+
evt_menu(ID_CREATE) { create_child }
|
|
55
|
+
evt_menu(ID_CLOSE) { on_close_child }
|
|
56
|
+
|
|
57
|
+
create_status_bar(2).set_status_widths([100, -1])
|
|
58
|
+
set_status_text("Some features only work on MS Windows", 1)
|
|
59
|
+
|
|
60
|
+
create_child
|
|
61
|
+
create_child
|
|
62
|
+
create_child
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def on_close_child
|
|
66
|
+
active = get_active_child
|
|
67
|
+
if(active)
|
|
68
|
+
active.close
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def create_child
|
|
73
|
+
@child_number += 1
|
|
74
|
+
name = "Child #{@child_number.to_s}"
|
|
75
|
+
Wx::MDIChildFrame.new(self, -1, name)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
class NothingApp < Wx::App
|
|
80
|
+
def on_init
|
|
81
|
+
frame = MyFrame.new("MDI App")
|
|
82
|
+
frame.show
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
a = NothingApp.new
|
|
87
|
+
a.main_loop()
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
# This sample shows a fairly minimal Wx::App using a Frame, with a
|
|
17
|
+
# MenuBar and StatusBar but no controls. For the absolute minimum app,
|
|
18
|
+
# see nothing.rb
|
|
19
|
+
|
|
20
|
+
# A Wx::Frame is a self-contained, top-level Window that can contain
|
|
21
|
+
# controls, menubars, and statusbars
|
|
22
|
+
class MinimalFrame < Wx::Frame
|
|
23
|
+
def initialize(title)
|
|
24
|
+
# The main application frame has no parent (nil)
|
|
25
|
+
super(nil, :title => title, :size => [ 400, 300 ])
|
|
26
|
+
|
|
27
|
+
icon_file = File.join( File.dirname(__FILE__), "mondrian.png")
|
|
28
|
+
# PNG can be used on all platforms, but icon type must be specified
|
|
29
|
+
# to work on Windows; OS X doesn't have "Frame" icons.
|
|
30
|
+
self.icon = Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_PNG)
|
|
31
|
+
|
|
32
|
+
menu_bar = Wx::MenuBar.new
|
|
33
|
+
# The "file" menu
|
|
34
|
+
menu_file = Wx::Menu.new
|
|
35
|
+
menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
|
|
36
|
+
menu_bar.append(menu_file, "&File")
|
|
37
|
+
|
|
38
|
+
# The "help" menu
|
|
39
|
+
menu_help = Wx::Menu.new
|
|
40
|
+
# Using Wx::ID_ABOUT default id means the menu item will be placed
|
|
41
|
+
# in the correct platform-specific place - eg on OS X
|
|
42
|
+
menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
|
|
43
|
+
menu_bar.append(menu_help, "&Help")
|
|
44
|
+
|
|
45
|
+
# Assign the menubar to this frame
|
|
46
|
+
self.menu_bar = menu_bar
|
|
47
|
+
|
|
48
|
+
# Create a status bar
|
|
49
|
+
create_status_bar(2)
|
|
50
|
+
self.status_text = "Welcome to wxRuby!"
|
|
51
|
+
|
|
52
|
+
# Set it up to handle menu events using the relevant methods
|
|
53
|
+
evt_menu Wx::ID_EXIT, :on_quit
|
|
54
|
+
evt_menu Wx::ID_ABOUT, :on_about
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# End the application; it should finish automatically when the last
|
|
58
|
+
# window is closed.
|
|
59
|
+
def on_quit
|
|
60
|
+
close()
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# show an 'About' dialog
|
|
64
|
+
def on_about
|
|
65
|
+
msg = sprintf("This is the About dialog of the minimal sample.\n" \
|
|
66
|
+
"Welcome to wxRuby, version %s", Wx::WXRUBY_VERSION)
|
|
67
|
+
|
|
68
|
+
# create a simple message dialog with OK button
|
|
69
|
+
about_dlg = Wx::MessageDialog.new( self, msg, 'About Minimal',
|
|
70
|
+
Wx::OK|Wx::ICON_INFORMATION )
|
|
71
|
+
# Display the dialog on top of and blocking other windows, until
|
|
72
|
+
# dismissed by clicking the 'OK' button
|
|
73
|
+
about_dlg.show_modal
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Wx::App is the container class for any wxruby app. To start an
|
|
78
|
+
# application, either define a subclass of Wx::App, create an instance,
|
|
79
|
+
# and call its main_loop method, OR, simply call the Wx::App.run class
|
|
80
|
+
# method, as shown here.
|
|
81
|
+
Wx::App.run do
|
|
82
|
+
self.app_name = 'Minimal'
|
|
83
|
+
frame = MinimalFrame.new("Minimal wxRuby App")
|
|
84
|
+
frame.show
|
|
85
|
+
end
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
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 is the minimum code to start a WxRuby app - create a Frame, and
|
|
17
|
+
# show it.
|
|
18
|
+
Wx::App.run do
|
|
19
|
+
frame = Wx::Frame.new(nil, :title => "Minimal wxRuby App")
|
|
20
|
+
frame.show
|
|
21
|
+
end
|
|
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()
|