wxruby 1.9.2-i386-mswin32 → 1.9.3-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/LICENSE +53 -53
  2. data/README +299 -299
  3. data/lib/wx/classes/app.rb +6 -0
  4. data/lib/wx/classes/checklistbox.rb +45 -30
  5. data/lib/wx/classes/clipboard.rb +16 -0
  6. data/lib/wx/classes/event.rb +5 -0
  7. data/lib/wx/classes/evthandler.rb +20 -10
  8. data/lib/wx/classes/grid.rb +38 -39
  9. data/lib/wx/classes/listctrl.rb +12 -0
  10. data/lib/wx/classes/mediactrl.rb +22 -0
  11. data/lib/wx/classes/menu.rb +6 -6
  12. data/lib/wx/classes/sound.rb +23 -0
  13. data/lib/wx/classes/styledtextctrl.rb +2 -2
  14. data/lib/wx/classes/treectrl.rb +26 -0
  15. data/lib/wx/keyword_ctors.rb +19 -5
  16. data/lib/wx/keyword_defs.rb +20 -0
  17. data/lib/wx/version.rb +1 -1
  18. data/lib/wx.rb +42 -42
  19. data/lib/wxruby2.exp +0 -0
  20. data/lib/wxruby2.lib +0 -0
  21. data/lib/wxruby2.so +0 -0
  22. data/samples/SAMPLES-LICENSE.TXT +17 -17
  23. data/samples/aui/aui.rb +8 -1
  24. data/samples/bigdemo/About.rbw +39 -39
  25. data/samples/bigdemo/ColorPanel.rbw +25 -25
  26. data/samples/bigdemo/GridSimple.rbw +80 -80
  27. data/samples/bigdemo/MDIDemo.rbw +59 -59
  28. data/samples/bigdemo/PopupMenu.rbw +151 -151
  29. data/samples/bigdemo/Sizers.rbw +545 -545
  30. data/samples/bigdemo/bigdemo.rb +826 -826
  31. data/samples/bigdemo/demoTemplate.rbw +37 -37
  32. data/samples/bigdemo/icons/choice.xpm +27 -27
  33. data/samples/bigdemo/icons/combo.xpm +27 -27
  34. data/samples/bigdemo/icons/copy.xpm +25 -25
  35. data/samples/bigdemo/icons/cut.xpm +24 -24
  36. data/samples/bigdemo/icons/gauge.xpm +27 -27
  37. data/samples/bigdemo/icons/help.xpm +25 -25
  38. data/samples/bigdemo/icons/list.xpm +27 -27
  39. data/samples/bigdemo/icons/mondrian.xpm +44 -44
  40. data/samples/bigdemo/icons/new.xpm +24 -24
  41. data/samples/bigdemo/icons/ogl.ico +0 -0
  42. data/samples/bigdemo/icons/ogl.xpm +45 -45
  43. data/samples/bigdemo/icons/open.xpm +26 -26
  44. data/samples/bigdemo/icons/paste.xpm +38 -38
  45. data/samples/bigdemo/icons/preview.xpm +26 -26
  46. data/samples/bigdemo/icons/print.xpm +26 -26
  47. data/samples/bigdemo/icons/radio.xpm +27 -27
  48. data/samples/bigdemo/icons/robert.xpm +415 -415
  49. data/samples/bigdemo/icons/save.xpm +25 -25
  50. data/samples/bigdemo/icons/smiles.xpm +39 -39
  51. data/samples/bigdemo/icons/smiley.xpm +42 -42
  52. data/samples/bigdemo/icons/stattext.xpm +24 -24
  53. data/samples/bigdemo/icons/test2.bmp +0 -0
  54. data/samples/bigdemo/icons/test2.xpm +79 -79
  55. data/samples/bigdemo/icons/text.xpm +27 -27
  56. data/samples/bigdemo/icons/tog1.xpm +38 -38
  57. data/samples/bigdemo/icons/tog2.xpm +38 -38
  58. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -25
  59. data/samples/bigdemo/tips.txt +7 -7
  60. data/samples/bigdemo/utils.rb +11 -11
  61. data/samples/bigdemo/wxButton.rbw +66 -66
  62. data/samples/bigdemo/wxCalendarCtrl.rbw +72 -72
  63. data/samples/bigdemo/wxCheckBox.rbw +52 -52
  64. data/samples/bigdemo/wxCheckListBox.rbw +77 -77
  65. data/samples/bigdemo/wxChoice.rbw +49 -49
  66. data/samples/bigdemo/wxColourDialog.rbw +34 -34
  67. data/samples/bigdemo/wxComboBox.rbw +79 -79
  68. data/samples/bigdemo/wxDialog.rbw +92 -92
  69. data/samples/bigdemo/wxDirDialog.rbw +32 -32
  70. data/samples/bigdemo/wxFileDialog.rbw +39 -39
  71. data/samples/bigdemo/wxFileDialog_Save.rbw +38 -38
  72. data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -85
  73. data/samples/bigdemo/wxFontDialog.rbw +176 -176
  74. data/samples/bigdemo/wxFrame.rbw +55 -55
  75. data/samples/bigdemo/wxGauge.rbw +73 -73
  76. data/samples/bigdemo/wxGrid.rbw +68 -68
  77. data/samples/bigdemo/wxListBox.rbw +142 -142
  78. data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -109
  79. data/samples/bigdemo/wxMDIWindows.rbw +52 -52
  80. data/samples/bigdemo/wxMenu.rbw +238 -238
  81. data/samples/bigdemo/wxMessageDialog.rbw +30 -30
  82. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -34
  83. data/samples/bigdemo/wxNotebook.rbw +138 -138
  84. data/samples/bigdemo/wxProgressDialog.rbw +45 -45
  85. data/samples/bigdemo/wxRadioBox.rbw +74 -74
  86. data/samples/bigdemo/wxRadioButton.rbw +127 -127
  87. data/samples/bigdemo/wxSashWindow.rbw +94 -104
  88. data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -59
  89. data/samples/bigdemo/wxScrolledWindow.rbw +201 -201
  90. data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -35
  91. data/samples/bigdemo/wxSlider.rbw +44 -44
  92. data/samples/bigdemo/wxSpinButton.rbw +52 -52
  93. data/samples/bigdemo/wxSpinCtrl.rbw +53 -53
  94. data/samples/bigdemo/wxSplitterWindow.rbw +65 -65
  95. data/samples/bigdemo/wxStaticBitmap.rbw +53 -53
  96. data/samples/bigdemo/wxStaticText.rbw +57 -57
  97. data/samples/bigdemo/wxStatusBar.rbw +128 -128
  98. data/samples/bigdemo/wxTextCtrl.rbw +151 -151
  99. data/samples/bigdemo/wxTextEntryDialog.rbw +34 -34
  100. data/samples/bigdemo/wxToggleButton.rbw +51 -51
  101. data/samples/bigdemo/wxToolBar.rbw +133 -133
  102. data/samples/bigdemo/wxTreeCtrl.rbw +192 -192
  103. data/samples/calendar/calendar.rb +275 -275
  104. data/samples/caret/caret.rb +286 -286
  105. data/samples/caret/mondrian.xpm +44 -44
  106. data/samples/controls/controls.rb +1140 -1140
  107. data/samples/controls/get_item_sample.rb +87 -87
  108. data/samples/controls/icons/choice.xpm +27 -27
  109. data/samples/controls/icons/combo.xpm +27 -27
  110. data/samples/controls/icons/gauge.xpm +27 -27
  111. data/samples/controls/icons/list.xpm +27 -27
  112. data/samples/controls/icons/radio.xpm +27 -27
  113. data/samples/controls/icons/stattext.xpm +24 -24
  114. data/samples/controls/icons/text.xpm +27 -27
  115. data/samples/controls/mondrian.xpm +44 -44
  116. data/samples/dialogs/dialogs.rb +724 -724
  117. data/samples/dialogs/tips.txt +18 -18
  118. data/samples/drawing/graphics_drawing.rb +232 -0
  119. data/samples/{images → drawing}/images.rb +48 -48
  120. data/samples/{images → drawing}/paperclip.png +0 -0
  121. data/samples/etc/activation.rb +108 -108
  122. data/samples/etc/choice.rb +72 -72
  123. data/samples/etc/miniframe.rb +84 -84
  124. data/samples/etc/sash.rb +135 -135
  125. data/samples/etc/scrollwin.rb +116 -116
  126. data/samples/etc/system_settings.rb +258 -258
  127. data/samples/etc/wizard.rb +79 -79
  128. data/samples/grid/grid.rb +1 -0
  129. data/samples/listbook/listbook.rb +181 -181
  130. data/samples/listbook/listbook.xrc +370 -370
  131. data/samples/mdi/mdi.rb +87 -87
  132. data/samples/media/mediactrl.rb +173 -0
  133. data/samples/minimal/minimal.rb +85 -85
  134. data/samples/minimal/nothing.rb +21 -21
  135. data/samples/opengl/cube.rb +123 -0
  136. data/samples/sockets/SocketPackets.rb +27 -0
  137. data/samples/sockets/res/message-new.png +0 -0
  138. data/samples/sockets/res/user.png +0 -0
  139. data/samples/sockets/wxClient.rb +395 -0
  140. data/samples/sockets/wxServer.rb +422 -0
  141. data/samples/sockets/wxSocketGUI.rb +97 -0
  142. data/samples/text/textctrl.rb +124 -124
  143. data/samples/text/unicode.rb +238 -238
  144. data/samples/text/utf8.txt +14 -14
  145. data/samples/treectrl/treectrl.rb +1180 -1181
  146. data/samples/xrc/samples.xrc +46 -46
  147. data/samples/xrc/xrc_sample.rb +107 -107
  148. metadata +26 -9
  149. data/samples/images/Thumbs.db +0 -0
