wxruby-ruby19 1.9.8-x86-linux → 1.9.10-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. data/LICENSE +53 -0
  2. data/README +297 -0
  3. data/lib/wx/accessors.rb +58 -0
  4. data/lib/wx/classes/acceleratortable.rb +28 -0
  5. data/lib/wx/classes/animation.rb +18 -0
  6. data/lib/wx/classes/app.rb +51 -0
  7. data/lib/wx/classes/artprovider.rb +31 -0
  8. data/lib/wx/classes/auinotebook.rb +9 -0
  9. data/lib/wx/classes/bitmap.rb +56 -0
  10. data/lib/wx/classes/busycursor.rb +12 -0
  11. data/lib/wx/classes/checklistbox.rb +45 -0
  12. data/lib/wx/classes/choice.rb +4 -0
  13. data/lib/wx/classes/clientdc.rb +13 -0
  14. data/lib/wx/classes/clipboard.rb +32 -0
  15. data/lib/wx/classes/colour.rb +49 -0
  16. data/lib/wx/classes/combobox.rb +4 -0
  17. data/lib/wx/classes/commandevent.rb +7 -0
  18. data/lib/wx/classes/controlwithitems.rb +10 -0
  19. data/lib/wx/classes/data_object.rb +14 -0
  20. data/lib/wx/classes/data_object_simple.rb +6 -0
  21. data/lib/wx/classes/dataformat.rb +23 -0
  22. data/lib/wx/classes/dc.rb +57 -0
  23. data/lib/wx/classes/event.rb +5 -0
  24. data/lib/wx/classes/evthandler.rb +1039 -0
  25. data/lib/wx/classes/font.rb +118 -0
  26. data/lib/wx/classes/functions.rb +44 -0
  27. data/lib/wx/classes/gauge.rb +12 -0
  28. data/lib/wx/classes/genericdirctrl.rb +36 -0
  29. data/lib/wx/classes/grid.rb +146 -0
  30. data/lib/wx/classes/hboxsizer.rb +6 -0
  31. data/lib/wx/classes/helpcontroller.rb +5 -0
  32. data/lib/wx/classes/helpcontrollerhelpprovider.rb +23 -0
  33. data/lib/wx/classes/helpprovider.rb +15 -0
  34. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  35. data/lib/wx/classes/htmlwindow.rb +14 -0
  36. data/lib/wx/classes/icon.rb +32 -0
  37. data/lib/wx/classes/iconbundle.rb +3 -0
  38. data/lib/wx/classes/image.rb +43 -0
  39. data/lib/wx/classes/imagelist.rb +3 -0
  40. data/lib/wx/classes/listbox.rb +4 -0
  41. data/lib/wx/classes/listctrl.rb +33 -0
  42. data/lib/wx/classes/locale.rb +28 -0
  43. data/lib/wx/classes/mediactrl.rb +48 -0
  44. data/lib/wx/classes/menu.rb +62 -0
  45. data/lib/wx/classes/menuitem.rb +7 -0
  46. data/lib/wx/classes/notebook.rb +9 -0
  47. data/lib/wx/classes/object.rb +14 -0
  48. data/lib/wx/classes/paintdc.rb +12 -0
  49. data/lib/wx/classes/point.rb +56 -0
  50. data/lib/wx/classes/previewframe.rb +13 -0
  51. data/lib/wx/classes/rect.rb +19 -0
  52. data/lib/wx/classes/richtextctrl.rb +63 -0
  53. data/lib/wx/classes/simplehelpprovider.rb +38 -0
  54. data/lib/wx/classes/size.rb +58 -0
  55. data/lib/wx/classes/sizer.rb +37 -0
  56. data/lib/wx/classes/sound.rb +23 -0
  57. data/lib/wx/classes/standardpaths.rb +9 -0
  58. data/lib/wx/classes/styledtextctrl.rb +92 -0
  59. data/lib/wx/classes/textctrl.rb +14 -0
  60. data/lib/wx/classes/texturlevent.rb +18 -0
  61. data/lib/wx/classes/timer.rb +94 -0
  62. data/lib/wx/classes/toolbar.rb +27 -0
  63. data/lib/wx/classes/toolbartool.rb +4 -0
  64. data/lib/wx/classes/treectrl.rb +44 -0
  65. data/lib/wx/classes/vboxsizer.rb +6 -0
  66. data/lib/wx/classes/window.rb +89 -0
  67. data/lib/wx/classes/xmlresource.rb +54 -0
  68. data/lib/wx/helpers.rb +45 -0
  69. data/lib/wx/keyword_ctors.rb +204 -0
  70. data/lib/wx/keyword_defs.rb +558 -0
  71. data/lib/wx/version.rb +3 -0
  72. data/lib/wx.rb +53 -0
  73. data/lib/wxruby2.so +0 -0
  74. data/samples/SAMPLES-LICENSE.TXT +18 -0
  75. data/samples/aui/aui.rb +1356 -0
  76. data/samples/bigdemo/About.rbw +39 -0
  77. data/samples/bigdemo/ColorPanel.rbw +23 -0
  78. data/samples/bigdemo/GridSimple.rbw +78 -0
  79. data/samples/bigdemo/MDIDemo.rbw +57 -0
  80. data/samples/bigdemo/PopupMenu.rbw +149 -0
  81. data/samples/bigdemo/ShapedWindow.rbw +131 -0
  82. data/samples/bigdemo/Sizers.rbw +543 -0
  83. data/samples/bigdemo/bigdemo.rb +823 -0
  84. data/samples/bigdemo/demoTemplate.rbw +33 -0
  85. data/samples/bigdemo/helpfile.htb +0 -0
  86. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  87. data/samples/bigdemo/icons/Test 015.png +0 -0
  88. data/samples/bigdemo/icons/choice.bmp +0 -0
  89. data/samples/bigdemo/icons/choice.xpm +27 -0
  90. data/samples/bigdemo/icons/combo.bmp +0 -0
  91. data/samples/bigdemo/icons/combo.xpm +27 -0
  92. data/samples/bigdemo/icons/copy.xpm +25 -0
  93. data/samples/bigdemo/icons/cut.xpm +24 -0
  94. data/samples/bigdemo/icons/gauge.bmp +0 -0
  95. data/samples/bigdemo/icons/gauge.xpm +27 -0
  96. data/samples/bigdemo/icons/help.xpm +25 -0
  97. data/samples/bigdemo/icons/list.bmp +0 -0
  98. data/samples/bigdemo/icons/list.xpm +27 -0
  99. data/samples/bigdemo/icons/mondrian.ico +0 -0
  100. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  101. data/samples/bigdemo/icons/new.xpm +24 -0
  102. data/samples/bigdemo/icons/ogl.ico +0 -0
  103. data/samples/bigdemo/icons/ogl.xpm +45 -0
  104. data/samples/bigdemo/icons/open.xpm +26 -0
  105. data/samples/bigdemo/icons/paste.bmp +0 -0
  106. data/samples/bigdemo/icons/paste.xpm +38 -0
  107. data/samples/bigdemo/icons/pointy.png +0 -0
  108. data/samples/bigdemo/icons/preview.xpm +26 -0
  109. data/samples/bigdemo/icons/print.xpm +26 -0
  110. data/samples/bigdemo/icons/radio.bmp +0 -0
  111. data/samples/bigdemo/icons/radio.xpm +27 -0
  112. data/samples/bigdemo/icons/robert.xpm +415 -0
  113. data/samples/bigdemo/icons/ruby.png +0 -0
  114. data/samples/bigdemo/icons/sashtest.ico +0 -0
  115. data/samples/bigdemo/icons/save.xpm +25 -0
  116. data/samples/bigdemo/icons/smiles.bmp +0 -0
  117. data/samples/bigdemo/icons/smiles.xpm +39 -0
  118. data/samples/bigdemo/icons/smiley.ico +0 -0
  119. data/samples/bigdemo/icons/smiley.xpm +42 -0
  120. data/samples/bigdemo/icons/stattext.xpm +24 -0
  121. data/samples/bigdemo/icons/test2.bmp +0 -0
  122. data/samples/bigdemo/icons/test2.png +0 -0
  123. data/samples/bigdemo/icons/test2.xpm +79 -0
  124. data/samples/bigdemo/icons/text.bmp +0 -0
  125. data/samples/bigdemo/icons/text.xpm +27 -0
  126. data/samples/bigdemo/icons/tog1.bmp +0 -0
  127. data/samples/bigdemo/icons/tog1.xpm +38 -0
  128. data/samples/bigdemo/icons/tog2.bmp +0 -0
  129. data/samples/bigdemo/icons/tog2.xpm +38 -0
  130. data/samples/bigdemo/icons/wxwin.ico +0 -0
  131. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  132. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  133. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  134. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  135. data/samples/bigdemo/run.rb +90 -0
  136. data/samples/bigdemo/tips.txt +7 -0
  137. data/samples/bigdemo/utils.rb +12 -0
  138. data/samples/bigdemo/wxArtProvider.rbw +281 -0
  139. data/samples/bigdemo/wxBitmapButton.rbw +65 -0
  140. data/samples/bigdemo/wxButton.rbw +64 -0
  141. data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
  142. data/samples/bigdemo/wxCheckBox.rbw +50 -0
  143. data/samples/bigdemo/wxCheckListBox.rbw +65 -0
  144. data/samples/bigdemo/wxChoice.rbw +47 -0
  145. data/samples/bigdemo/wxChoicebook.rbw +78 -0
  146. data/samples/bigdemo/wxColourDialog.rbw +31 -0
  147. data/samples/bigdemo/wxComboBox.rbw +77 -0
  148. data/samples/bigdemo/wxCursor.rbw +136 -0
  149. data/samples/bigdemo/wxDialog.rbw +74 -0
  150. data/samples/bigdemo/wxDirDialog.rbw +29 -0
  151. data/samples/bigdemo/wxDragImage.rbw +70 -0
  152. data/samples/bigdemo/wxFileDialog.rbw +37 -0
  153. data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
  154. data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
  155. data/samples/bigdemo/wxFontDialog.rbw +173 -0
  156. data/samples/bigdemo/wxFrame.rbw +53 -0
  157. data/samples/bigdemo/wxGauge.rbw +71 -0
  158. data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
  159. data/samples/bigdemo/wxGrid.rbw +66 -0
  160. data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
  161. data/samples/bigdemo/wxListBox.rbw +140 -0
  162. data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -0
  163. data/samples/bigdemo/wxMDIWindows.rbw +50 -0
  164. data/samples/bigdemo/wxMenu.rbw +236 -0
  165. data/samples/bigdemo/wxMessageDialog.rbw +27 -0
  166. data/samples/bigdemo/wxMiniFrame.rbw +70 -0
  167. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
  168. data/samples/bigdemo/wxNotebook.rbw +136 -0
  169. data/samples/bigdemo/wxProgressDialog.rbw +43 -0
  170. data/samples/bigdemo/wxRadioBox.rbw +72 -0
  171. data/samples/bigdemo/wxRadioButton.rbw +125 -0
  172. data/samples/bigdemo/wxSashWindow.rbw +141 -0
  173. data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
  174. data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
  175. data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
  176. data/samples/bigdemo/wxSlider.rbw +42 -0
  177. data/samples/bigdemo/wxSpinButton.rbw +50 -0
  178. data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
  179. data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
  180. data/samples/bigdemo/wxStaticBitmap.rbw +51 -0
  181. data/samples/bigdemo/wxStaticText.rbw +55 -0
  182. data/samples/bigdemo/wxStatusBar.rbw +126 -0
  183. data/samples/bigdemo/wxTextCtrl.rbw +149 -0
  184. data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
  185. data/samples/bigdemo/wxToggleButton.rbw +49 -0
  186. data/samples/bigdemo/wxToolBar.rbw +131 -0
  187. data/samples/bigdemo/wxTreeCtrl.rbw +191 -0
  188. data/samples/calendar/calendar.rb +256 -0
  189. data/samples/caret/caret.rb +282 -0
  190. data/samples/caret/mondrian.xpm +44 -0
  191. data/samples/controls/controls.rb +1136 -0
  192. data/samples/controls/get_item_sample.rb +87 -0
  193. data/samples/controls/icons/choice.xpm +27 -0
  194. data/samples/controls/icons/combo.xpm +27 -0
  195. data/samples/controls/icons/gauge.xpm +27 -0
  196. data/samples/controls/icons/list.xpm +27 -0
  197. data/samples/controls/icons/radio.xpm +27 -0
  198. data/samples/controls/icons/stattext.xpm +24 -0
  199. data/samples/controls/icons/text.xpm +27 -0
  200. data/samples/controls/mondrian.ico +0 -0
  201. data/samples/controls/mondrian.xpm +44 -0
  202. data/samples/controls/test2.bmp +0 -0
  203. data/samples/dialogs/dialogs.rb +797 -0
  204. data/samples/dialogs/tips.txt +18 -0
  205. data/samples/dragdrop/dragdrop.rb +177 -0
  206. data/samples/drawing/graphics_drawing.rb +235 -0
  207. data/samples/drawing/images.rb +37 -0
  208. data/samples/drawing/paperclip.png +0 -0
  209. data/samples/etc/activation.rb +102 -0
  210. data/samples/etc/choice.rb +67 -0
  211. data/samples/etc/miniframe.rb +79 -0
  212. data/samples/etc/sash.rb +130 -0
  213. data/samples/etc/scrollwin.rb +110 -0
  214. data/samples/etc/system_settings.rb +252 -0
  215. data/samples/etc/threaded.rb +72 -0
  216. data/samples/etc/toolbar_sizer_additem.rb +55 -0
  217. data/samples/etc/wizard.rb +74 -0
  218. data/samples/event/event.rb +182 -0
  219. data/samples/event/update_ui_event.rb +70 -0
  220. data/samples/grid/grid.rb +198 -0
  221. data/samples/grid/gridtablebase.rb +148 -0
  222. data/samples/html/html.rb +262 -0
  223. data/samples/listbook/listbook.rb +174 -0
  224. data/samples/listbook/listbook.xrc +370 -0
  225. data/samples/mdi/mdi.rb +85 -0
  226. data/samples/media/mediactrl.rb +167 -0
  227. data/samples/minimal/minimal.rb +77 -0
  228. data/samples/minimal/mondrian.ico +0 -0
  229. data/samples/minimal/mondrian.png +0 -0
  230. data/samples/minimal/nothing.rb +16 -0
  231. data/samples/opengl/cube.rb +117 -0
  232. data/samples/printing/mondrian.ico +0 -0
  233. data/samples/printing/mondrian.xpm +44 -0
  234. data/samples/printing/printing.rb +487 -0
  235. data/samples/sockets/SocketPackets.rb +27 -0
  236. data/samples/sockets/res/message-new.png +0 -0
  237. data/samples/sockets/res/user.png +0 -0
  238. data/samples/sockets/wxClient.rb +395 -0
  239. data/samples/sockets/wxServer.rb +422 -0
  240. data/samples/sockets/wxSocketGUI.rb +97 -0
  241. data/samples/text/format-text-bold.png +0 -0
  242. data/samples/text/format-text-italic.png +0 -0
  243. data/samples/text/format-text-underline.png +0 -0
  244. data/samples/text/mondrian.ico +0 -0
  245. data/samples/text/mondrian.xpm +44 -0
  246. data/samples/text/rich_textctrl.rb +98 -0
  247. data/samples/text/scintilla.rb +169 -0
  248. data/samples/text/textctrl.rb +111 -0
  249. data/samples/text/unicode.rb +242 -0
  250. data/samples/text/utf8.txt +15 -0
  251. data/samples/treectrl/icon1.xpm +79 -0
  252. data/samples/treectrl/icon2.xpm +53 -0
  253. data/samples/treectrl/icon3.xpm +79 -0
  254. data/samples/treectrl/icon4.xpm +43 -0
  255. data/samples/treectrl/icon5.xpm +79 -0
  256. data/samples/treectrl/treectrl.rb +1166 -0
  257. data/samples/xrc/samples.xrc +46 -0
  258. data/samples/xrc/xrc_sample.rb +76 -0
  259. metadata +234 -220
