wxruby 1.9.3-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. data/LICENSE +53 -0
  2. data/README +299 -0
  3. data/lib/wx.rb +42 -0
  4. data/lib/wx/accessors.rb +52 -0
  5. data/lib/wx/classes/app.rb +45 -0
  6. data/lib/wx/classes/artprovider.rb +31 -0
  7. data/lib/wx/classes/bitmap.rb +23 -0
  8. data/lib/wx/classes/checklistbox.rb +45 -0
  9. data/lib/wx/classes/choice.rb +4 -0
  10. data/lib/wx/classes/clientdc.rb +13 -0
  11. data/lib/wx/classes/clipboard.rb +16 -0
  12. data/lib/wx/classes/colour.rb +47 -0
  13. data/lib/wx/classes/combobox.rb +4 -0
  14. data/lib/wx/classes/commandevent.rb +7 -0
  15. data/lib/wx/classes/controlwithitems.rb +10 -0
  16. data/lib/wx/classes/event.rb +5 -0
  17. data/lib/wx/classes/evthandler.rb +894 -0
  18. data/lib/wx/classes/font.rb +118 -0
  19. data/lib/wx/classes/grid.rb +129 -0
  20. data/lib/wx/classes/helpcontroller.rb +5 -0
  21. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  22. data/lib/wx/classes/htmlwindow.rb +6 -0
  23. data/lib/wx/classes/icon.rb +14 -0
  24. data/lib/wx/classes/image.rb +14 -0
  25. data/lib/wx/classes/listbox.rb +4 -0
  26. data/lib/wx/classes/listctrl.rb +21 -0
  27. data/lib/wx/classes/locale.rb +28 -0
  28. data/lib/wx/classes/mediactrl.rb +22 -0
  29. data/lib/wx/classes/menu.rb +62 -0
  30. data/lib/wx/classes/menuitem.rb +7 -0
  31. data/lib/wx/classes/object.rb +7 -0
  32. data/lib/wx/classes/paintdc.rb +12 -0
  33. data/lib/wx/classes/point.rb +48 -0
  34. data/lib/wx/classes/previewframe.rb +13 -0
  35. data/lib/wx/classes/rect.rb +5 -0
  36. data/lib/wx/classes/size.rb +49 -0
  37. data/lib/wx/classes/sound.rb +23 -0
  38. data/lib/wx/classes/styledtextctrl.rb +92 -0
  39. data/lib/wx/classes/textctrl.rb +14 -0
  40. data/lib/wx/classes/texturlevent.rb +6 -0
  41. data/lib/wx/classes/timer.rb +69 -0
  42. data/lib/wx/classes/treectrl.rb +44 -0
  43. data/lib/wx/classes/window.rb +49 -0
  44. data/lib/wx/classes/xmlresource.rb +16 -0
  45. data/lib/wx/keyword_ctors.rb +219 -0
  46. data/lib/wx/keyword_defs.rb +485 -0
  47. data/lib/wx/version.rb +3 -0
  48. data/lib/wxruby2.so +0 -0
  49. data/samples/SAMPLES-LICENSE.TXT +18 -0
  50. data/samples/aui/aui.rb +1360 -0
  51. data/samples/bigdemo/About.rbw +39 -0
  52. data/samples/bigdemo/ColorPanel.rbw +25 -0
  53. data/samples/bigdemo/GridSimple.rbw +80 -0
  54. data/samples/bigdemo/MDIDemo.rbw +59 -0
  55. data/samples/bigdemo/PopupMenu.rbw +151 -0
  56. data/samples/bigdemo/ShapedWindow.rbw +135 -0
  57. data/samples/bigdemo/Sizers.rbw +545 -0
  58. data/samples/bigdemo/bigdemo.rb +826 -0
  59. data/samples/bigdemo/demoTemplate.rbw +37 -0
  60. data/samples/bigdemo/helpfile.htb +0 -0
  61. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  62. data/samples/bigdemo/icons/Test 015.png +0 -0
  63. data/samples/bigdemo/icons/choice.bmp +0 -0
  64. data/samples/bigdemo/icons/choice.xpm +27 -0
  65. data/samples/bigdemo/icons/combo.bmp +0 -0
  66. data/samples/bigdemo/icons/combo.xpm +27 -0
  67. data/samples/bigdemo/icons/copy.xpm +25 -0
  68. data/samples/bigdemo/icons/cut.xpm +24 -0
  69. data/samples/bigdemo/icons/gauge.bmp +0 -0
  70. data/samples/bigdemo/icons/gauge.xpm +27 -0
  71. data/samples/bigdemo/icons/help.xpm +25 -0
  72. data/samples/bigdemo/icons/list.bmp +0 -0
  73. data/samples/bigdemo/icons/list.xpm +27 -0
  74. data/samples/bigdemo/icons/mondrian.ico +0 -0
  75. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  76. data/samples/bigdemo/icons/new.xpm +24 -0
  77. data/samples/bigdemo/icons/ogl.ico +0 -0
  78. data/samples/bigdemo/icons/ogl.xpm +45 -0
  79. data/samples/bigdemo/icons/open.xpm +26 -0
  80. data/samples/bigdemo/icons/paste.bmp +0 -0
  81. data/samples/bigdemo/icons/paste.xpm +38 -0
  82. data/samples/bigdemo/icons/pointy.png +0 -0
  83. data/samples/bigdemo/icons/preview.xpm +26 -0
  84. data/samples/bigdemo/icons/print.xpm +26 -0
  85. data/samples/bigdemo/icons/radio.bmp +0 -0
  86. data/samples/bigdemo/icons/radio.xpm +27 -0
  87. data/samples/bigdemo/icons/robert.xpm +415 -0
  88. data/samples/bigdemo/icons/ruby.png +0 -0
  89. data/samples/bigdemo/icons/sashtest.ico +0 -0
  90. data/samples/bigdemo/icons/save.xpm +25 -0
  91. data/samples/bigdemo/icons/smiles.bmp +0 -0
  92. data/samples/bigdemo/icons/smiles.xpm +39 -0
  93. data/samples/bigdemo/icons/smiley.ico +0 -0
  94. data/samples/bigdemo/icons/smiley.xpm +42 -0
  95. data/samples/bigdemo/icons/stattext.xpm +24 -0
  96. data/samples/bigdemo/icons/test2.bmp +0 -0
  97. data/samples/bigdemo/icons/test2.png +0 -0
  98. data/samples/bigdemo/icons/test2.xpm +79 -0
  99. data/samples/bigdemo/icons/text.bmp +0 -0
  100. data/samples/bigdemo/icons/text.xpm +27 -0
  101. data/samples/bigdemo/icons/tog1.bmp +0 -0
  102. data/samples/bigdemo/icons/tog1.xpm +38 -0
  103. data/samples/bigdemo/icons/tog2.bmp +0 -0
  104. data/samples/bigdemo/icons/tog2.xpm +38 -0
  105. data/samples/bigdemo/icons/wxwin.ico +0 -0
  106. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  107. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  108. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  109. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  110. data/samples/bigdemo/run.rb +94 -0
  111. data/samples/bigdemo/tips.txt +7 -0
  112. data/samples/bigdemo/utils.rb +12 -0
  113. data/samples/bigdemo/wxArtProvider.rbw +285 -0
  114. data/samples/bigdemo/wxBitmapButton.rbw +64 -0
  115. data/samples/bigdemo/wxButton.rbw +66 -0
  116. data/samples/bigdemo/wxCalendarCtrl.rbw +72 -0
  117. data/samples/bigdemo/wxCheckBox.rbw +52 -0
  118. data/samples/bigdemo/wxCheckListBox.rbw +77 -0
  119. data/samples/bigdemo/wxChoice.rbw +49 -0
  120. data/samples/bigdemo/wxChoicebook.rbw +80 -0
  121. data/samples/bigdemo/wxColourDialog.rbw +34 -0
  122. data/samples/bigdemo/wxComboBox.rbw +79 -0
  123. data/samples/bigdemo/wxCursor.rbw +140 -0
  124. data/samples/bigdemo/wxDialog.rbw +92 -0
  125. data/samples/bigdemo/wxDirDialog.rbw +32 -0
  126. data/samples/bigdemo/wxDragImage.rbw +74 -0
  127. data/samples/bigdemo/wxFileDialog.rbw +39 -0
  128. data/samples/bigdemo/wxFileDialog_Save.rbw +38 -0
  129. data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -0
  130. data/samples/bigdemo/wxFontDialog.rbw +176 -0
  131. data/samples/bigdemo/wxFrame.rbw +55 -0
  132. data/samples/bigdemo/wxGauge.rbw +73 -0
  133. data/samples/bigdemo/wxGenericDirCtrl.rbw +78 -0
  134. data/samples/bigdemo/wxGrid.rbw +68 -0
  135. data/samples/bigdemo/wxHtmlHelpController.rbw +57 -0
  136. data/samples/bigdemo/wxListBox.rbw +142 -0
  137. data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -0
  138. data/samples/bigdemo/wxMDIWindows.rbw +52 -0
  139. data/samples/bigdemo/wxMenu.rbw +238 -0
  140. data/samples/bigdemo/wxMessageDialog.rbw +30 -0
  141. data/samples/bigdemo/wxMiniFrame.rbw +74 -0
  142. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -0
  143. data/samples/bigdemo/wxNotebook.rbw +138 -0
  144. data/samples/bigdemo/wxProgressDialog.rbw +45 -0
  145. data/samples/bigdemo/wxRadioBox.rbw +74 -0
  146. data/samples/bigdemo/wxRadioButton.rbw +127 -0
  147. data/samples/bigdemo/wxSashWindow.rbw +145 -0
  148. data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -0
  149. data/samples/bigdemo/wxScrolledWindow.rbw +201 -0
  150. data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -0
  151. data/samples/bigdemo/wxSlider.rbw +44 -0
  152. data/samples/bigdemo/wxSpinButton.rbw +52 -0
  153. data/samples/bigdemo/wxSpinCtrl.rbw +53 -0
  154. data/samples/bigdemo/wxSplitterWindow.rbw +65 -0
  155. data/samples/bigdemo/wxStaticBitmap.rbw +53 -0
  156. data/samples/bigdemo/wxStaticText.rbw +57 -0
  157. data/samples/bigdemo/wxStatusBar.rbw +128 -0
  158. data/samples/bigdemo/wxTextCtrl.rbw +151 -0
  159. data/samples/bigdemo/wxTextEntryDialog.rbw +34 -0
  160. data/samples/bigdemo/wxToggleButton.rbw +51 -0
  161. data/samples/bigdemo/wxToolBar.rbw +133 -0
  162. data/samples/bigdemo/wxTreeCtrl.rbw +192 -0
  163. data/samples/calendar/calendar.rb +275 -0
  164. data/samples/caret/caret.rb +286 -0
  165. data/samples/caret/mondrian.xpm +44 -0
  166. data/samples/controls/controls.rb +1140 -0
  167. data/samples/controls/get_item_sample.rb +87 -0
  168. data/samples/controls/icons/choice.xpm +27 -0
  169. data/samples/controls/icons/combo.xpm +27 -0
  170. data/samples/controls/icons/gauge.xpm +27 -0
  171. data/samples/controls/icons/list.xpm +27 -0
  172. data/samples/controls/icons/radio.xpm +27 -0
  173. data/samples/controls/icons/stattext.xpm +24 -0
  174. data/samples/controls/icons/text.xpm +27 -0
  175. data/samples/controls/mondrian.ico +0 -0
  176. data/samples/controls/mondrian.xpm +44 -0
  177. data/samples/controls/test2.bmp +0 -0
  178. data/samples/dialogs/dialogs.rb +724 -0
  179. data/samples/dialogs/tips.txt +18 -0
  180. data/samples/drawing/graphics_drawing.rb +232 -0
  181. data/samples/drawing/images.rb +48 -0
  182. data/samples/drawing/paperclip.png +0 -0
  183. data/samples/etc/activation.rb +108 -0
  184. data/samples/etc/choice.rb +72 -0
  185. data/samples/etc/miniframe.rb +84 -0
  186. data/samples/etc/sash.rb +135 -0
  187. data/samples/etc/scrollwin.rb +116 -0
  188. data/samples/etc/system_settings.rb +258 -0
  189. data/samples/etc/threaded.rb +81 -0
  190. data/samples/etc/wizard.rb +79 -0
  191. data/samples/event/event.rb +184 -0
  192. data/samples/grid/grid.rb +202 -0
  193. data/samples/html/html.rb +264 -0
  194. data/samples/listbook/listbook.rb +181 -0
  195. data/samples/listbook/listbook.xrc +370 -0
  196. data/samples/mdi/mdi.rb +87 -0
  197. data/samples/media/mediactrl.rb +173 -0
  198. data/samples/minimal/minimal.rb +85 -0
  199. data/samples/minimal/mondrian.ico +0 -0
  200. data/samples/minimal/mondrian.png +0 -0
  201. data/samples/minimal/nothing.rb +21 -0
  202. data/samples/opengl/cube.rb +123 -0
  203. data/samples/printing/mondrian.ico +0 -0
  204. data/samples/printing/mondrian.xpm +44 -0
  205. data/samples/printing/printing.rb +484 -0
  206. data/samples/sockets/SocketPackets.rb +27 -0
  207. data/samples/sockets/res/message-new.png +0 -0
  208. data/samples/sockets/res/user.png +0 -0
  209. data/samples/sockets/wxClient.rb +395 -0
  210. data/samples/sockets/wxServer.rb +422 -0
  211. data/samples/sockets/wxSocketGUI.rb +97 -0
  212. data/samples/text/mondrian.ico +0 -0
  213. data/samples/text/mondrian.xpm +44 -0
  214. data/samples/text/scintilla.rb +174 -0
  215. data/samples/text/textctrl.rb +124 -0
  216. data/samples/text/unicode.rb +238 -0
  217. data/samples/text/utf8.txt +15 -0
  218. data/samples/treectrl/icon1.xpm +79 -0
  219. data/samples/treectrl/icon2.xpm +53 -0
  220. data/samples/treectrl/icon3.xpm +79 -0
  221. data/samples/treectrl/icon4.xpm +43 -0
  222. data/samples/treectrl/icon5.xpm +79 -0
  223. data/samples/treectrl/treectrl.rb +1180 -0
  224. data/samples/xrc/samples.xrc +46 -0
  225. data/samples/xrc/xrc_sample.rb +107 -0
  226. metadata +303 -0
@@ -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,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
@@ -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
@@ -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
@@ -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