wxruby 1.9.5-i386-mswin32 → 1.9.7-i386-mswin32
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/lib/wx/classes/acceleratortable.rb +28 -0
- data/lib/wx/classes/animation.rb +18 -0
- data/lib/wx/classes/bitmap.rb +5 -0
- data/lib/wx/classes/busycursor.rb +12 -0
- data/lib/wx/classes/evthandler.rb +36 -21
- data/lib/wx/classes/functions.rb +44 -0
- data/lib/wx/classes/grid.rb +16 -7
- data/lib/wx/classes/htmlwindow.rb +8 -0
- data/lib/wx/classes/icon.rb +7 -0
- data/lib/wx/classes/iconbundle.rb +3 -0
- data/lib/wx/classes/image.rb +17 -0
- data/lib/wx/classes/imagelist.rb +3 -0
- data/lib/wx/classes/toolbartool.rb +4 -0
- data/lib/wx/classes/xmlresource.rb +21 -0
- data/lib/wx/keyword_ctors.rb +9 -6
- data/lib/wx/keyword_defs.rb +7 -0
- data/lib/wx/version.rb +1 -1
- data/lib/wxruby2.exp +0 -0
- data/lib/wxruby2.lib +0 -0
- data/lib/wxruby2.so +0 -0
- data/samples/aui/aui.rb +6 -10
- data/samples/bigdemo/ColorPanel.rbw +7 -9
- data/samples/bigdemo/GridSimple.rbw +7 -9
- data/samples/bigdemo/MDIDemo.rbw +7 -9
- data/samples/bigdemo/PopupMenu.rbw +7 -9
- data/samples/bigdemo/ShapedWindow.rbw +6 -10
- data/samples/bigdemo/Sizers.rbw +7 -9
- data/samples/bigdemo/bigdemo.rb +24 -25
- data/samples/bigdemo/demoTemplate.rbw +6 -10
- data/samples/bigdemo/run.rb +6 -10
- data/samples/bigdemo/wxArtProvider.rbw +6 -10
- data/samples/bigdemo/wxBitmapButton.rbw +42 -41
- data/samples/bigdemo/wxButton.rbw +7 -9
- data/samples/bigdemo/wxCalendarCtrl.rbw +41 -53
- data/samples/bigdemo/wxCheckBox.rbw +7 -9
- data/samples/bigdemo/wxCheckListBox.rbw +7 -9
- data/samples/bigdemo/wxChoice.rbw +7 -9
- data/samples/bigdemo/wxChoicebook.rbw +7 -9
- data/samples/bigdemo/wxColourDialog.rbw +7 -10
- data/samples/bigdemo/wxComboBox.rbw +7 -9
- data/samples/bigdemo/wxCursor.rbw +6 -10
- data/samples/bigdemo/wxDialog.rbw +7 -9
- data/samples/bigdemo/wxDirDialog.rbw +7 -10
- data/samples/bigdemo/wxDragImage.rbw +6 -10
- data/samples/bigdemo/wxFileDialog.rbw +7 -9
- data/samples/bigdemo/wxFileDialog_Save.rbw +7 -10
- data/samples/bigdemo/wxFindReplaceDialog.rbw +7 -10
- data/samples/bigdemo/wxFontDialog.rbw +7 -10
- data/samples/bigdemo/wxFrame.rbw +7 -9
- data/samples/bigdemo/wxGauge.rbw +7 -9
- data/samples/bigdemo/wxGenericDirCtrl.rbw +6 -10
- data/samples/bigdemo/wxGrid.rbw +7 -9
- data/samples/bigdemo/wxHtmlHelpController.rbw +6 -11
- data/samples/bigdemo/wxListBox.rbw +7 -9
- data/samples/bigdemo/wxListCtrl_virtual.rbw +7 -9
- data/samples/bigdemo/wxMDIWindows.rbw +7 -9
- data/samples/bigdemo/wxMenu.rbw +7 -9
- data/samples/bigdemo/wxMessageDialog.rbw +7 -10
- data/samples/bigdemo/wxMiniFrame.rbw +6 -10
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +7 -9
- data/samples/bigdemo/wxNotebook.rbw +7 -9
- data/samples/bigdemo/wxProgressDialog.rbw +7 -9
- data/samples/bigdemo/wxRadioBox.rbw +7 -9
- data/samples/bigdemo/wxRadioButton.rbw +7 -9
- data/samples/bigdemo/wxSashWindow.rbw +6 -10
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +7 -9
- data/samples/bigdemo/wxScrolledWindow.rbw +7 -9
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +7 -9
- data/samples/bigdemo/wxSlider.rbw +7 -9
- data/samples/bigdemo/wxSpinButton.rbw +7 -9
- data/samples/bigdemo/wxSpinCtrl.rbw +7 -9
- data/samples/bigdemo/wxSplitterWindow.rbw +7 -9
- data/samples/bigdemo/wxStaticBitmap.rbw +7 -9
- data/samples/bigdemo/wxStaticText.rbw +7 -9
- data/samples/bigdemo/wxStatusBar.rbw +7 -9
- data/samples/bigdemo/wxTextCtrl.rbw +7 -9
- data/samples/bigdemo/wxTextEntryDialog.rbw +7 -10
- data/samples/bigdemo/wxToggleButton.rbw +7 -9
- data/samples/bigdemo/wxToolBar.rbw +7 -9
- data/samples/bigdemo/wxTreeCtrl.rbw +7 -9
- data/samples/calendar/calendar.rb +6 -10
- data/samples/caret/caret.rb +6 -10
- data/samples/controls/controls.rb +6 -10
- data/samples/dialogs/dialogs.rb +10 -11
- data/samples/dragdrop/dragdrop.rb +177 -0
- data/samples/drawing/graphics_drawing.rb +6 -7
- data/samples/drawing/images.rb +5 -10
- data/samples/etc/activation.rb +4 -10
- data/samples/etc/choice.rb +5 -10
- data/samples/etc/miniframe.rb +5 -10
- data/samples/etc/sash.rb +5 -10
- data/samples/etc/scrollwin.rb +4 -10
- data/samples/etc/system_settings.rb +4 -10
- data/samples/etc/threaded.rb +4 -10
- data/samples/etc/wizard.rb +5 -10
- data/samples/event/event.rb +3 -5
- data/samples/grid/grid.rb +5 -9
- data/samples/grid/gridtablebase.rb +134 -0
- data/samples/html/html.rb +4 -10
- data/samples/listbook/listbook.rb +4 -11
- data/samples/mdi/mdi.rb +5 -10
- data/samples/media/mediactrl.rb +4 -10
- data/samples/minimal/minimal.rb +18 -26
- data/samples/minimal/nothing.rb +5 -10
- data/samples/opengl/cube.rb +8 -14
- data/samples/printing/printing.rb +5 -179
- data/samples/text/scintilla.rb +5 -10
- data/samples/text/textctrl.rb +27 -38
- data/samples/text/unicode.rb +6 -2
- data/samples/treectrl/treectrl.rb +4 -10
- data/samples/xrc/xrc_sample.rb +6 -17
- metadata +12 -2
@@ -0,0 +1,134 @@
|
|
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
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
require 'wx'
|
9
|
+
|
10
|
+
# GridTableBase is an alternative way to provide data to a Wx::Grid. A
|
11
|
+
# subclass of Wx::GridTableBase is created which is reqiured to provide
|
12
|
+
# methods to report the total size of the Grid in rows and columns, and
|
13
|
+
# the contents and style of individual cells.
|
14
|
+
#
|
15
|
+
# Then, when creating the Grid, instead of calling create_grid and
|
16
|
+
# set_value to populate it, the GridTableBase-derived class is
|
17
|
+
# associated with the Grid, and provides these functions (see below)
|
18
|
+
#
|
19
|
+
# This approach is typically useful for dealing with very large sets of
|
20
|
+
# data, as each cell's value is only requested as it becomes visible.v
|
21
|
+
class MyGridTable < Wx::GridTableBase
|
22
|
+
attr_reader :cols, :rows
|
23
|
+
def initialize(rows, cols)
|
24
|
+
super()
|
25
|
+
@rows = rows
|
26
|
+
@cols = cols
|
27
|
+
@val = 'a'
|
28
|
+
end
|
29
|
+
|
30
|
+
# Firstly, a GridTableBase must indicate the size of the grid in
|
31
|
+
# terms of rows ...
|
32
|
+
def get_number_rows
|
33
|
+
@rows
|
34
|
+
end
|
35
|
+
|
36
|
+
# ... and columns
|
37
|
+
def get_number_cols
|
38
|
+
@cols
|
39
|
+
end
|
40
|
+
|
41
|
+
# Most importantly, it should be able to return any given cell's
|
42
|
+
# contents, given its row and column reference
|
43
|
+
def get_value(row, col)
|
44
|
+
"#{@val} - #{row}"
|
45
|
+
end
|
46
|
+
|
47
|
+
# It should also return the attributes that should apply to any given
|
48
|
+
# cell; this example give alternate rows red text letters
|
49
|
+
def get_attr(row, col, attr_kind)
|
50
|
+
attr = Wx::GridCellAttr.new
|
51
|
+
if (row % 2).zero?
|
52
|
+
attr.text_colour = Wx::RED
|
53
|
+
end
|
54
|
+
attr
|
55
|
+
end
|
56
|
+
|
57
|
+
# It should indicate whether any given cell is empty
|
58
|
+
def is_empty_cell(row, col)
|
59
|
+
false
|
60
|
+
end
|
61
|
+
|
62
|
+
# It may also provide labels for the columns and rows
|
63
|
+
def get_col_label_value(col)
|
64
|
+
"Col: #{col}"
|
65
|
+
end
|
66
|
+
|
67
|
+
# If the Grid is to support write as well as read operations,
|
68
|
+
# set_value should also be implemented. In this case, the change is
|
69
|
+
# merely echoed back and doesn't alter the underlying value; a real
|
70
|
+
# implementation could, for example, write back to a database
|
71
|
+
def set_value(x, y, val)
|
72
|
+
puts "Changing the value of cell (#{x}, #{y}) to '#{val}'"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# A derivative class illustrating that it is possible to change
|
77
|
+
# parameters of the GridTable and have the main control update.
|
78
|
+
class MyMutableGridTable < MyGridTable
|
79
|
+
def increment_value
|
80
|
+
@val = @val.succ
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
class GridFrame < Wx::Frame
|
86
|
+
def initialize()
|
87
|
+
super(nil, :title => 'GridTableBase demo')
|
88
|
+
main_sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
89
|
+
# Create a grid and associate an instance of the GridTable as the
|
90
|
+
# data provider for the grid
|
91
|
+
@grid = Wx::Grid.new(self)
|
92
|
+
@grid.table = MyMutableGridTable.new(10, 10)
|
93
|
+
|
94
|
+
main_sizer.add(@grid, 1, Wx::EXPAND|Wx::ALL, 5)
|
95
|
+
|
96
|
+
# Add some buttons that can change the contents
|
97
|
+
butt_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)
|
98
|
+
|
99
|
+
butt_1 = Wx::Button.new(self, :label => "Add row")
|
100
|
+
# When resizing the grid to have a new number of rows or columns,
|
101
|
+
# need to allocate a new grid table source
|
102
|
+
evt_button(butt_1) do
|
103
|
+
@grid.table = MyMutableGridTable.new( @grid.table.rows + 1,
|
104
|
+
@grid.table.cols)
|
105
|
+
@grid.refresh
|
106
|
+
end
|
107
|
+
butt_sizer.add(butt_1)
|
108
|
+
|
109
|
+
butt_2 = Wx::Button.new(self, :label => "Add column")
|
110
|
+
evt_button(butt_2) do
|
111
|
+
@grid.table = MyMutableGridTable.new( @grid.table.rows,
|
112
|
+
@grid.table.cols + 1)
|
113
|
+
@grid.refresh
|
114
|
+
end
|
115
|
+
butt_sizer.add(butt_2)
|
116
|
+
|
117
|
+
# For other changes, can just change a value in the existing
|
118
|
+
# GridTable
|
119
|
+
butt_3 = Wx::Button.new(self, :label => "Increment letter")
|
120
|
+
evt_button(butt_3) do
|
121
|
+
@grid.table.increment_value
|
122
|
+
@grid.refresh
|
123
|
+
end
|
124
|
+
butt_sizer.add(butt_3)
|
125
|
+
|
126
|
+
main_sizer.add(butt_sizer, 0, Wx::EXPAND|Wx::ALL, 5)
|
127
|
+
self.sizer = main_sizer
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
Wx::App.run do
|
132
|
+
GridFrame.new.show
|
133
|
+
end
|
134
|
+
|
data/samples/html/html.rb
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
3
|
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
|
5
4
|
begin
|
6
|
-
require '
|
7
|
-
rescue LoadError
|
8
|
-
begin
|
9
|
-
require 'rubygems'
|
10
|
-
require 'wx'
|
11
|
-
rescue LoadError
|
12
|
-
raise no_wx_err
|
13
|
-
end
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
14
7
|
end
|
8
|
+
require 'wx'
|
15
9
|
|
16
10
|
require 'net/http'
|
17
11
|
require 'uri'
|
@@ -1,19 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
3
|
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
|
5
4
|
begin
|
6
|
-
require '
|
7
|
-
rescue LoadError
|
8
|
-
begin
|
9
|
-
require 'rubygems'
|
10
|
-
require 'wx'
|
11
|
-
rescue LoadError
|
12
|
-
raise no_wx_err
|
13
|
-
end
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
14
7
|
end
|
8
|
+
require 'wx'
|
15
9
|
|
16
|
-
#
|
17
10
|
# Basic Frame Class. This creates the dialog window
|
18
11
|
#
|
19
12
|
class SimpleFrame < Wx::Frame
|
data/samples/mdi/mdi.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
3
|
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
|
5
4
|
begin
|
6
|
-
require '
|
7
|
-
rescue LoadError
|
8
|
-
begin
|
9
|
-
require 'rubygems'
|
10
|
-
require 'wx'
|
11
|
-
rescue LoadError
|
12
|
-
raise no_wx_err
|
13
|
-
end
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
14
7
|
end
|
8
|
+
require 'wx'
|
9
|
+
|
15
10
|
|
16
11
|
# MDI sample for wxRuby
|
17
12
|
# slapped together quickly by Kevin Smith
|
data/samples/media/mediactrl.rb
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code.
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
3
|
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
|
5
4
|
begin
|
6
|
-
require '
|
7
|
-
rescue LoadError
|
8
|
-
begin
|
9
|
-
require 'rubygems'
|
10
|
-
require 'wx'
|
11
|
-
rescue LoadError
|
12
|
-
raise no_wx_err
|
13
|
-
end
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
14
7
|
end
|
8
|
+
require 'wx'
|
15
9
|
|
16
10
|
# This sample demonstrates the use of Wx::MediaCtrl, which can be used
|
17
11
|
# to playback sounds or movies using a platform-native player.
|
data/samples/minimal/minimal.rb
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
3
|
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
|
5
4
|
begin
|
6
|
-
require '
|
7
|
-
rescue LoadError
|
8
|
-
begin
|
9
|
-
require 'rubygems'
|
10
|
-
load 'wx'
|
11
|
-
rescue
|
12
|
-
raise no_wx_err
|
13
|
-
end
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
14
7
|
end
|
8
|
+
require 'wx'
|
15
9
|
|
16
10
|
# This sample shows a fairly minimal Wx::App using a Frame, with a
|
17
11
|
# MenuBar and StatusBar but no controls. For the absolute minimum app,
|
@@ -24,32 +18,33 @@ class MinimalFrame < Wx::Frame
|
|
24
18
|
# The main application frame has no parent (nil)
|
25
19
|
super(nil, :title => title, :size => [ 400, 300 ])
|
26
20
|
|
27
|
-
icon_file = File.join( File.dirname(__FILE__), "mondrian.png")
|
28
21
|
# PNG can be used on all platforms, but icon type must be specified
|
29
|
-
# to work on Windows
|
22
|
+
# to work on Windows. Note that OS X doesn't have "Frame" icons.
|
23
|
+
icon_file = File.join( File.dirname(__FILE__), "mondrian.png")
|
30
24
|
self.icon = Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_PNG)
|
31
25
|
|
32
26
|
menu_bar = Wx::MenuBar.new
|
33
27
|
# The "file" menu
|
34
28
|
menu_file = Wx::Menu.new
|
29
|
+
# Using Wx::ID_EXIT standard id means the menu item will be given
|
30
|
+
# the right label for the platform and language, and placed in the
|
31
|
+
# correct platform-specific menu - eg on OS X, in the Application's menu
|
35
32
|
menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
|
36
33
|
menu_bar.append(menu_file, "&File")
|
37
34
|
|
38
35
|
# The "help" menu
|
39
36
|
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
37
|
menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
|
43
38
|
menu_bar.append(menu_help, "&Help")
|
44
39
|
|
45
40
|
# Assign the menubar to this frame
|
46
41
|
self.menu_bar = menu_bar
|
47
42
|
|
48
|
-
# Create a status bar
|
43
|
+
# Create a status bar at the bottom of the frame
|
49
44
|
create_status_bar(2)
|
50
45
|
self.status_text = "Welcome to wxRuby!"
|
51
46
|
|
52
|
-
# Set it up to handle menu events using the relevant methods
|
47
|
+
# Set it up to handle menu events using the relevant methods.
|
53
48
|
evt_menu Wx::ID_EXIT, :on_quit
|
54
49
|
evt_menu Wx::ID_ABOUT, :on_about
|
55
50
|
end
|
@@ -60,17 +55,14 @@ class MinimalFrame < Wx::Frame
|
|
60
55
|
close()
|
61
56
|
end
|
62
57
|
|
63
|
-
# show an 'About' dialog
|
58
|
+
# show an 'About' dialog - WxRuby's about_box function will show a
|
59
|
+
# platform-native 'About' dialog, but you could also use an ordinary
|
60
|
+
# Wx::MessageDialog here.
|
64
61
|
def on_about
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
62
|
+
Wx::about_box(:name => self.title,
|
63
|
+
:version => Wx::WXRUBY_VERSION,
|
64
|
+
:description => "This is the minimal sample",
|
65
|
+
:developers => ['The wxRuby Development Team'] )
|
74
66
|
end
|
75
67
|
end
|
76
68
|
|
data/samples/minimal/nothing.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
3
|
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
|
5
4
|
begin
|
6
|
-
require '
|
7
|
-
rescue LoadError
|
8
|
-
begin
|
9
|
-
require 'rubygems'
|
10
|
-
require 'wx'
|
11
|
-
rescue LoadError
|
12
|
-
raise no_wx_err
|
13
|
-
end
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
14
7
|
end
|
8
|
+
require 'wx'
|
9
|
+
|
15
10
|
|
16
11
|
# This is the minimum code to start a WxRuby app - create a Frame, and
|
17
12
|
# show it.
|
data/samples/opengl/cube.rb
CHANGED
@@ -1,19 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
3
4
|
begin
|
4
|
-
|
5
|
-
|
6
|
-
require 'glu'
|
7
|
-
rescue LoadError => e
|
8
|
-
begin
|
9
|
-
require 'rubygems'
|
10
|
-
require 'wx'
|
11
|
-
require 'gl'
|
12
|
-
require 'glu'
|
13
|
-
rescue
|
14
|
-
raise e
|
15
|
-
end
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
16
7
|
end
|
8
|
+
require 'wx'
|
9
|
+
require 'gl'
|
10
|
+
require 'glu'
|
17
11
|
|
18
12
|
include Gl
|
19
13
|
include Glu
|
@@ -120,4 +114,4 @@ Wx::App.run do
|
|
120
114
|
self.app_name = 'GLCanvas Cube'
|
121
115
|
frame = CubeFrame.new("OpenGL Canvas wxRuby App")
|
122
116
|
frame.show
|
123
|
-
end
|
117
|
+
end
|
@@ -1,185 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
3
|
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
|
5
|
-
require '
|
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
|
-
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
182
7
|
end
|
8
|
+
require 'wx'
|
183
9
|
|
184
10
|
class MyCanvas < Wx::ScrolledWindow
|
185
11
|
#attr_accessor :frame
|