rwx 0.0.1.dev

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.
Files changed (376) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +49 -0
  3. data/COPYING +0 -0
  4. data/README.rdoc +0 -0
  5. data/Rakefile +100 -0
  6. data/VERSION +1 -0
  7. data/ext/extconf.rb +112 -0
  8. data/ext/main.cpp +432 -0
  9. data/ext/main.hpp +454 -0
  10. data/ext/rwx.cpp +472 -0
  11. data/ext/wxAboutDlg.cpp +213 -0
  12. data/ext/wxAboutDlg.hpp +19 -0
  13. data/ext/wxAnyButton.cpp +141 -0
  14. data/ext/wxAnyButton.hpp +17 -0
  15. data/ext/wxAnyChoiceDialog.cpp +93 -0
  16. data/ext/wxAnyChoiceDialog.hpp +19 -0
  17. data/ext/wxApp.cpp +205 -0
  18. data/ext/wxApp.hpp +48 -0
  19. data/ext/wxAui.hpp +19 -0
  20. data/ext/wxAuiBook.cpp +453 -0
  21. data/ext/wxAuiBook.hpp +21 -0
  22. data/ext/wxAuiManager.cpp +79 -0
  23. data/ext/wxAuiManager.hpp +18 -0
  24. data/ext/wxAuiPane.cpp +343 -0
  25. data/ext/wxAuiPane.hpp +29 -0
  26. data/ext/wxAuiToolBar.cpp +47 -0
  27. data/ext/wxAuiToolBar.hpp +17 -0
  28. data/ext/wxBitmap.cpp +368 -0
  29. data/ext/wxBitmap.hpp +60 -0
  30. data/ext/wxBitmapButton.cpp +82 -0
  31. data/ext/wxBitmapButton.hpp +17 -0
  32. data/ext/wxBitmapComboBox.cpp +284 -0
  33. data/ext/wxBitmapComboBox.hpp +22 -0
  34. data/ext/wxBitmapToggleButton.cpp +82 -0
  35. data/ext/wxBitmapToggleButton.hpp +17 -0
  36. data/ext/wxBookCtrl.cpp +633 -0
  37. data/ext/wxBookCtrl.hpp +22 -0
  38. data/ext/wxBoxSizer.cpp +60 -0
  39. data/ext/wxBoxSizer.hpp +17 -0
  40. data/ext/wxBrush.cpp +281 -0
  41. data/ext/wxBrush.hpp +28 -0
  42. data/ext/wxButton.cpp +85 -0
  43. data/ext/wxButton.hpp +17 -0
  44. data/ext/wxButtonToolBar.cpp +54 -0
  45. data/ext/wxButtonToolBar.hpp +21 -0
  46. data/ext/wxCalendarCtrl.cpp +91 -0
  47. data/ext/wxCalendarCtrl.hpp +17 -0
  48. data/ext/wxCalendarCtrlBase.cpp +55 -0
  49. data/ext/wxCalendarCtrlBase.hpp +26 -0
  50. data/ext/wxCalendarCtrlGeneric.cpp +102 -0
  51. data/ext/wxCalendarCtrlGeneric.hpp +21 -0
  52. data/ext/wxCheckBox.cpp +157 -0
  53. data/ext/wxCheckBox.hpp +17 -0
  54. data/ext/wxCheckListBox.cpp +191 -0
  55. data/ext/wxCheckListBox.hpp +20 -0
  56. data/ext/wxChoice.cpp +133 -0
  57. data/ext/wxChoice.hpp +30 -0
  58. data/ext/wxChoiceBook.cpp +90 -0
  59. data/ext/wxChoiceBook.hpp +23 -0
  60. data/ext/wxCollapsiblePane.cpp +110 -0
  61. data/ext/wxCollapsiblePane.hpp +21 -0
  62. data/ext/wxColor.cpp +435 -0
  63. data/ext/wxColor.hpp +38 -0
  64. data/ext/wxColorDialog.cpp +97 -0
  65. data/ext/wxColorDialog.hpp +19 -0
  66. data/ext/wxColorPicker.cpp +131 -0
  67. data/ext/wxColorPicker.hpp +20 -0
  68. data/ext/wxColorPickerWidget.cpp +105 -0
  69. data/ext/wxColorPickerWidget.hpp +20 -0
  70. data/ext/wxComboBox.cpp +214 -0
  71. data/ext/wxComboBox.hpp +22 -0
  72. data/ext/wxCommandEvent.cpp +45 -0
  73. data/ext/wxCommandEvent.hpp +16 -0
  74. data/ext/wxConfig.cpp +19 -0
  75. data/ext/wxConfig.hpp +17 -0
  76. data/ext/wxContextHelpButton.cpp +93 -0
  77. data/ext/wxContextHelpButton.hpp +21 -0
  78. data/ext/wxControl.cpp +90 -0
  79. data/ext/wxControl.hpp +15 -0
  80. data/ext/wxCursor.cpp +108 -0
  81. data/ext/wxCursor.hpp +25 -0
  82. data/ext/wxDC.cpp +252 -0
  83. data/ext/wxDC.hpp +18 -0
  84. data/ext/wxDataView.cpp +224 -0
  85. data/ext/wxDataView.hpp +45 -0
  86. data/ext/wxDataViewList.cpp +190 -0
  87. data/ext/wxDataViewList.hpp +17 -0
  88. data/ext/wxDatePicker.cpp +103 -0
  89. data/ext/wxDatePicker.hpp +22 -0
  90. data/ext/wxDialog.cpp +120 -0
  91. data/ext/wxDialog.hpp +17 -0
  92. data/ext/wxDirDialog.cpp +152 -0
  93. data/ext/wxDirDialog.hpp +20 -0
  94. data/ext/wxDirPicker.cpp +134 -0
  95. data/ext/wxDirPicker.hpp +28 -0
  96. data/ext/wxDirPickerWidget.cpp +127 -0
  97. data/ext/wxDirPickerWidget.hpp +20 -0
  98. data/ext/wxError.cpp +67 -0
  99. data/ext/wxError.hpp +17 -0
  100. data/ext/wxEvent.cpp +60 -0
  101. data/ext/wxEvent.hpp +17 -0
  102. data/ext/wxEvtHandler.cpp +291 -0
  103. data/ext/wxEvtHandler.hpp +85 -0
  104. data/ext/wxFileCtrl.cpp +98 -0
  105. data/ext/wxFileCtrl.hpp +17 -0
  106. data/ext/wxFileCtrlBase.cpp +219 -0
  107. data/ext/wxFileCtrlBase.hpp +33 -0
  108. data/ext/wxFileCtrlGeneric.cpp +106 -0
  109. data/ext/wxFileCtrlGeneric.hpp +19 -0
  110. data/ext/wxFileDialog.cpp +268 -0
  111. data/ext/wxFileDialog.hpp +19 -0
  112. data/ext/wxFileDirPicker.cpp +89 -0
  113. data/ext/wxFileDirPicker.hpp +29 -0
  114. data/ext/wxFileHistory.cpp +134 -0
  115. data/ext/wxFileHistory.hpp +20 -0
  116. data/ext/wxFilePicker.cpp +160 -0
  117. data/ext/wxFilePicker.hpp +28 -0
  118. data/ext/wxFilePickerWidget.cpp +139 -0
  119. data/ext/wxFilePickerWidget.hpp +20 -0
  120. data/ext/wxFont.cpp +542 -0
  121. data/ext/wxFont.hpp +37 -0
  122. data/ext/wxFontDialog.cpp +143 -0
  123. data/ext/wxFontDialog.hpp +21 -0
  124. data/ext/wxFontPicker.cpp +160 -0
  125. data/ext/wxFontPicker.hpp +21 -0
  126. data/ext/wxFontPickerWidget.cpp +128 -0
  127. data/ext/wxFontPickerWidget.hpp +20 -0
  128. data/ext/wxFrame.cpp +274 -0
  129. data/ext/wxFrame.hpp +17 -0
  130. data/ext/wxGauge.cpp +167 -0
  131. data/ext/wxGauge.hpp +17 -0
  132. data/ext/wxGrid.cpp +250 -0
  133. data/ext/wxGrid.hpp +43 -0
  134. data/ext/wxGridCellAttr.cpp +68 -0
  135. data/ext/wxGridCellAttr.hpp +26 -0
  136. data/ext/wxGridCellRenderer.cpp +120 -0
  137. data/ext/wxGridCellRenderer.hpp +30 -0
  138. data/ext/wxGridTable.cpp +111 -0
  139. data/ext/wxGridTable.hpp +47 -0
  140. data/ext/wxHyperLink.cpp +148 -0
  141. data/ext/wxHyperLink.hpp +20 -0
  142. data/ext/wxImage.cpp +884 -0
  143. data/ext/wxImage.hpp +24 -0
  144. data/ext/wxInfoBar.cpp +85 -0
  145. data/ext/wxInfoBar.hpp +21 -0
  146. data/ext/wxInfoBarBase.cpp +145 -0
  147. data/ext/wxInfoBarBase.hpp +21 -0
  148. data/ext/wxInfoBarGeneric.cpp +90 -0
  149. data/ext/wxInfoBarGeneric.hpp +21 -0
  150. data/ext/wxItemContainer.cpp +313 -0
  151. data/ext/wxItemContainer.hpp +17 -0
  152. data/ext/wxKeyEvent.cpp +35 -0
  153. data/ext/wxKeyEvent.hpp +16 -0
  154. data/ext/wxListBook.cpp +90 -0
  155. data/ext/wxListBook.hpp +21 -0
  156. data/ext/wxListBox.cpp +290 -0
  157. data/ext/wxListBox.hpp +29 -0
  158. data/ext/wxMenu.cpp +600 -0
  159. data/ext/wxMenu.hpp +17 -0
  160. data/ext/wxMenuBar.cpp +180 -0
  161. data/ext/wxMenuBar.hpp +17 -0
  162. data/ext/wxMenuItem.cpp +174 -0
  163. data/ext/wxMenuItem.hpp +17 -0
  164. data/ext/wxMessageDialog.cpp +91 -0
  165. data/ext/wxMessageDialog.hpp +19 -0
  166. data/ext/wxMessageDialogBase.cpp +152 -0
  167. data/ext/wxMessageDialogBase.hpp +18 -0
  168. data/ext/wxMessageDialogGeneric.cpp +91 -0
  169. data/ext/wxMessageDialogGeneric.hpp +19 -0
  170. data/ext/wxMouseEvent.cpp +60 -0
  171. data/ext/wxMouseEvent.hpp +16 -0
  172. data/ext/wxMultiChoiceDialog.cpp +143 -0
  173. data/ext/wxMultiChoiceDialog.hpp +19 -0
  174. data/ext/wxNoteBook.cpp +89 -0
  175. data/ext/wxNoteBook.hpp +21 -0
  176. data/ext/wxNotifyEvent.cpp +45 -0
  177. data/ext/wxNotifyEvent.hpp +16 -0
  178. data/ext/wxNumberEntryDialog.cpp +131 -0
  179. data/ext/wxNumberEntryDialog.hpp +20 -0
  180. data/ext/wxPalette.cpp +214 -0
  181. data/ext/wxPalette.hpp +24 -0
  182. data/ext/wxPanel.cpp +77 -0
  183. data/ext/wxPanel.hpp +19 -0
  184. data/ext/wxPasswordEntryDialog.cpp +141 -0
  185. data/ext/wxPasswordEntryDialog.hpp +20 -0
  186. data/ext/wxPen.cpp +323 -0
  187. data/ext/wxPen.hpp +37 -0
  188. data/ext/wxPickerBase.cpp +121 -0
  189. data/ext/wxPickerBase.hpp +28 -0
  190. data/ext/wxPoint.cpp +224 -0
  191. data/ext/wxPoint.hpp +40 -0
  192. data/ext/wxPreferences.cpp +149 -0
  193. data/ext/wxPreferences.hpp +18 -0
  194. data/ext/wxProgressDialog.cpp +171 -0
  195. data/ext/wxProgressDialog.hpp +20 -0
  196. data/ext/wxProperty.cpp +723 -0
  197. data/ext/wxProperty.hpp +16 -0
  198. data/ext/wxPropertyCell.cpp +99 -0
  199. data/ext/wxPropertyCell.hpp +16 -0
  200. data/ext/wxPropertyGrid.cpp +234 -0
  201. data/ext/wxPropertyGrid.hpp +20 -0
  202. data/ext/wxPropertyGridInterface.cpp +146 -0
  203. data/ext/wxPropertyGridInterface.hpp +33 -0
  204. data/ext/wxPropertyGridManager.cpp +257 -0
  205. data/ext/wxPropertyGridManager.hpp +20 -0
  206. data/ext/wxPropertyGridPage.cpp +65 -0
  207. data/ext/wxPropertyGridPage.hpp +20 -0
  208. data/ext/wxRadioBox.cpp +405 -0
  209. data/ext/wxRadioBox.hpp +20 -0
  210. data/ext/wxRadioButton.cpp +107 -0
  211. data/ext/wxRadioButton.hpp +16 -0
  212. data/ext/wxRearrangeCtrl.cpp +89 -0
  213. data/ext/wxRearrangeCtrl.hpp +20 -0
  214. data/ext/wxRearrangeDialog.cpp +122 -0
  215. data/ext/wxRearrangeDialog.hpp +20 -0
  216. data/ext/wxRearrangeList.cpp +94 -0
  217. data/ext/wxRearrangeList.hpp +20 -0
  218. data/ext/wxRect.cpp +281 -0
  219. data/ext/wxRect.hpp +29 -0
  220. data/ext/wxRichMessageDialog.cpp +91 -0
  221. data/ext/wxRichMessageDialog.hpp +21 -0
  222. data/ext/wxRichTextAttr.cpp +69 -0
  223. data/ext/wxRichTextAttr.hpp +28 -0
  224. data/ext/wxRichTextCtrl.cpp +484 -0
  225. data/ext/wxRichTextCtrl.hpp +21 -0
  226. data/ext/wxRichTextStyle.cpp +86 -0
  227. data/ext/wxRichTextStyle.hpp +25 -0
  228. data/ext/wxRichTextStyleSheet.cpp +497 -0
  229. data/ext/wxRichTextStyleSheet.hpp +21 -0
  230. data/ext/wxSTC.cpp +331 -0
  231. data/ext/wxSTC.hpp +21 -0
  232. data/ext/wxScrollEvent.cpp +43 -0
  233. data/ext/wxScrollEvent.hpp +16 -0
  234. data/ext/wxSearchCtrl.cpp +189 -0
  235. data/ext/wxSearchCtrl.hpp +21 -0
  236. data/ext/wxSimpleBook.cpp +89 -0
  237. data/ext/wxSimpleBook.hpp +21 -0
  238. data/ext/wxSingleChoiceDialog.cpp +147 -0
  239. data/ext/wxSingleChoiceDialog.hpp +19 -0
  240. data/ext/wxSize.cpp +206 -0
  241. data/ext/wxSize.hpp +32 -0
  242. data/ext/wxSizer.cpp +368 -0
  243. data/ext/wxSizer.hpp +23 -0
  244. data/ext/wxSizerItem.cpp +37 -0
  245. data/ext/wxSizerItem.hpp +18 -0
  246. data/ext/wxSlider.cpp +204 -0
  247. data/ext/wxSlider.hpp +21 -0
  248. data/ext/wxSpinButton.cpp +158 -0
  249. data/ext/wxSpinButton.hpp +20 -0
  250. data/ext/wxSpinCtrl.cpp +132 -0
  251. data/ext/wxSpinCtrl.hpp +21 -0
  252. data/ext/wxStartUpTip.cpp +44 -0
  253. data/ext/wxStartUpTip.hpp +16 -0
  254. data/ext/wxStaticBitmap.cpp +79 -0
  255. data/ext/wxStaticBitmap.hpp +17 -0
  256. data/ext/wxStaticBitmapBase.cpp +46 -0
  257. data/ext/wxStaticBitmapBase.hpp +22 -0
  258. data/ext/wxStaticBitmapGeneric.cpp +82 -0
  259. data/ext/wxStaticBitmapGeneric.hpp +17 -0
  260. data/ext/wxStaticBox.cpp +92 -0
  261. data/ext/wxStaticBox.hpp +22 -0
  262. data/ext/wxStaticLine.cpp +100 -0
  263. data/ext/wxStaticLine.hpp +22 -0
  264. data/ext/wxStaticText.cpp +82 -0
  265. data/ext/wxStaticText.hpp +21 -0
  266. data/ext/wxStatusBar.cpp +417 -0
  267. data/ext/wxStatusBar.hpp +17 -0
  268. data/ext/wxStream.cpp +41 -0
  269. data/ext/wxStream.hpp +46 -0
  270. data/ext/wxTaskBar.cpp +104 -0
  271. data/ext/wxTaskBar.hpp +41 -0
  272. data/ext/wxTextArea.cpp +141 -0
  273. data/ext/wxTextArea.hpp +21 -0
  274. data/ext/wxTextAttr.cpp +320 -0
  275. data/ext/wxTextAttr.hpp +28 -0
  276. data/ext/wxTextCtrl.cpp +177 -0
  277. data/ext/wxTextCtrl.hpp +30 -0
  278. data/ext/wxTextEntry.cpp +248 -0
  279. data/ext/wxTextEntry.hpp +19 -0
  280. data/ext/wxTextEntryDialog.cpp +133 -0
  281. data/ext/wxTextEntryDialog.hpp +20 -0
  282. data/ext/wxTimePicker.cpp +105 -0
  283. data/ext/wxTimePicker.hpp +22 -0
  284. data/ext/wxTimer.cpp +106 -0
  285. data/ext/wxTimer.hpp +16 -0
  286. data/ext/wxToggleButton.cpp +96 -0
  287. data/ext/wxToggleButton.hpp +21 -0
  288. data/ext/wxToolBar.cpp +85 -0
  289. data/ext/wxToolBar.hpp +17 -0
  290. data/ext/wxToolBarBase.cpp +615 -0
  291. data/ext/wxToolBarBase.hpp +17 -0
  292. data/ext/wxToolBarTool.cpp +179 -0
  293. data/ext/wxToolBarTool.hpp +16 -0
  294. data/ext/wxToolBook.cpp +96 -0
  295. data/ext/wxToolBook.hpp +23 -0
  296. data/ext/wxToplevel.cpp +125 -0
  297. data/ext/wxToplevel.hpp +25 -0
  298. data/ext/wxTreeBook.cpp +240 -0
  299. data/ext/wxTreeBook.hpp +21 -0
  300. data/ext/wxTreeCtrl.cpp +443 -0
  301. data/ext/wxTreeCtrl.hpp +66 -0
  302. data/ext/wxVariant.cpp +65 -0
  303. data/ext/wxVariant.hpp +17 -0
  304. data/ext/wxWindow.cpp +980 -0
  305. data/ext/wxWindow.hpp +35 -0
  306. data/ext/wxWizard.cpp +321 -0
  307. data/ext/wxWizard.hpp +19 -0
  308. data/ext/wxWizardPage.cpp +137 -0
  309. data/ext/wxWizardPage.hpp +38 -0
  310. data/ext/wxXRC.cpp +48 -0
  311. data/ext/wxXRC.hpp +21 -0
  312. data/old_tests/button.rb +56 -0
  313. data/old_tests/file.png +0 -0
  314. data/old_tests/green.xpm +25 -0
  315. data/old_tests/new16x16.png +0 -0
  316. data/old_tests/project.xml +10 -0
  317. data/old_tests/propertygrid.rb +51 -0
  318. data/old_tests/red.xpm +25 -0
  319. data/old_tests/ruby32x32.png +0 -0
  320. data/old_tests/status.rb +45 -0
  321. data/old_tests/test.rb +580 -0
  322. data/old_tests/wizard.xrc +40 -0
  323. data/old_tests/xrc.rb +38 -0
  324. data/rwx.gemspec +43 -0
  325. data/samples/controls/controls.rb +143 -0
  326. data/samples/controls/icons/choice.bmp +0 -0
  327. data/samples/controls/icons/choice.xpm +27 -0
  328. data/samples/controls/icons/combo.bmp +0 -0
  329. data/samples/controls/icons/combo.xpm +27 -0
  330. data/samples/controls/icons/gauge.bmp +0 -0
  331. data/samples/controls/icons/gauge.xpm +27 -0
  332. data/samples/controls/icons/list.bmp +0 -0
  333. data/samples/controls/icons/list.xpm +27 -0
  334. data/samples/controls/icons/radio.bmp +0 -0
  335. data/samples/controls/icons/radio.xpm +27 -0
  336. data/samples/controls/icons/stattext.xpm +24 -0
  337. data/samples/controls/icons/text.bmp +0 -0
  338. data/samples/controls/icons/text.xpm +27 -0
  339. data/samples/dialog/dialog_sample.rb +227 -0
  340. data/samples/sample.xpm +44 -0
  341. data/samples/widgets/icons/bmpbtn.xpm +37 -0
  342. data/samples/widgets/icons/bmpcombobox.xpm +54 -0
  343. data/samples/widgets/icons/button.xpm +54 -0
  344. data/samples/widgets/icons/checkbox.xpm +54 -0
  345. data/samples/widgets/icons/choice.xpm +27 -0
  346. data/samples/widgets/icons/choicebk.xpm +54 -0
  347. data/samples/widgets/icons/clrpicker.xpm +193 -0
  348. data/samples/widgets/icons/combobox.xpm +54 -0
  349. data/samples/widgets/icons/datepick.xpm +200 -0
  350. data/samples/widgets/icons/dirctrl.xpm +54 -0
  351. data/samples/widgets/icons/dirpicker.xpm +213 -0
  352. data/samples/widgets/icons/filepicker.xpm +214 -0
  353. data/samples/widgets/icons/fontpicker.xpm +185 -0
  354. data/samples/widgets/icons/gauge.xpm +54 -0
  355. data/samples/widgets/icons/hyperlnk.xpm +54 -0
  356. data/samples/widgets/icons/listbook.xpm +54 -0
  357. data/samples/widgets/icons/listbox.xpm +54 -0
  358. data/samples/widgets/icons/notebook.xpm +54 -0
  359. data/samples/widgets/icons/odcombobox.xpm +54 -0
  360. data/samples/widgets/icons/radiobox.xpm +54 -0
  361. data/samples/widgets/icons/scrolbar.xpm +54 -0
  362. data/samples/widgets/icons/slider.xpm +54 -0
  363. data/samples/widgets/icons/spinbtn.xpm +40 -0
  364. data/samples/widgets/icons/statbmp.xpm +40 -0
  365. data/samples/widgets/icons/statbox.xpm +54 -0
  366. data/samples/widgets/icons/stattext.xpm +54 -0
  367. data/samples/widgets/icons/text.xpm +54 -0
  368. data/samples/widgets/icons/timepick.xpm +207 -0
  369. data/samples/widgets/icons/toggle.xpm +54 -0
  370. data/samples/widgets/pages/colorpicker.rb +66 -0
  371. data/samples/widgets/pages/common.rb +17 -0
  372. data/samples/widgets/widgets.rb +29 -0
  373. data/samples/xrc/samples.xrc +46 -0
  374. data/samples/xrc/xrc_sample.rb +59 -0
  375. data/test/test_color.rb +64 -0
  376. metadata +470 -0