@@ -0,0 +1,169 @@
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
+ include Wx
11
+
12
+
13
+ Minimal_Quit = 1
14
+ Minimal_About = ID_ABOUT
15
+ Toggle_Whitespace = 5000
16
+ Toggle_EOL = 5001
17
+
18
+ class MyFrame < Frame
19
+ def initialize(title,pos,size,style=DEFAULT_FRAME_STYLE)
20
+ super(nil,-1,title,pos,size,style)
21
+
22
+ menuFile = Menu.new()
23
+ menuFile.append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program")
24
+
25
+ menuView = Menu.new()
26
+ menuView.append(Toggle_Whitespace, "Show &Whitespace\tF6", "Show Whitespace", ITEM_CHECK)
27
+ menuView.append(Toggle_EOL, "Show &End of Line\tF7", "Show End of Line characters", ITEM_CHECK)
28
+
29
+ menuHelp = Menu.new()
30
+ menuHelp.append(Minimal_About, "&About...\tF1", "Show about dialog")
31
+
32
+ menuBar = MenuBar.new()
33
+ menuBar.append(menuFile, "&File")
34
+ menuBar.append(menuView, "&View")
35
+ menuBar.append(menuHelp, "&Help")
36
+ set_menu_bar(menuBar)
37
+
38
+ tb = create_tool_bar(Wx::TB_HORIZONTAL | Wx::NO_BORDER | Wx::TB_FLAT | Wx::TB_TEXT)
39
+
40
+ create_status_bar(2)
41
+ set_status_text("Welcome to wxRuby!")
42
+
43
+ @sci = Wx::StyledTextCtrl.new(self)
44
+
45
+ font = Font.new(10, TELETYPE, NORMAL, NORMAL)
46
+ @sci.style_set_font(STC_STYLE_DEFAULT, font);
47
+
48
+ @ws_visible = false
49
+ @eol_visible = false
50
+ @sci.set_edge_mode(STC_EDGE_LINE)
51
+
52
+ line_num_margin = @sci.text_width(STC_STYLE_LINENUMBER, "_99999")
53
+ @sci.set_margin_width(0, line_num_margin)
54
+
55
+ @sci.style_set_foreground(STC_STYLE_DEFAULT, BLACK);
56
+ @sci.style_set_background(STC_STYLE_DEFAULT, WHITE);
57
+ @sci.style_set_foreground(STC_STYLE_LINENUMBER, LIGHT_GREY);
58
+ @sci.style_set_background(STC_STYLE_LINENUMBER, WHITE);
59
+ @sci.style_set_foreground(STC_STYLE_INDENTGUIDE, LIGHT_GREY);
60
+
61
+ @sci.set_tab_width(4)
62
+ @sci.set_use_tabs(false)
63
+ @sci.set_tab_indents(true)
64
+ @sci.set_back_space_un_indents(true)
65
+ @sci.set_indent(4)
66
+ @sci.set_edge_column(80)
67
+
68
+ @sci.set_lexer(STC_LEX_RUBY)
69
+ @sci.style_clear_all
70
+ @sci.style_set_foreground(2, RED)
71
+ @sci.style_set_foreground(3, GREEN)
72
+ @sci.style_set_foreground(5, BLUE)
73
+ @sci.style_set_foreground(6, BLUE)
74
+ @sci.style_set_foreground(7, BLUE)
75
+ @sci.set_key_words(0, "begin break elsif module retry unless end case next return until class ensure nil self when def false not super while alias defined? for or then yield and do if redo true else in rescue undef")
76
+
77
+ @sci.set_property("fold","1")
78
+ @sci.set_property("fold.compact", "0")
79
+ @sci.set_property("fold.comment", "1")
80
+ @sci.set_property("fold.preprocessor", "1")
81
+
82
+ @sci.set_margin_width(1, 0)
83
+ @sci.set_margin_type(1, STC_MARGIN_SYMBOL)
84
+ @sci.set_margin_mask(1, STC_MASK_FOLDERS)
85
+ @sci.set_margin_width(1, 20)
86
+
87
+ @sci.marker_define(STC_MARKNUM_FOLDER, STC_MARK_PLUS)
88
+ @sci.marker_define(STC_MARKNUM_FOLDEROPEN, STC_MARK_MINUS)
89
+ @sci.marker_define(STC_MARKNUM_FOLDEREND, STC_MARK_EMPTY)
90
+ @sci.marker_define(STC_MARKNUM_FOLDERMIDTAIL, STC_MARK_EMPTY)
91
+ @sci.marker_define(STC_MARKNUM_FOLDEROPENMID, STC_MARK_EMPTY)
92
+ @sci.marker_define(STC_MARKNUM_FOLDERSUB, STC_MARK_EMPTY)
93
+ @sci.marker_define(STC_MARKNUM_FOLDERTAIL, STC_MARK_EMPTY)
94
+ @sci.set_fold_flags(16)
95
+
96
+ @sci.set_margin_sensitive(1,1)
97
+
98
+ evt_menu(Minimal_Quit) {onQuit}
99
+ evt_menu(Minimal_About) {onAbout}
100
+ evt_menu(Toggle_Whitespace) {onWhitespace}
101
+ evt_menu(Toggle_EOL) {onEOL}
102
+ evt_stc_charadded(@sci.get_id) {|evt| onCharadded(evt)}
103
+ evt_stc_marginclick(@sci.get_id) {|evt| onMarginClick(evt)}
104
+
105
+ end
106
+
107
+ def onQuit
108
+ close(TRUE)
109
+ end
110
+
111
+ def onAbout
112
+ GC.start
113
+ msg = sprintf("This is the About dialog of the scintilla sample.\n" \
114
+ "Welcome to %s", VERSION_STRING)
115
+
116
+ message_box(msg, "About Scintilla", OK | ICON_INFORMATION, self)
117
+
118
+ end
119
+
120
+ def onWhitespace
121
+ @ws_visible = !@ws_visible
122
+ @sci.set_view_white_space(@ws_visible ? STC_WS_VISIBLEALWAYS : STC_WS_INVISIBLE)
123
+ end
124
+
125
+ def onEOL
126
+ @eol_visible = !@eol_visible
127
+ @sci.set_view_eol(@eol_visible)
128
+ end
129
+
130
+ def onCharadded(evt)
131
+ chr = evt.get_key
132
+ curr_line = @sci.get_current_line
133
+
134
+ if(chr == 13)
135
+ if curr_line > 0
136
+ line_ind = @sci.get_line_indentation(curr_line - 1)
137
+ if line_ind > 0
138
+ @sci.set_line_indentation(curr_line, line_ind)
139
+ @sci.goto_pos(@sci.position_from_line(curr_line)+line_ind)
140
+ end
141
+ end
142
+ end
143
+ end
144
+
145
+ def onMarginClick(evt)
146
+ line_num = @sci.line_from_position(evt.get_position)
147
+ margin = evt.get_margin
148
+
149
+ if(margin == 1)
150
+ @sci.toggle_fold(line_num)
151
+ end
152
+ end
153
+
154
+ end
155
+
156
+ class RbApp < App
157
+ def on_init
158
+ frame = MyFrame.new("wxRuby Scintilla App",Point.new(50, 50), Size.new(450, 340))
159
+
160
+ frame.show(TRUE)
161
+
162
+ end
163
+ end
164
+
165
+ a = RbApp.new
166
+ a.main_loop()
167
+ puts("back from main_loop...")
168
+ GC.start
169
+ puts("survived gc")
@@ -0,0 +1,111 @@
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
+ class InformativeTextCtrl < Wx::TextCtrl
11
+ # These text controls are multiline, and may have rich (coloured,
12
+ # styled) text in them
13
+ STYLE = Wx::TE_MULTILINE|Wx::TE_RICH|Wx::TE_RICH2
14
+ def initialize(parent, text = '')
15
+ super(parent, :value => text, :style => STYLE)
16
+ end
17
+
18
+ # more ruby-ish
19
+ alias :<< :append_text
20
+
21
+ # run through a few useful methods of textctrl and report the results
22
+ # as a string
23
+ def report()
24
+ report = ''
25
+ report << 'Insertion Point: ' << get_insertion_point.to_s() << "\n"
26
+ report << 'First Line Text: ' << get_line_text(0) << "\n"
27
+ report << 'Final Position: ' << get_last_position().to_s() << "\n"
28
+ report << 'Selection: ' << get_selection().inspect() << "\n"
29
+ report << 'String Selection: ' << get_string_selection().inspect << "\n"
30
+ report << 'Position to X, Y: ' <<
31
+ position_to_xy( get_insertion_point ).inspect
32
+ return report
33
+ end
34
+ end
35
+
36
+ # A read-only text ctrl useful for displaying output
37
+ class LogTextCtrl < Wx::TextCtrl
38
+ STYLE = Wx::TE_READONLY|Wx::TE_MULTILINE
39
+ def initialize(parent)
40
+ super(parent, :style => STYLE)
41
+ end
42
+ end
43
+
44
+ class TextCtrlFrame < Wx::Frame
45
+ def initialize(*args)
46
+ super(nil, *args)
47
+
48
+ panel = Wx::Panel.new(self)
49
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
50
+
51
+ @textctrl = InformativeTextCtrl.new(panel)
52
+ populate_textctrl()
53
+ sizer.add(@textctrl, 2, Wx::GROW|Wx::ALL, 2)
54
+
55
+ button = Wx::Button.new(panel, :label => 'Get Info')
56
+ sizer.add(button, 0, Wx::ADJUST_MINSIZE|Wx::ALL, 2 )
57
+ evt_button button, :on_click
58
+
59
+ @log = LogTextCtrl.new(panel)
60
+ sizer.add(@log, 1, Wx::GROW|Wx::ALL, 2)
61
+ panel.sizer = sizer
62
+ end
63
+
64
+ def populate_textctrl()
65
+ @textctrl << "This is some plain text\n"
66
+ @textctrl << "Text with green letters and yellow background\n"
67
+ @textctrl << "This is some more plain text"
68
+ # create a new rich text style
69
+ attr = Wx::TextAttr.new(Wx::GREEN, Wx::Colour.new(255, 255, 0) )
70
+ # apply the style from character 26 to character 76
71
+ @textctrl.set_style(24, 69, attr)
72
+ end
73
+
74
+ def construct_menus()
75
+ menu_bar = Wx::MenuBar.new()
76
+
77
+ menu_file = Wx::Menu.new()
78
+ menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
79
+ menu_bar.append(menu_file, "&File")
80
+ evt_menu Wx::ID_EXIT, :on_quit
81
+
82
+ menu_help = Wx::Menu.new()
83
+ menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
84
+ evt_menu Wx::ID_ABOUT, :on_about
85
+ menu_bar.append(menu_help, "&Help")
86
+
87
+ self.menu_bar = menu_bar
88
+ end
89
+
90
+ def on_click
91
+ @log.value = @textctrl.report
92
+ end
93
+
94
+ def on_quit
95
+ close
96
+ end
97
+
98
+ def on_about
99
+ msg = sprintf("This is the About dialog of the textctrl sample.\n" \
100
+ "Welcome to %s", Wx::VERSION_STRING)
101
+ message_box(msg, "About Minimal", Wx::OK|Wx::ICON_INFORMATION, self)
102
+ end
103
+ end
104
+
105
+ Wx::App.run do
106
+ frame = TextCtrlFrame.new( :title => "TextCtrl demonstration",
107
+ :pos => [ 50, 50 ],
108
+ :size => [ 450, 340 ] )
109
+ frame.show
110
+ end
111
+
@@ -0,0 +1,242 @@
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
+ # Tell ruby this script is written in UTF-8 encoded text.
9
+ $KCODE = 'u'
10
+
11
+ # Library to get character lengths (as opposed to byte lengths) from
12
+ # Ruby strings.
13
+ require 'jcode'
14
+
15
+ require 'wx'
16
+
17
+ $utf8_file = File.join( File.dirname(__FILE__), 'utf8.txt')
18
+
19
+ class UnicodeDemoTextCtrl < Wx::TextCtrl
20
+ NEWLINE_CORRECTION_FACTOR = 0
21
+
22
+ DEFAULT_TEXT = "If you have a unicode version of wxruby, you should be able to see a range of characters from different languages displayed, and be able to type multilingual strings in the text area. Note that some scripts may only be displayed if you are using a suitable font; otherwise characters will appear as blank boxes.
23
+
24
+ " << File.read( $utf8_file )
25
+
26
+ def initialize(parent, text = DEFAULT_TEXT)
27
+ super(parent, -1, text,
28
+ Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::TE_MULTILINE)
29
+ end
30
+
31
+ # run through a few useful methods of textctrl and report the results
32
+ # as a string
33
+ def report()
34
+ report = ''
35
+ sel = get_string_selection()
36
+ report << 'Selected string byte length: ' << sel.length.to_s << "\n"
37
+ report << 'Selected string character length: ' << sel.jlength.to_s << "\n"
38
+ report << 'Selected string:: ' << sel.inspect << "\n"
39
+ return report
40
+ end
41
+ end
42
+
43
+ # A read-only text ctrl useful for displaying output
44
+ class LogTextCtrl < Wx::TextCtrl
45
+ STYLE = Wx::TE_READONLY|Wx::TE_MULTILINE
46
+ def initialize(parent)
47
+ super(parent, -1, '', Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, STYLE)
48
+ end
49
+ end
50
+
51
+ class IConvFrame < Wx::Frame
52
+ # Ruby stdlib for converting strings between encodings
53
+ begin
54
+ require 'iconv'
55
+ ICONV_LOADED = 1
56
+ rescue LoadError
57
+ end
58
+
59
+ # The encodings we're going to make importable and exportable in this
60
+ # application - see construct_import_export_menus below
61
+ ENCODINGS = { 'US ASCII' => 'ASCII',
62
+ 'UTF-8' => 'UTF-8',
63
+ 'UTF-16' => 'UTF-16',
64
+ 'Windows Latin CP1252' => 'CP1252',
65
+ 'Latin ISO-8859-1' => 'ISO-8859-1',
66
+ 'Japanese SHIFT-JIS' => 'SHIFT-JIS' }
67
+
68
+ def initialize(title, pos, size)
69
+ super(nil, -1, title, pos, size)
70
+ panel = Wx::Panel.new(self)
71
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
72
+
73
+ sys_lang = Wx::Locale.get_system_language_name
74
+ text = Wx::StaticText.new(panel, -1, "System language: #{sys_lang}")
75
+ sizer.add(text, 0, Wx::ALL, 5)
76
+
77
+ sys_enc = Wx::Locale.get_system_encoding_name
78
+ text = Wx::StaticText.new(panel, -1, "System default encoding: #{sys_enc}")
79
+ sizer.add(text, 0, Wx::ALL, 5)
80
+
81
+ # The text input and display
82
+ @textctrl = UnicodeDemoTextCtrl.new(panel)
83
+ sizer.add(@textctrl, 3, Wx::GROW|Wx::ALL, 2)
84
+
85
+ # The button to show what's selected
86
+ button = Wx::Button.new(panel, -1, 'Describe text selection')
87
+ sizer.add(button, 0, Wx::ADJUST_MINSIZE|Wx::ALL, 2 )
88
+ evt_button(button.get_id) { | e | on_click(e) }
89
+
90
+ @log = LogTextCtrl.new(panel)
91
+ sizer.add(@log, 1, Wx::GROW|Wx::ALL, 2)
92
+ sizer.add( Wx::StaticText.new(panel, -1, 'Some controls with unicode'),
93
+ 0, Wx::ADJUST_MINSIZE|Wx::ALL, 2 )
94
+ ctrl_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)
95
+
96
+ test_button = Wx::Button.new(panel, -1, '万')
97
+ ctrl_sizer.add(test_button, 0, Wx::ADJUST_MINSIZE|Wx::ALL, 2)
98
+ choice = Wx::Choice.new(panel, -1, Wx::DEFAULT_POSITION,
99
+ Wx::DEFAULT_SIZE, [])
100
+ File.readlines($utf8_file).each do | line |
101
+ next if line.chomp.empty?
102
+ choice.append(line.chomp)
103
+ end
104
+ choice.set_selection(0)
105
+ ctrl_sizer.add(choice, 0, Wx::ADJUST_MINSIZE|Wx::ALL, 2)
106
+
107
+ sizer.add(ctrl_sizer, 0, Wx::ADJUST_MINSIZE|Wx::ALL, 2)
108
+ construct_menus()
109
+ panel.set_sizer_and_fit( sizer )
110
+ end
111
+
112
+ # Prompt the user to specify a file whose contents should be loaded
113
+ # into the text ctrl. The file should be encoded in +encoding+
114
+ def on_import_file(encoding)
115
+ fd = Wx::FileDialog.new( nil, 'Import file', "", "",
116
+ "*.*", Wx::OPEN|Wx::FILE_MUST_EXIST )
117
+ return unless fd.show_modal() == Wx::ID_OK
118
+ File.open( fd.get_path ) do | file |
119
+ import_file( file, encoding )
120
+ end
121
+ rescue Iconv::IllegalSequence
122
+ message = "The file %s does not seem to be in %s encoding " %
123
+ [ fd.get_filename, encoding ]
124
+ Wx::MessageDialog.new(self, message, 'Wrong encoding',
125
+ Wx::OK|Wx::ICON_EXCLAMATION).show_modal()
126
+ end
127
+
128
+ # Read +io+, which should be text file encoding in +source_encoding+,
129
+ # and display the contents in the textctrl.
130
+ def import_file(io, source_encoding = 'UTF-8')
131
+ case source_encoding
132
+ when /UTF-?8/
133
+ @textctrl.set_value( io.read() )
134
+ else
135
+ output = ''
136
+ Iconv.open('UTF-8', source_encoding) do | converter |
137
+ output << converter.iconv( io.read() )
138
+ output << converter.iconv(nil)
139
+ end
140
+ @textctrl.set_value( output )
141
+ end
142
+ end
143
+
144
+ # Ask the user for a file path, and then export the content of the
145
+ # textctrl to it in the encoding +encoding+
146
+ def on_export_file(encoding)
147
+ fd = Wx::FileDialog.new( nil, 'Export file', "", "",
148
+ "*.*", Wx::SAVE|Wx::OVERWRITE_PROMPT )
149
+ return unless fd.show_modal() == Wx::ID_OK
150
+ File.open( fd.get_path, 'w' ) do | file |
151
+ export_file( file, encoding )
152
+ end
153
+ rescue Iconv::IllegalSequence
154
+ message = "The text content containts characters that " <<
155
+ "cannot be encoded using %s" % encoding
156
+ Wx::MessageDialog.new(self, message, 'Invalid encoding',
157
+ Wx::OK|Wx::ICON_EXCLAMATION).show_modal()
158
+ end
159
+
160
+ # Write the content of the textctrl to the file or io +io+, encoding
161
+ # the text in encoding +target_encoding+
162
+ def export_file(io, target_encoding = 'utf-8')
163
+ case target_encoding
164
+ when /UTF-?8/
165
+ io.write( @textctrl.get_value )
166
+ else
167
+ Iconv.open(target_encoding, 'UTF-8') do | converter |
168
+ io << converter.iconv( @textctrl.get_value )
169
+ io << converter.iconv(nil)
170
+ end
171
+ end
172
+ end
173
+
174
+ def construct_menus()
175
+ menu_bar = Wx::MenuBar.new()
176
+
177
+ menu_file = Wx::Menu.new()
178
+ menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
179
+ evt_menu(Wx::ID_EXIT) { on_quit() }
180
+ menu_bar.append(menu_file, "&File")
181
+ if self.class.const_defined?(:ICONV_LOADED)
182
+ construct_import_export_menus(menu_bar)
183
+ end
184
+
185
+ menu_help = Wx::Menu.new()
186
+ menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
187
+ evt_menu(Wx::ID_ABOUT) { on_about() }
188
+ menu_bar.append(menu_help, "&Help")
189
+
190
+ set_menu_bar(menu_bar)
191
+ end
192
+
193
+ def construct_import_export_menus(menu_bar)
194
+ id_counter = 0
195
+ menu_import = Wx::Menu.new()
196
+
197
+ ENCODINGS.each do | desc, enc |
198
+ id_counter += 1
199
+ menu_import.append(id_counter, "Import (#{desc})",
200
+ "Import a file in #{desc} encoding")
201
+
202
+ evt_menu(id_counter) { on_import_file(enc) }
203
+ end
204
+ menu_bar.append(menu_import, '&Import')
205
+
206
+ menu_export = Wx::Menu.new()
207
+ ENCODINGS.each do | desc, enc |
208
+ id_counter += 1
209
+ menu_export.append(id_counter, "Export (#{desc})",
210
+ "Export a file in #{desc} encoding")
211
+
212
+ evt_menu(id_counter) { on_export_file(enc) }
213
+ end
214
+ menu_bar.append(menu_export, '&Export')
215
+ end
216
+
217
+ def on_click(e)
218
+ @log.set_value( @textctrl.report() )
219
+ end
220
+
221
+ def on_quit()
222
+ close(TRUE)
223
+ end
224
+
225
+ def on_about()
226
+ msg = sprintf("This is the About dialog of the Unicode sample.\n" \
227
+ "Welcome to %s", Wx::VERSION_STRING)
228
+ Wx::message_box(msg, "About Minimal", Wx::OK|Wx::ICON_INFORMATION, self)
229
+ end
230
+ end
231
+
232
+ class IConvApp < Wx::App
233
+ def on_init()
234
+ frame = IConvFrame.new("Unicode demonstration - ",
235
+ Wx::Point.new(50, 50),
236
+ Wx::Size.new(450, 450) )
237
+
238
+ frame.show(true)
239
+ end
240
+ end
241
+
242
+ IConvApp.new().main_loop()
@@ -0,0 +1,15 @@
1
+ Western European: ÀÉÎè
2
+
3
+ Chinese (Simplified): 丁万不㐀㐁丣並
4
+
5
+ Extended Latin: ĀčŁœ
6
+
7
+ Japanese Hiragana: あきぐけ゚
8
+
9
+ Arabic: ؟تص
10
+
11
+ Cyrillic: ЀЋЖ
12
+
13
+ Greek: Άαξ
14
+
15
+ Korean: 了丫乖
@@ -0,0 +1,79 @@
1
+ /* XPM */
2
+ static char *icon1_xpm[] = {
3
+ /* columns rows colors chars-per-pixel */
4
+ "32 32 41 1",
5
+ "> c #97C4E7",
6
+ "# c #4381AA",
7
+ "d c #FFFFFF",
8
+ "< c #71B2DE",
9
+ "+ c #538BB1",
10
+ "& c #D1E5F5",
11
+ "q c #63B3DE",
12
+ "6 c #F1F4F7",
13
+ "* c #CAE1F3",
14
+ "y c #7AC4E5",
15
+ "= c #C3DDF1",
16
+ "X c #74A1BD",
17
+ "- c #BCD9EF",
18
+ "5 c #619BC4",
19
+ "3 c #E6EAF1",
20
+ "2 c #4B8EBF",
21
+ "o c #6B97B6",
22
+ ". c #4B82A8",
23
+ " c None",
24
+ "w c #54A6D8",
25
+ "1 c #71A8D1",
26
+ ", c #85BBE2",
27
+ "t c #EFF6FC",
28
+ "7 c #DEEDF8",
29
+ "@ c #4388B4",
30
+ "a c #F7FBFD",
31
+ "$ c #D7E0E9",
32
+ "r c #FAFCFE",
33
+ "4 c #DAEAF7",
34
+ "e c #E9F3FA",
35
+ "0 c #76BAE2",
36
+ "% c #7FA6C0",
37
+ "s c #FDFDFE",
38
+ "O c #5896BE",
39
+ "p c #B6D5EE",
40
+ "8 c #87ABC3",
41
+ ": c #A5CCEA",
42
+ "9 c #E5F0F9",
43
+ "; c #AFD1EC",
44
+ "i c #F4F9FD",
45
+ "u c #8FB0C3",
46
+ /* pixels */
47
+ " ",
48
+ " ",
49
+ " ",
50
+ " ",
51
+ " ",
52
+ " .XXXooOO++@#$ ",
53
+ " %&*=-;:>>,<123 ",
54
+ " %4&*=-;:>>,1>56 ",
55
+ " %74&*=-;:>>1*>56 ",
56
+ " 89700qqqqwq1e*>X ",
57
+ " 8e974&*=-;:1re*>8 ",
58
+ " 8te974&*=-;11111# ",
59
+ " 8tty000qqqqqww>,+ ",
60
+ " uitte974&*=-p:>>+ ",
61
+ " uaitte974&*=-p:>O ",
62
+ " uaayyyy000qqqqp:O ",
63
+ " uraaitte974&*=-po ",
64
+ " urraaitte974&*=-o ",
65
+ " usryyyyyyy000q*=X ",
66
+ " ussrraaitte974&*X ",
67
+ " udssrraaitte974&X ",
68
+ " uddyyyyyyyyyy074% ",
69
+ " udddssrraaitte97% ",
70
+ " uddddssrraaitte9% ",
71
+ " udddddssrraaitte8 ",
72
+ " uddddddssrraaitt8 ",
73
+ " uuuuuuuuuuuuuu88u ",
74
+ " ",
75
+ " ",
76
+ " ",
77
+ " ",
78
+ " "
79
+ };
@@ -0,0 +1,53 @@
1
+ /* XPM */
2
+ static char *icon2_xpm[] = {
3
+ /* columns rows colors chars-per-pixel */
4
+ "32 32 15 1",
5
+ ". c Black",
6
+ "O c #97C4E7",
7
+ "$ c #63B3DE",
8
+ "@ c #CAE1F3",
9
+ "; c #7AC4E5",
10
+ "* c #74A1BD",
11
+ "+ c #619BC4",
12
+ "o c #4B8EBF",
13
+ " c None",
14
+ "% c #54A6D8",
15
+ "= c #FAFCFE",
16
+ "& c #E9F3FA",
17
+ "# c #76BAE2",
18
+ "X c #C00000",
19
+ "- c #87ABC3",
20
+ /* pixels */
21
+ " ",
22
+ " ",
23
+ " ",
24
+ " ",
25
+ " ",
26
+ " ............. ",
27
+ " .XXXXXXXXXX.o. ",
28
+ " .XXXXXXXXXX.O+. ",
29
+ " .XXXXXXXXXX.@O+. ",
30
+ " .XX##$$$$%$.&@O* ",
31
+ " .XXXXXXXXXX.=&@O- ",
32
+ " .XXXXXXXXXX...... ",
33
+ " .XX;###$$$$$%%XX. ",
34
+ " .XXXXXXXXXXXXXXX. ",
35
+ " .XXXXXXXXXXXXXXX. ",
36
+ " .XX;;;;###$$$$XX. ",
37
+ " .XXXXXXXXXXXXXXX. ",
38
+ " .XXXXXXXXXXXXXXX. ",
39
+ " .XX;;;;;;;###$XX. ",
40
+ " .XXXXXXXXXXXXXXX. ",
41
+ " .XXXXXXXXXXXXXXX. ",
42
+ " .XX;;;;;;;;;;#XX. ",
43
+ " .XXXXXXXXXXXXXXX. ",
44
+ " .XXXXXXXXXXXXXXX. ",
45
+ " .XXXXXXXXXXXXXXX. ",
46
+ " .XXXXXXXXXXXXXXX. ",
47
+ " ................. ",
48
+ " ",
49
+ " ",
50
+ " ",
51
+ " ",
52
+ " "
53
+ };