data/samples/mdi/mdi.rb CHANGED
@@ -1,87 +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()
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,173 @@
1
+ #!/usr/bin/env ruby
2
+ # wxRuby2 Sample Code. Ported from wxPython by Albin Holmgren
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 sample demonstrates the use of Wx::MediaCtrl, which can be used
17
+ # to playback sounds or movies using a platform-native player.
18
+ class MediaPanel<Wx::Panel
19
+ def initialize(parent)
20
+ super(parent, :style => Wx::TAB_TRAVERSAL|Wx::CLIP_CHILDREN)
21
+
22
+ # The actual media player control
23
+ @mc = Wx::MediaCtrl.new(self, :pos => [100,100], :size => [300,300])
24
+ evt_media_loaded @mc,:on_media_loaded
25
+
26
+ # Some buttons to control playback
27
+ @btn_load = Wx::Button.new(self, :label => "Load File")
28
+ evt_button @btn_load,:on_load_file
29
+
30
+ @btn_play = Wx::Button.new(self, :label => "Play")
31
+ evt_button @btn_play, :on_play
32
+ @btn_play.disable
33
+
34
+ @btn_pause = Wx::Button.new(self, :label => "Pause")
35
+ evt_button @btn_pause, :on_pause
36
+ @btn_pause.disable
37
+
38
+ @btn_stop = Wx::Button.new(self, :label => "Stop")
39
+ evt_button @btn_stop,:on_stop
40
+ @btn_stop.disable
41
+
42
+ @slider = Wx::Slider.new(self, :min_value => 0, :max_value => 1)
43
+ @slider.min_size = [150, -1]
44
+ evt_slider @slider, :on_seek
45
+
46
+ @st_size = Wx::StaticText.new(self, :label => "", :size => [100, -1])
47
+ @st_len = Wx::StaticText.new(self, :label => "", :size => [100, -1])
48
+ @st_pos = Wx::StaticText.new(self, :label => "", :size => [100, -1])
49
+
50
+ # layout the panel
51
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
52
+
53
+ sizer.add(@mc, 1, Wx::EXPAND|Wx::ALL, 5)
54
+ sizer.add(@slider, 0, Wx::EXPAND|Wx::ALL, 5)
55
+
56
+ # For the playback text
57
+ secs_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)
58
+ secs_sizer.add(@st_pos, 0, Wx::ALL, 2)
59
+ secs_sizer.add(@st_len, 0, Wx::ALL, 2)
60
+ secs_sizer.add(@st_size, 0, Wx::ALL, 2)
61
+ sizer.add(secs_sizer, 0, Wx::ALIGN_RIGHT|Wx::ALL, 0)
62
+
63
+ btn_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)
64
+ btn_sizer.add(@btn_load, 1, Wx::ALL, 2)
65
+ btn_sizer.add(@btn_play, 1, Wx::ALL, 2)
66
+ btn_sizer.add(@btn_pause, 1, Wx::ALL, 2)
67
+ btn_sizer.add(@btn_stop, 1, Wx::ALL, 2)
68
+ sizer.add(btn_sizer, 0, Wx::ALL, 5)
69
+
70
+ self.sizer = sizer
71
+
72
+ @timer = Wx::Timer.new(self,101)
73
+ evt_timer(101,:on_timer)
74
+ @timer.start(100)
75
+ end
76
+
77
+ # Update the position indicator in seconds
78
+ def on_timer(evt)
79
+ offset = @mc.tell
80
+ # Will be -1 if nothing is loaded
81
+ if offset >= 0
82
+ @slider.value = offset
83
+ offset_secs = offset / 1000
84
+ @st_pos.label = "%i:%02d" % [ offset_secs / 60, offset_secs % 60 ]
85
+ else
86
+ @st_pos.label = ""
87
+ end
88
+ end
89
+
90
+ # Actually load a file into the mediactrl
91
+ def do_load_file(path)
92
+ @btn_play.disable
93
+ unless @mc.load(path)
94
+ Wx::message_box("Unable to load file", "ERROR",
95
+ Wx::ICON_ERROR|Wx::OK)
96
+ else
97
+
98
+ end
99
+ end
100
+
101
+ MEDIA_FILE_WILDCARD = "MP3 Files (*.mp3)|*.mp3|Avi Files (*.avi)|*.avi"
102
+ # Load a media file from disk
103
+ def on_load_file(evt)
104
+ dlg = Wx::FileDialog.new( self,
105
+ :message => "Choose a media file",
106
+ :wildcard => MEDIA_FILE_WILDCARD,
107
+ :style => Wx::OPEN)
108
+ if dlg.show_modal == Wx::ID_OK
109
+ do_load_file(dlg.path)
110
+ end
111
+ dlg.destroy
112
+ end
113
+
114
+ # Move the media to a position in the file, using the slider
115
+ def on_seek(evt)
116
+ offset = @slider.value
117
+ @mc.seek(offset)
118
+ end
119
+
120
+ # Set up the initial size for the move
121
+ def on_media_loaded(evt)
122
+ # Readjust to the original size of the video
123
+ @mc.set_initial_size
124
+
125
+ # Enable the control buttons
126
+ @btn_play.enable
127
+ @btn_pause.enable
128
+ @btn_stop.enable
129
+
130
+ # Update the length and position text indicators with the media's
131
+ # time length, shown as minutes and seconds
132
+ len_secs = @mc.length / 1000
133
+ @st_len.label = "%i:%02d" % [ len_secs / 60, len_secs % 60 ]
134
+
135
+ # Set the seek slider
136
+ @slider.set_range(0, @mc.length)
137
+
138
+ # Refresh the layout
139
+ sizer.layout
140
+ end
141
+
142
+ # Stop the playback
143
+ def on_stop(evt)
144
+ @mc.stop
145
+ end
146
+
147
+ # Pause the playback
148
+ def on_pause(evt)
149
+ @mc.pause
150
+ end
151
+
152
+ # Start the playback
153
+ def on_play(evt)
154
+ if not @mc.play
155
+ Wx::MessageBox("unable to play media","ERROR",Wx::ICON_ERROR|Wx::OK)
156
+ else
157
+ @mc.set_initial_size
158
+ sizer.layout
159
+ end
160
+ end
161
+ end
162
+
163
+ class MediaFrame<Wx::Frame
164
+ def initialize()
165
+ super(nil,:title=>"MediaCtrl test",:size=>[700,700])
166
+ win = MediaPanel.new(self)
167
+ end
168
+ end
169
+
170
+ # Actually run the app
171
+ Wx::App.run do
172
+ MediaFrame.new.show
173
+ end
@@ -1,85 +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
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
@@ -1,21 +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
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
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'wx'
5
+ require 'gl'
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
16
+ end
17
+
18
+ include Gl
19
+ include Glu
20
+
21
+ class CubeFrame < Wx::Frame
22
+ def initialize(title)
23
+ super(nil, :title => title, :size => [ 400, 300 ])
24
+ attrib = [Wx::GL_RGBA, Wx::GL_DOUBLEBUFFER, Wx::GL_DEPTH_SIZE, 24]
25
+ @canvas = Wx::GLCanvas.new(self, -1, [-1, -1], [-1, -1],
26
+ Wx::FULL_REPAINT_ON_RESIZE, 'GLCanvas', attrib)
27
+ @canvas.evt_paint { @canvas.paint { render } }
28
+ @canvas.evt_key_down {|evt| on_key_down(evt.get_key_code) }
29
+ @rotate = [0.0, 0.0, 0.0]
30
+ end
31
+
32
+ def on_key_down(key)
33
+ case key
34
+ when Wx::K_UP
35
+ @rotate[0] -= 3.0
36
+ when Wx::K_DOWN
37
+ @rotate[0] += 3.0
38
+ when Wx::K_LEFT
39
+ @rotate[2] -= 3.0
40
+ when Wx::K_RIGHT
41
+ @rotate[2] += 3.0
42
+ end
43
+ render
44
+ end
45
+
46
+ def render
47
+ @canvas.set_current
48
+ sz = @canvas.get_size
49
+ w = sz.get_width
50
+ h = sz.get_height
51
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
52
+ glEnable(GL_DEPTH_TEST)
53
+ glViewport(0, 0, w, h)
54
+ glMatrixMode(GL_PROJECTION)
55
+ glLoadIdentity()
56
+ gluPerspective(30.0, w.to_f/h.to_f, 0.1, 1000.0)
57
+ glMatrixMode(GL_MODELVIEW)
58
+ glLoadIdentity()
59
+ gluLookAt(0.0, -10.0, 0.0,
60
+ 0.0, 0.0, 0.0,
61
+ 0.0, 0.0, 1.0)
62
+ glRotate(@rotate[0], 1.0, 0.0, 0.0)
63
+ glRotate(@rotate[1], 0.0, 1.0, 0.0)
64
+ glRotate(@rotate[2], 0.0, 0.0, 1.0)
65
+ glBegin(GL_TRIANGLES)
66
+ #left
67
+ glColor3d(1.0, 1.0, 1.0)
68
+ glVertex3d(-1.0, 1.0, 1.0)
69
+ glVertex3d(-1.0, 1.0,-1.0)
70
+ glVertex3d(-1.0,-1.0, 1.0)
71
+ glVertex3d(-1.0,-1.0, 1.0)
72
+ glVertex3d(-1.0, 1.0,-1.0)
73
+ glVertex3d(-1.0,-1.0,-1.0)
74
+ #right
75
+ glColor3d(0.0, 1.0, 1.0)
76
+ glVertex3d( 1.0,-1.0, 1.0)
77
+ glVertex3d( 1.0,-1.0,-1.0)
78
+ glVertex3d( 1.0, 1.0, 1.0)
79
+ glVertex3d( 1.0, 1.0, 1.0)
80
+ glVertex3d( 1.0,-1.0,-1.0)
81
+ glVertex3d( 1.0, 1.0,-1.0)
82
+ #up
83
+ glColor3d(0.0, 0.0, 1.0)
84
+ glVertex3d(-1.0, 1.0, 1.0)
85
+ glVertex3d(-1.0,-1.0, 1.0)
86
+ glVertex3d( 1.0, 1.0, 1.0)
87
+ glVertex3d( 1.0, 1.0, 1.0)
88
+ glVertex3d(-1.0,-1.0, 1.0)
89
+ glVertex3d( 1.0,-1.0, 1.0)
90
+ #down
91
+ glColor3d(1.0, 0.0, 0.0)
92
+ glVertex3d(-1.0,-1.0,-1.0)
93
+ glVertex3d(-1.0, 1.0,-1.0)
94
+ glVertex3d( 1.0,-1.0,-1.0)
95
+ glVertex3d( 1.0,-1.0,-1.0)
96
+ glVertex3d(-1.0, 1.0,-1.0)
97
+ glVertex3d( 1.0, 1.0,-1.0)
98
+ #front
99
+ glColor3d(1.0, 1.0, 0.0)
100
+ glVertex3d(-1.0,-1.0, 1.0)
101
+ glVertex3d(-1.0,-1.0,-1.0)
102
+ glVertex3d( 1.0,-1.0, 1.0)
103
+ glVertex3d( 1.0,-1.0, 1.0)
104
+ glVertex3d(-1.0,-1.0,-1.0)
105
+ glVertex3d( 1.0,-1.0,-1.0)
106
+ #back
107
+ glColor3d(0.0, 1.0, 0.0)
108
+ glVertex3d( 1.0, 1.0, 1.0)
109
+ glVertex3d( 1.0, 1.0,-1.0)
110
+ glVertex3d(-1.0, 1.0, 1.0)
111
+ glVertex3d(-1.0, 1.0, 1.0)
112
+ glVertex3d( 1.0, 1.0,-1.0)
113
+ glVertex3d(-1.0, 1.0,-1.0)
114
+ glEnd()
115
+ @canvas.swap_buffers
116
+ end
117
+ end
118
+
119
+ Wx::App.run do
120
+ self.app_name = 'GLCanvas Cube'
121
+ frame = CubeFrame.new("OpenGL Canvas wxRuby App")
122
+ frame.show
123
+ end