@@ -0,0 +1,454 @@
1
+ /*
2
+ * main.hpp
3
+ *
4
+ * Created on: 04.02.2012
5
+ * Author: hanmac
6
+ */
7
+
8
+ #ifndef MAIN_HPP_
9
+ #define MAIN_HPP_
10
+
11
+ #include <cerrno>
12
+
13
+ #if defined _WIN32 || defined __CYGWIN__
14
+ #ifdef BUILDING_DLL
15
+ #ifdef __GNUC__
16
+ #define DLL_PUBLIC __attribute__ ((dllexport))
17
+ #else
18
+ #define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
19
+ #endif
20
+ #else
21
+ #ifdef __GNUC__
22
+ #define DLL_PUBLIC __attribute__ ((dllimport))
23
+ #else
24
+ #define DLL_PUBLIC __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
25
+ #endif
26
+ #endif
27
+ #define DLL_LOCAL
28
+ #else
29
+ #if __GNUC__ >= 4
30
+ #define DLL_PUBLIC __attribute__ ((visibility ("default")))
31
+ #define DLL_LOCAL __attribute__ ((visibility ("hidden")))
32
+ #else
33
+ #define DLL_PUBLIC
34
+ #define DLL_LOCAL
35
+ #endif
36
+ #endif
37
+
38
+ #include "extconf.h"
39
+
40
+ //need to include setup first because main header does it wrong
41
+ #include <wx/setup.h>
42
+ #include <wx/wx.h>
43
+ #include <ruby.h>
44
+
45
+ #include <typeinfo>
46
+ #include <map>
47
+ #include <string>
48
+ #include <string.h>
49
+
50
+
51
+ #ifdef HAVE_RUBY_ENCODING_H
52
+ #include <ruby/encoding.h>
53
+ #endif
54
+
55
+ #if wxUSE_XRC
56
+ #include <wx/xrc/xmlres.h>
57
+ #endif
58
+
59
+ #if wxUSE_PROPGRID
60
+ #include <wx/propgrid/property.h>
61
+ #endif
62
+
63
+ #if wxUSE_GRID
64
+ #include <wx/grid.h>
65
+ #endif
66
+
67
+ #ifndef RARRAY_AREF
68
+ #ifdef RARRAY_CONST_PTR
69
+ #define RARRAY_AREF(a,i) RARRAY_CONST_PTR(a)[i]
70
+ #else
71
+ #define RARRAY_AREF(a,i) RARRAY_PTR(a)[i]
72
+ #endif
73
+
74
+ #endif
75
+
76
+
77
+ template< class T > struct remove_pointer {typedef T type;};
78
+ template< class T > struct remove_pointer<T*> {typedef T type;};
79
+ template< class T > struct remove_pointer<T* const> {typedef T type;};
80
+ template< class T > struct remove_pointer<T* volatile> {typedef T type;};
81
+ template< class T > struct remove_pointer<T* const volatile> {typedef T type;};
82
+
83
+ //typedef std::map<std::string,VALUE> klassholdertype;
84
+ typedef std::map<const wxClassInfo*,VALUE> infoholdertype;
85
+ extern infoholdertype infoklassholder;
86
+ typedef std::map<std::string,VALUE> typeholdertype;
87
+ extern typeholdertype typeklassholder;
88
+
89
+ typedef std::map<VALUE, rb_data_type_t> datatypeholdertype;
90
+ extern datatypeholdertype datatypeholder;
91
+ extern datatypeholdertype datatypeholder_const;
92
+
93
+ extern VALUE global_holder;
94
+ void rwx_refobject(VALUE object);
95
+ bool rwx_unrefobject(VALUE object);
96
+
97
+ VALUE wrapTypedPtr(void *arg,VALUE klass);
98
+ VALUE wrapTypedPtr(wxObject *object,VALUE klass);
99
+ VALUE wrapTypedPtr(wxEvtHandler *handler,VALUE klass);
100
+
101
+ VALUE wrapTypedPtr(wxClientDataContainer *sizer,VALUE klass);
102
+ VALUE wrapTypedPtr(wxSizer *sizer,VALUE klass);
103
+
104
+ #if wxUSE_PROPGRID
105
+ VALUE wrapTypedPtr(wxPGProperty *sizer,VALUE klass);
106
+ #endif
107
+ #if wxUSE_GRID
108
+ VALUE wrapTypedPtr(wxGridTableBase *sizer,VALUE klass);
109
+ VALUE wrapTypedPtr(wxGridCellAttr *sizer,VALUE klass);
110
+ #endif
111
+
112
+
113
+ struct enumtype
114
+ {
115
+ std::string name;
116
+ typedef std::multimap<int,ID> value_type;
117
+ value_type values;
118
+
119
+ bool allow_array;
120
+ int defaults;
121
+
122
+ enumtype* add(int enumo,const char* sym)
123
+ {
124
+
125
+ values.insert(std::make_pair(enumo,rb_intern(sym)));
126
+ return this;
127
+ }
128
+ };
129
+ //typedef std::map<int,ID > enumtype;
130
+ typedef std::map<std::string,enumtype* > enumregistertype;
131
+
132
+ extern enumregistertype enumregister;
133
+
134
+
135
+ DLL_LOCAL enumtype* registerEnum(const std::string& name,const std::string& type ,int def = 0);
136
+
137
+
138
+ template <typename T>
139
+ DLL_LOCAL enumtype* registerEnum(const char* name,int def = 0)
140
+ {
141
+ return registerEnum(name,typeid(T).name(),def);
142
+ }
143
+
144
+
145
+ template <typename T>
146
+ DLL_LOCAL size_t type_size_of(const void* data)
147
+ {
148
+ return data ? sizeof(T) : 0;
149
+ }
150
+
151
+ DLL_LOCAL void registerDataType(VALUE klass);
152
+ DLL_LOCAL void registerDataType(VALUE klass, RUBY_DATA_FUNC freefunc, size_t (*sizefunc)(const void *) = NULL);
153
+
154
+ template <typename T>
155
+ DLL_LOCAL void registerType(VALUE klass, bool bfree = false)
156
+ {
157
+ typeklassholder[typeid(T*).name()]=klass;
158
+ if(bfree)
159
+ registerDataType(klass, RUBY_TYPED_DEFAULT_FREE, type_size_of<T>);
160
+ else
161
+ registerDataType(klass, RUBY_TYPED_NEVER_FREE, type_size_of<T>);
162
+ }
163
+
164
+ template <typename T>
165
+ DLL_LOCAL void registerInfo(VALUE klass, bool bfree = false)
166
+ {
167
+ infoklassholder[wxCLASSINFO(T)]=klass;
168
+ registerType<T>(klass, bfree);
169
+ }
170
+
171
+ DLL_LOCAL VALUE wrapClass(const wxClassInfo * info);
172
+
173
+ DLL_LOCAL rb_data_type_t* unwrapDataType(const VALUE& klass);
174
+
175
+ template <typename T>
176
+ VALUE wrap(T *arg)
177
+ {
178
+ if(!arg)
179
+ return Qnil;
180
+ wxClassInfo *info = arg->GetClassInfo();
181
+ VALUE klass = wrapClass(info);
182
+ if(!NIL_P(klass))
183
+ {
184
+ return wrapTypedPtr(arg,klass);
185
+ }
186
+ rb_warn("%s type unknown",wxString(info->GetClassName()).c_str().AsChar());
187
+ return Qnil;
188
+ }
189
+
190
+ template <typename T>
191
+ VALUE wrap(const T *arg)
192
+ {
193
+ VALUE result = rb_obj_freeze(wrap(const_cast<T*>(arg)));
194
+ RTYPEDDATA_TYPE(result) = &datatypeholder_const[CLASS_OF(result)];
195
+ return result;
196
+ }
197
+
198
+
199
+ DLL_LOCAL void* unwrapTypedPtr(const VALUE &obj, rb_data_type_t* rbdata);
200
+
201
+ template <typename T>
202
+ T* unwrapTypedPtr(const VALUE &obj,const VALUE &klass, rb_data_type_t* rbdata = NULL)
203
+ {
204
+ if(NIL_P(obj))
205
+ return NULL;
206
+
207
+ if(rb_obj_is_instance_of(obj,rb_cClass) && rb_class_inherited(obj,klass)) {
208
+ return unwrapTypedPtr<T>(rb_class_new_instance(0,NULL,obj), klass, rbdata);
209
+ }else if (rb_obj_is_kind_of(obj, klass)){
210
+ return (T*)unwrapTypedPtr(obj, rbdata ? rbdata : unwrapDataType(klass));
211
+ }else{
212
+ rb_raise(rb_eTypeError,
213
+ "Expected %s got %s!",
214
+ rb_class2name(klass),
215
+ rb_obj_classname(obj)
216
+ );
217
+ return NULL;
218
+ }
219
+
220
+ }
221
+
222
+ template <typename T>
223
+ T unwrap(const VALUE &arg)
224
+ {
225
+ if(NIL_P(arg))
226
+ return NULL;
227
+ typedef typename remove_pointer<T>::type rtype;
228
+
229
+ typeholdertype::iterator it = typeklassholder.find(typeid(rtype*).name());
230
+ if(it != typeklassholder.end())
231
+ {
232
+ return unwrapTypedPtr<rtype>(arg,it->second);
233
+ }
234
+ rb_raise(rb_eTypeError,"%s type unknown",typeid(rtype*).name());
235
+ return NULL;
236
+ }
237
+
238
+ template <class T>
239
+ VALUE wrap(const T &arg){
240
+ return wrap(new T(arg));
241
+ };
242
+
243
+ template <typename T>
244
+ bool is_wrapable(const VALUE &arg);
245
+
246
+
247
+ VALUE wrapenum(const int &arg, const std::string& name);
248
+
249
+
250
+ template <typename T>
251
+ VALUE wrapenum(const T &arg){
252
+ return wrapenum(arg,typeid(T).name());
253
+ }
254
+
255
+ template <typename T>
256
+ VALUE wrapenum(int arg){
257
+ return wrapenum((T)arg);
258
+ }
259
+
260
+ int unwrapenum(const VALUE &arg, const std::string& name);
261
+
262
+ template <typename T>
263
+ T unwrapenum(const VALUE &arg){
264
+ return (T)unwrapenum(arg,typeid(T).name());
265
+ }
266
+
267
+
268
+ template <>
269
+ bool unwrap< bool >(const VALUE &val );
270
+ template <>
271
+ VALUE wrap< bool >(const bool &st );
272
+ template <>
273
+ int unwrap< int >(const VALUE &val );
274
+ template <>
275
+ VALUE wrap< int >(const int &st );
276
+ template <>
277
+ double unwrap< double >(const VALUE &val );
278
+ template <>
279
+ VALUE wrap< double >(const double &st );
280
+
281
+
282
+ template <>
283
+ unsigned int unwrap< unsigned int >(const VALUE &val );
284
+ template <>
285
+ VALUE wrap< unsigned int >(const unsigned int &st );
286
+
287
+ template <>
288
+ long unwrap< long >(const VALUE &val );
289
+ template <>
290
+ VALUE wrap< long >(const long &st );
291
+
292
+ template <>
293
+ unsigned long unwrap< unsigned long >(const VALUE &val );
294
+ template <>
295
+ VALUE wrap< unsigned long >(const unsigned long &st );
296
+
297
+ template <>
298
+ VALUE wrap< wxString >(const wxString &st );
299
+
300
+ template <>
301
+ VALUE wrap< wxChar >(const wxChar &c );
302
+
303
+ template <>
304
+ char* unwrap< char* >(const VALUE &val );
305
+
306
+ template <>
307
+ wxString unwrap< wxString >(const VALUE &val );
308
+
309
+ template <>
310
+ VALUE wrap< wxArrayString >(const wxArrayString &st );
311
+
312
+ template <>
313
+ VALUE wrap< wxArrayInt >(const wxArrayInt &st );
314
+
315
+ template <>
316
+ wxArrayString unwrap< wxArrayString >(const VALUE &val );
317
+ template <>
318
+ wxArrayInt unwrap< wxArrayInt >(const VALUE &val );
319
+
320
+ template <>
321
+ VALUE wrap< wxDateTime >(const wxDateTime &st );
322
+
323
+ template <>
324
+ wxDateTime unwrap< wxDateTime >(const VALUE &val );
325
+
326
+ DLL_LOCAL int unwrap_iconflag(const VALUE& val,int mask = wxICON_MASK);
327
+ DLL_LOCAL int unwrap_buttonflag(const VALUE& val);
328
+
329
+ DLL_LOCAL bool check_file_loadable(const wxString& path);
330
+ DLL_LOCAL bool check_file_saveable(const wxString& path);
331
+
332
+ template <typename T>
333
+ DLL_LOCAL bool window_parent_check(VALUE window, wxWindow* parent, T* &w)
334
+ {
335
+ w = unwrap<T*>(window);
336
+ if(w && w->GetParent() != parent)
337
+ {
338
+ rb_raise(rb_eArgError, "%s has wrong parent.",unwrap<char*>(window));
339
+ return false;
340
+ }
341
+ return true;
342
+ }
343
+
344
+ bool nil_check(VALUE window,const char* type,bool raise = true);
345
+ bool nil_check(VALUE window,VALUE klass ,bool raise = true);
346
+ bool nil_check(VALUE window,bool raise = true);
347
+
348
+ bool check_index(int &cidx,const std::size_t &count);
349
+
350
+ #define macro_attr_func(attr,funcget,funcset,wrapget,wrapset,con) \
351
+ DLL_LOCAL VALUE _get##attr(VALUE self)\
352
+ { \
353
+ if(con)\
354
+ return wrapget(_self->funcget);\
355
+ return Qnil;\
356
+ }\
357
+ \
358
+ DLL_LOCAL VALUE _set##attr(VALUE self,VALUE other)\
359
+ {\
360
+ rb_check_frozen(self);\
361
+ if(con)\
362
+ _self->funcset(wrapset(other));\
363
+ return other;\
364
+ }
365
+
366
+
367
+ template <typename T>
368
+ DLL_LOCAL bool set_hash_option(VALUE hash,const char* name,T& val,T func(const VALUE&) = unwrap<T> )
369
+ {
370
+ VALUE temp;
371
+ if(!NIL_P(temp=rb_hash_aref(hash,ID2SYM(rb_intern(name)))))
372
+ {
373
+ val = func(temp);
374
+ return true;
375
+ }
376
+ return false;
377
+
378
+ }
379
+
380
+ DLL_LOCAL bool set_hash_flag_option(VALUE hash,const char* name,const int& flag,int& val);
381
+
382
+ #define macro_attr(attr,type) macro_attr_func(attr,Get##attr(),Set##attr,wrap,unwrap<type>,true)
383
+ #define macro_attr_enum(attr,type) macro_attr_func(attr,Get##attr(),Set##attr,wrapenum<type>,unwrapenum<type>,true)
384
+ #define macro_attr_with_func(attr,getf,setf) macro_attr_func(attr,Get##attr(),Set##attr,getf,setf,true)
385
+
386
+ #define macro_attr_con(attr,type,con) macro_attr_func(attr,Get##attr(),Set##attr,wrap,unwrap<type>,con)
387
+ #define macro_attr_enum_con(attr,type,con) macro_attr_func(attr,Get##attr(),Set##attr,wrapenum<type>,unwrapenum<type>,_self->con())
388
+
389
+ #define macro_attr_pre(attr,type,pre) macro_attr_func(attr,pre().Get##attr(),pre().Set##attr,wrap,unwrap<type>,true)
390
+
391
+ #define macro_attr_bool(attr) macro_attr_func(attr,Is##attr(),Set##attr,wrap,RTEST,true)
392
+ #define macro_attr_bool2(attr,attr2) macro_attr_func(attr,Is##attr(),attr2,wrap,RTEST,true)
393
+ #define macro_attr_bool3(attr,attr2) macro_attr_func(attr,Has##attr(),attr2,wrap,RTEST,true)
394
+ #define macro_attr_bool_con(attr,con) macro_attr_func(attr,Is##attr(),Set##attr,wrap,RTEST,_self->con())
395
+
396
+ //*/
397
+ #define macro_attr_prop(attr,type) macro_attr_func(_##attr,attr,attr = ,wrap,unwrap<type>,true)
398
+ #define macro_attr_prop_enum(attr,type) macro_attr_func(_##attr,attr,attr = ,wrapenum<type>,unwrapenum<type>,true)
399
+ #define macro_attr_prop_with_func(attr,getf,setf) macro_attr_func(_##attr,attr,attr = ,getf,setf,true)
400
+
401
+
402
+ /*
403
+ * special macro for select attributes that manages wxNOT_FOUND
404
+ */
405
+ #define macro_attr_selection(attr,count) \
406
+ DLL_LOCAL VALUE _get##attr(VALUE self)\
407
+ { \
408
+ int val = _self->Get##attr();\
409
+ return val == wxNOT_FOUND ? Qnil : UINT2NUM(val);\
410
+ }\
411
+ \
412
+ DLL_LOCAL VALUE _set##attr(VALUE self,VALUE other)\
413
+ {\
414
+ rb_check_frozen(self);\
415
+ if(NIL_P(other))\
416
+ _self->Set##attr(wxNOT_FOUND);\
417
+ int cother = NUM2INT(other);\
418
+ if(check_index(cother,_self->count()))\
419
+ _self->Set##attr(cother);\
420
+ return other;\
421
+ }
422
+
423
+
424
+ DLL_LOCAL void rb_define_attr_method(VALUE klass,std::string name,VALUE(get)(VALUE),VALUE(set)(VALUE,VALUE));
425
+
426
+ #define singlefunc(func) \
427
+ DLL_LOCAL VALUE _##func(VALUE self)\
428
+ {\
429
+ rb_check_frozen(self);\
430
+ _self->func();\
431
+ return self;\
432
+ }
433
+
434
+
435
+ #define singlereturn(func) \
436
+ DLL_LOCAL VALUE _##func(VALUE self)\
437
+ {\
438
+ return wrap(_self->func());\
439
+ }
440
+
441
+ #define singlereturn_frozen(func) \
442
+ DLL_LOCAL VALUE _##func(VALUE self)\
443
+ {\
444
+ rb_check_frozen(self);\
445
+ return wrap(_self->func());\
446
+ }
447
+
448
+ #define set_option_func(name,cname,func) \
449
+ if(!NIL_P(temp=rb_hash_aref(hash,ID2SYM(rb_intern(#name)))))\
450
+ _self->Set##cname(func(temp));
451
+
452
+ #define set_option(name,cname,type) set_option_func(name,cname,unwrap<type>)
453
+
454
+ #endif /* MAIN_HPP_ */