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.
- checksums.yaml +7 -0
- data/.gitignore +49 -0
- data/COPYING +0 -0
- data/README.rdoc +0 -0
- data/Rakefile +100 -0
- data/VERSION +1 -0
- data/ext/extconf.rb +112 -0
- data/ext/main.cpp +432 -0
- data/ext/main.hpp +454 -0
- data/ext/rwx.cpp +472 -0
- data/ext/wxAboutDlg.cpp +213 -0
- data/ext/wxAboutDlg.hpp +19 -0
- data/ext/wxAnyButton.cpp +141 -0
- data/ext/wxAnyButton.hpp +17 -0
- data/ext/wxAnyChoiceDialog.cpp +93 -0
- data/ext/wxAnyChoiceDialog.hpp +19 -0
- data/ext/wxApp.cpp +205 -0
- data/ext/wxApp.hpp +48 -0
- data/ext/wxAui.hpp +19 -0
- data/ext/wxAuiBook.cpp +453 -0
- data/ext/wxAuiBook.hpp +21 -0
- data/ext/wxAuiManager.cpp +79 -0
- data/ext/wxAuiManager.hpp +18 -0
- data/ext/wxAuiPane.cpp +343 -0
- data/ext/wxAuiPane.hpp +29 -0
- data/ext/wxAuiToolBar.cpp +47 -0
- data/ext/wxAuiToolBar.hpp +17 -0
- data/ext/wxBitmap.cpp +368 -0
- data/ext/wxBitmap.hpp +60 -0
- data/ext/wxBitmapButton.cpp +82 -0
- data/ext/wxBitmapButton.hpp +17 -0
- data/ext/wxBitmapComboBox.cpp +284 -0
- data/ext/wxBitmapComboBox.hpp +22 -0
- data/ext/wxBitmapToggleButton.cpp +82 -0
- data/ext/wxBitmapToggleButton.hpp +17 -0
- data/ext/wxBookCtrl.cpp +633 -0
- data/ext/wxBookCtrl.hpp +22 -0
- data/ext/wxBoxSizer.cpp +60 -0
- data/ext/wxBoxSizer.hpp +17 -0
- data/ext/wxBrush.cpp +281 -0
- data/ext/wxBrush.hpp +28 -0
- data/ext/wxButton.cpp +85 -0
- data/ext/wxButton.hpp +17 -0
- data/ext/wxButtonToolBar.cpp +54 -0
- data/ext/wxButtonToolBar.hpp +21 -0
- data/ext/wxCalendarCtrl.cpp +91 -0
- data/ext/wxCalendarCtrl.hpp +17 -0
- data/ext/wxCalendarCtrlBase.cpp +55 -0
- data/ext/wxCalendarCtrlBase.hpp +26 -0
- data/ext/wxCalendarCtrlGeneric.cpp +102 -0
- data/ext/wxCalendarCtrlGeneric.hpp +21 -0
- data/ext/wxCheckBox.cpp +157 -0
- data/ext/wxCheckBox.hpp +17 -0
- data/ext/wxCheckListBox.cpp +191 -0
- data/ext/wxCheckListBox.hpp +20 -0
- data/ext/wxChoice.cpp +133 -0
- data/ext/wxChoice.hpp +30 -0
- data/ext/wxChoiceBook.cpp +90 -0
- data/ext/wxChoiceBook.hpp +23 -0
- data/ext/wxCollapsiblePane.cpp +110 -0
- data/ext/wxCollapsiblePane.hpp +21 -0
- data/ext/wxColor.cpp +435 -0
- data/ext/wxColor.hpp +38 -0
- data/ext/wxColorDialog.cpp +97 -0
- data/ext/wxColorDialog.hpp +19 -0
- data/ext/wxColorPicker.cpp +131 -0
- data/ext/wxColorPicker.hpp +20 -0
- data/ext/wxColorPickerWidget.cpp +105 -0
- data/ext/wxColorPickerWidget.hpp +20 -0
- data/ext/wxComboBox.cpp +214 -0
- data/ext/wxComboBox.hpp +22 -0
- data/ext/wxCommandEvent.cpp +45 -0
- data/ext/wxCommandEvent.hpp +16 -0
- data/ext/wxConfig.cpp +19 -0
- data/ext/wxConfig.hpp +17 -0
- data/ext/wxContextHelpButton.cpp +93 -0
- data/ext/wxContextHelpButton.hpp +21 -0
- data/ext/wxControl.cpp +90 -0
- data/ext/wxControl.hpp +15 -0
- data/ext/wxCursor.cpp +108 -0
- data/ext/wxCursor.hpp +25 -0
- data/ext/wxDC.cpp +252 -0
- data/ext/wxDC.hpp +18 -0
- data/ext/wxDataView.cpp +224 -0
- data/ext/wxDataView.hpp +45 -0
- data/ext/wxDataViewList.cpp +190 -0
- data/ext/wxDataViewList.hpp +17 -0
- data/ext/wxDatePicker.cpp +103 -0
- data/ext/wxDatePicker.hpp +22 -0
- data/ext/wxDialog.cpp +120 -0
- data/ext/wxDialog.hpp +17 -0
- data/ext/wxDirDialog.cpp +152 -0
- data/ext/wxDirDialog.hpp +20 -0
- data/ext/wxDirPicker.cpp +134 -0
- data/ext/wxDirPicker.hpp +28 -0
- data/ext/wxDirPickerWidget.cpp +127 -0
- data/ext/wxDirPickerWidget.hpp +20 -0
- data/ext/wxError.cpp +67 -0
- data/ext/wxError.hpp +17 -0
- data/ext/wxEvent.cpp +60 -0
- data/ext/wxEvent.hpp +17 -0
- data/ext/wxEvtHandler.cpp +291 -0
- data/ext/wxEvtHandler.hpp +85 -0
- data/ext/wxFileCtrl.cpp +98 -0
- data/ext/wxFileCtrl.hpp +17 -0
- data/ext/wxFileCtrlBase.cpp +219 -0
- data/ext/wxFileCtrlBase.hpp +33 -0
- data/ext/wxFileCtrlGeneric.cpp +106 -0
- data/ext/wxFileCtrlGeneric.hpp +19 -0
- data/ext/wxFileDialog.cpp +268 -0
- data/ext/wxFileDialog.hpp +19 -0
- data/ext/wxFileDirPicker.cpp +89 -0
- data/ext/wxFileDirPicker.hpp +29 -0
- data/ext/wxFileHistory.cpp +134 -0
- data/ext/wxFileHistory.hpp +20 -0
- data/ext/wxFilePicker.cpp +160 -0
- data/ext/wxFilePicker.hpp +28 -0
- data/ext/wxFilePickerWidget.cpp +139 -0
- data/ext/wxFilePickerWidget.hpp +20 -0
- data/ext/wxFont.cpp +542 -0
- data/ext/wxFont.hpp +37 -0
- data/ext/wxFontDialog.cpp +143 -0
- data/ext/wxFontDialog.hpp +21 -0
- data/ext/wxFontPicker.cpp +160 -0
- data/ext/wxFontPicker.hpp +21 -0
- data/ext/wxFontPickerWidget.cpp +128 -0
- data/ext/wxFontPickerWidget.hpp +20 -0
- data/ext/wxFrame.cpp +274 -0
- data/ext/wxFrame.hpp +17 -0
- data/ext/wxGauge.cpp +167 -0
- data/ext/wxGauge.hpp +17 -0
- data/ext/wxGrid.cpp +250 -0
- data/ext/wxGrid.hpp +43 -0
- data/ext/wxGridCellAttr.cpp +68 -0
- data/ext/wxGridCellAttr.hpp +26 -0
- data/ext/wxGridCellRenderer.cpp +120 -0
- data/ext/wxGridCellRenderer.hpp +30 -0
- data/ext/wxGridTable.cpp +111 -0
- data/ext/wxGridTable.hpp +47 -0
- data/ext/wxHyperLink.cpp +148 -0
- data/ext/wxHyperLink.hpp +20 -0
- data/ext/wxImage.cpp +884 -0
- data/ext/wxImage.hpp +24 -0
- data/ext/wxInfoBar.cpp +85 -0
- data/ext/wxInfoBar.hpp +21 -0
- data/ext/wxInfoBarBase.cpp +145 -0
- data/ext/wxInfoBarBase.hpp +21 -0
- data/ext/wxInfoBarGeneric.cpp +90 -0
- data/ext/wxInfoBarGeneric.hpp +21 -0
- data/ext/wxItemContainer.cpp +313 -0
- data/ext/wxItemContainer.hpp +17 -0
- data/ext/wxKeyEvent.cpp +35 -0
- data/ext/wxKeyEvent.hpp +16 -0
- data/ext/wxListBook.cpp +90 -0
- data/ext/wxListBook.hpp +21 -0
- data/ext/wxListBox.cpp +290 -0
- data/ext/wxListBox.hpp +29 -0
- data/ext/wxMenu.cpp +600 -0
- data/ext/wxMenu.hpp +17 -0
- data/ext/wxMenuBar.cpp +180 -0
- data/ext/wxMenuBar.hpp +17 -0
- data/ext/wxMenuItem.cpp +174 -0
- data/ext/wxMenuItem.hpp +17 -0
- data/ext/wxMessageDialog.cpp +91 -0
- data/ext/wxMessageDialog.hpp +19 -0
- data/ext/wxMessageDialogBase.cpp +152 -0
- data/ext/wxMessageDialogBase.hpp +18 -0
- data/ext/wxMessageDialogGeneric.cpp +91 -0
- data/ext/wxMessageDialogGeneric.hpp +19 -0
- data/ext/wxMouseEvent.cpp +60 -0
- data/ext/wxMouseEvent.hpp +16 -0
- data/ext/wxMultiChoiceDialog.cpp +143 -0
- data/ext/wxMultiChoiceDialog.hpp +19 -0
- data/ext/wxNoteBook.cpp +89 -0
- data/ext/wxNoteBook.hpp +21 -0
- data/ext/wxNotifyEvent.cpp +45 -0
- data/ext/wxNotifyEvent.hpp +16 -0
- data/ext/wxNumberEntryDialog.cpp +131 -0
- data/ext/wxNumberEntryDialog.hpp +20 -0
- data/ext/wxPalette.cpp +214 -0
- data/ext/wxPalette.hpp +24 -0
- data/ext/wxPanel.cpp +77 -0
- data/ext/wxPanel.hpp +19 -0
- data/ext/wxPasswordEntryDialog.cpp +141 -0
- data/ext/wxPasswordEntryDialog.hpp +20 -0
- data/ext/wxPen.cpp +323 -0
- data/ext/wxPen.hpp +37 -0
- data/ext/wxPickerBase.cpp +121 -0
- data/ext/wxPickerBase.hpp +28 -0
- data/ext/wxPoint.cpp +224 -0
- data/ext/wxPoint.hpp +40 -0
- data/ext/wxPreferences.cpp +149 -0
- data/ext/wxPreferences.hpp +18 -0
- data/ext/wxProgressDialog.cpp +171 -0
- data/ext/wxProgressDialog.hpp +20 -0
- data/ext/wxProperty.cpp +723 -0
- data/ext/wxProperty.hpp +16 -0
- data/ext/wxPropertyCell.cpp +99 -0
- data/ext/wxPropertyCell.hpp +16 -0
- data/ext/wxPropertyGrid.cpp +234 -0
- data/ext/wxPropertyGrid.hpp +20 -0
- data/ext/wxPropertyGridInterface.cpp +146 -0
- data/ext/wxPropertyGridInterface.hpp +33 -0
- data/ext/wxPropertyGridManager.cpp +257 -0
- data/ext/wxPropertyGridManager.hpp +20 -0
- data/ext/wxPropertyGridPage.cpp +65 -0
- data/ext/wxPropertyGridPage.hpp +20 -0
- data/ext/wxRadioBox.cpp +405 -0
- data/ext/wxRadioBox.hpp +20 -0
- data/ext/wxRadioButton.cpp +107 -0
- data/ext/wxRadioButton.hpp +16 -0
- data/ext/wxRearrangeCtrl.cpp +89 -0
- data/ext/wxRearrangeCtrl.hpp +20 -0
- data/ext/wxRearrangeDialog.cpp +122 -0
- data/ext/wxRearrangeDialog.hpp +20 -0
- data/ext/wxRearrangeList.cpp +94 -0
- data/ext/wxRearrangeList.hpp +20 -0
- data/ext/wxRect.cpp +281 -0
- data/ext/wxRect.hpp +29 -0
- data/ext/wxRichMessageDialog.cpp +91 -0
- data/ext/wxRichMessageDialog.hpp +21 -0
- data/ext/wxRichTextAttr.cpp +69 -0
- data/ext/wxRichTextAttr.hpp +28 -0
- data/ext/wxRichTextCtrl.cpp +484 -0
- data/ext/wxRichTextCtrl.hpp +21 -0
- data/ext/wxRichTextStyle.cpp +86 -0
- data/ext/wxRichTextStyle.hpp +25 -0
- data/ext/wxRichTextStyleSheet.cpp +497 -0
- data/ext/wxRichTextStyleSheet.hpp +21 -0
- data/ext/wxSTC.cpp +331 -0
- data/ext/wxSTC.hpp +21 -0
- data/ext/wxScrollEvent.cpp +43 -0
- data/ext/wxScrollEvent.hpp +16 -0
- data/ext/wxSearchCtrl.cpp +189 -0
- data/ext/wxSearchCtrl.hpp +21 -0
- data/ext/wxSimpleBook.cpp +89 -0
- data/ext/wxSimpleBook.hpp +21 -0
- data/ext/wxSingleChoiceDialog.cpp +147 -0
- data/ext/wxSingleChoiceDialog.hpp +19 -0
- data/ext/wxSize.cpp +206 -0
- data/ext/wxSize.hpp +32 -0
- data/ext/wxSizer.cpp +368 -0
- data/ext/wxSizer.hpp +23 -0
- data/ext/wxSizerItem.cpp +37 -0
- data/ext/wxSizerItem.hpp +18 -0
- data/ext/wxSlider.cpp +204 -0
- data/ext/wxSlider.hpp +21 -0
- data/ext/wxSpinButton.cpp +158 -0
- data/ext/wxSpinButton.hpp +20 -0
- data/ext/wxSpinCtrl.cpp +132 -0
- data/ext/wxSpinCtrl.hpp +21 -0
- data/ext/wxStartUpTip.cpp +44 -0
- data/ext/wxStartUpTip.hpp +16 -0
- data/ext/wxStaticBitmap.cpp +79 -0
- data/ext/wxStaticBitmap.hpp +17 -0
- data/ext/wxStaticBitmapBase.cpp +46 -0
- data/ext/wxStaticBitmapBase.hpp +22 -0
- data/ext/wxStaticBitmapGeneric.cpp +82 -0
- data/ext/wxStaticBitmapGeneric.hpp +17 -0
- data/ext/wxStaticBox.cpp +92 -0
- data/ext/wxStaticBox.hpp +22 -0
- data/ext/wxStaticLine.cpp +100 -0
- data/ext/wxStaticLine.hpp +22 -0
- data/ext/wxStaticText.cpp +82 -0
- data/ext/wxStaticText.hpp +21 -0
- data/ext/wxStatusBar.cpp +417 -0
- data/ext/wxStatusBar.hpp +17 -0
- data/ext/wxStream.cpp +41 -0
- data/ext/wxStream.hpp +46 -0
- data/ext/wxTaskBar.cpp +104 -0
- data/ext/wxTaskBar.hpp +41 -0
- data/ext/wxTextArea.cpp +141 -0
- data/ext/wxTextArea.hpp +21 -0
- data/ext/wxTextAttr.cpp +320 -0
- data/ext/wxTextAttr.hpp +28 -0
- data/ext/wxTextCtrl.cpp +177 -0
- data/ext/wxTextCtrl.hpp +30 -0
- data/ext/wxTextEntry.cpp +248 -0
- data/ext/wxTextEntry.hpp +19 -0
- data/ext/wxTextEntryDialog.cpp +133 -0
- data/ext/wxTextEntryDialog.hpp +20 -0
- data/ext/wxTimePicker.cpp +105 -0
- data/ext/wxTimePicker.hpp +22 -0
- data/ext/wxTimer.cpp +106 -0
- data/ext/wxTimer.hpp +16 -0
- data/ext/wxToggleButton.cpp +96 -0
- data/ext/wxToggleButton.hpp +21 -0
- data/ext/wxToolBar.cpp +85 -0
- data/ext/wxToolBar.hpp +17 -0
- data/ext/wxToolBarBase.cpp +615 -0
- data/ext/wxToolBarBase.hpp +17 -0
- data/ext/wxToolBarTool.cpp +179 -0
- data/ext/wxToolBarTool.hpp +16 -0
- data/ext/wxToolBook.cpp +96 -0
- data/ext/wxToolBook.hpp +23 -0
- data/ext/wxToplevel.cpp +125 -0
- data/ext/wxToplevel.hpp +25 -0
- data/ext/wxTreeBook.cpp +240 -0
- data/ext/wxTreeBook.hpp +21 -0
- data/ext/wxTreeCtrl.cpp +443 -0
- data/ext/wxTreeCtrl.hpp +66 -0
- data/ext/wxVariant.cpp +65 -0
- data/ext/wxVariant.hpp +17 -0
- data/ext/wxWindow.cpp +980 -0
- data/ext/wxWindow.hpp +35 -0
- data/ext/wxWizard.cpp +321 -0
- data/ext/wxWizard.hpp +19 -0
- data/ext/wxWizardPage.cpp +137 -0
- data/ext/wxWizardPage.hpp +38 -0
- data/ext/wxXRC.cpp +48 -0
- data/ext/wxXRC.hpp +21 -0
- data/old_tests/button.rb +56 -0
- data/old_tests/file.png +0 -0
- data/old_tests/green.xpm +25 -0
- data/old_tests/new16x16.png +0 -0
- data/old_tests/project.xml +10 -0
- data/old_tests/propertygrid.rb +51 -0
- data/old_tests/red.xpm +25 -0
- data/old_tests/ruby32x32.png +0 -0
- data/old_tests/status.rb +45 -0
- data/old_tests/test.rb +580 -0
- data/old_tests/wizard.xrc +40 -0
- data/old_tests/xrc.rb +38 -0
- data/rwx.gemspec +43 -0
- data/samples/controls/controls.rb +143 -0
- data/samples/controls/icons/choice.bmp +0 -0
- data/samples/controls/icons/choice.xpm +27 -0
- data/samples/controls/icons/combo.bmp +0 -0
- data/samples/controls/icons/combo.xpm +27 -0
- data/samples/controls/icons/gauge.bmp +0 -0
- data/samples/controls/icons/gauge.xpm +27 -0
- data/samples/controls/icons/list.bmp +0 -0
- data/samples/controls/icons/list.xpm +27 -0
- data/samples/controls/icons/radio.bmp +0 -0
- data/samples/controls/icons/radio.xpm +27 -0
- data/samples/controls/icons/stattext.xpm +24 -0
- data/samples/controls/icons/text.bmp +0 -0
- data/samples/controls/icons/text.xpm +27 -0
- data/samples/dialog/dialog_sample.rb +227 -0
- data/samples/sample.xpm +44 -0
- data/samples/widgets/icons/bmpbtn.xpm +37 -0
- data/samples/widgets/icons/bmpcombobox.xpm +54 -0
- data/samples/widgets/icons/button.xpm +54 -0
- data/samples/widgets/icons/checkbox.xpm +54 -0
- data/samples/widgets/icons/choice.xpm +27 -0
- data/samples/widgets/icons/choicebk.xpm +54 -0
- data/samples/widgets/icons/clrpicker.xpm +193 -0
- data/samples/widgets/icons/combobox.xpm +54 -0
- data/samples/widgets/icons/datepick.xpm +200 -0
- data/samples/widgets/icons/dirctrl.xpm +54 -0
- data/samples/widgets/icons/dirpicker.xpm +213 -0
- data/samples/widgets/icons/filepicker.xpm +214 -0
- data/samples/widgets/icons/fontpicker.xpm +185 -0
- data/samples/widgets/icons/gauge.xpm +54 -0
- data/samples/widgets/icons/hyperlnk.xpm +54 -0
- data/samples/widgets/icons/listbook.xpm +54 -0
- data/samples/widgets/icons/listbox.xpm +54 -0
- data/samples/widgets/icons/notebook.xpm +54 -0
- data/samples/widgets/icons/odcombobox.xpm +54 -0
- data/samples/widgets/icons/radiobox.xpm +54 -0
- data/samples/widgets/icons/scrolbar.xpm +54 -0
- data/samples/widgets/icons/slider.xpm +54 -0
- data/samples/widgets/icons/spinbtn.xpm +40 -0
- data/samples/widgets/icons/statbmp.xpm +40 -0
- data/samples/widgets/icons/statbox.xpm +54 -0
- data/samples/widgets/icons/stattext.xpm +54 -0
- data/samples/widgets/icons/text.xpm +54 -0
- data/samples/widgets/icons/timepick.xpm +207 -0
- data/samples/widgets/icons/toggle.xpm +54 -0
- data/samples/widgets/pages/colorpicker.rb +66 -0
- data/samples/widgets/pages/common.rb +17 -0
- data/samples/widgets/widgets.rb +29 -0
- data/samples/xrc/samples.xrc +46 -0
- data/samples/xrc/xrc_sample.rb +59 -0
- data/test/test_color.rb +64 -0
- metadata +470 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* wxGridCellRenderer.hpp
|
|
3
|
+
*
|
|
4
|
+
* Created on: 19.04.2012
|
|
5
|
+
* Author: hanmac
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#ifndef WXGRIDCELLRENDERER_HPP_
|
|
9
|
+
#define WXGRIDCELLRENDERER_HPP_
|
|
10
|
+
|
|
11
|
+
#include "main.hpp"
|
|
12
|
+
|
|
13
|
+
extern VALUE rb_cWXGridCellRenderer;
|
|
14
|
+
void Init_WXGridCellRenderer(VALUE rb_mWX);
|
|
15
|
+
|
|
16
|
+
#if wxUSE_GRID
|
|
17
|
+
#include <wx/grid.h>
|
|
18
|
+
|
|
19
|
+
template <>
|
|
20
|
+
VALUE wrap< wxGridCellRenderer >(wxGridCellRenderer* window);
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
template <>
|
|
24
|
+
wxGridCellRenderer* unwrap<wxGridCellRenderer*>(const VALUE &arg);
|
|
25
|
+
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
#endif /* WXGRIDCELLRENDERER_HPP_ */
|
data/ext/wxGridTable.cpp
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* wxGridTable.cpp
|
|
3
|
+
*
|
|
4
|
+
* Created on: 15.04.2012
|
|
5
|
+
* Author: hanmac
|
|
6
|
+
*/
|
|
7
|
+
#include "wxGridTable.hpp"
|
|
8
|
+
#include "wxEvtHandler.hpp"
|
|
9
|
+
#define mRuby static_cast<RubyClientData*>(GetClientObject())->mRuby
|
|
10
|
+
|
|
11
|
+
VALUE rb_cWXGridTable;
|
|
12
|
+
|
|
13
|
+
#if wxUSE_GRID
|
|
14
|
+
RubyGridTable::RubyGridTable(VALUE klass) : wxGridTableBase()
|
|
15
|
+
{
|
|
16
|
+
this->SetClientObject(new RubyClientData(wrapTypedPtr((void*)this,klass)));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
int RubyGridTable::GetNumberRows()
|
|
20
|
+
{
|
|
21
|
+
return NUM2INT(rb_funcall(mRuby,rb_intern("rows"),0));
|
|
22
|
+
}
|
|
23
|
+
int RubyGridTable::GetNumberCols()
|
|
24
|
+
{
|
|
25
|
+
return NUM2INT(rb_funcall(mRuby,rb_intern("cols"),0));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
wxString RubyGridTable::GetValue( int row, int col )
|
|
29
|
+
{
|
|
30
|
+
return unwrap<wxString>(rb_funcall(mRuby,rb_intern("[]"),2,INT2NUM(row),INT2NUM(col)));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void RubyGridTable::SetValue( int row, int col, const wxString& value )
|
|
34
|
+
{
|
|
35
|
+
rb_funcall(mRuby,rb_intern("[]="),3,INT2NUM(row),INT2NUM(col),wrap(value));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
wxString RubyGridTable::GetTypeName( int row, int col )
|
|
41
|
+
{
|
|
42
|
+
return unwrap<wxString>(rb_funcall(mRuby,rb_intern("typename"),2,INT2NUM(row),INT2NUM(col)));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void RubyGridTable::Clear()
|
|
46
|
+
{
|
|
47
|
+
rb_funcall(mRuby,rb_intern("clear"),0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
bool RubyGridTable::InsertRows( size_t pos, size_t numRows)
|
|
51
|
+
{
|
|
52
|
+
return RTEST(rb_funcall(mRuby,rb_intern("insert_rows"),2,UINT2NUM(pos),UINT2NUM(numRows)));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
bool RubyGridTable::AppendRows( size_t numRows)
|
|
56
|
+
{
|
|
57
|
+
return RTEST(rb_funcall(mRuby,rb_intern("append_rows"),1,UINT2NUM(numRows)));
|
|
58
|
+
}
|
|
59
|
+
bool RubyGridTable::DeleteRows( size_t pos, size_t numRows)
|
|
60
|
+
{
|
|
61
|
+
return RTEST(rb_funcall(mRuby,rb_intern("delete_rows"),2,UINT2NUM(pos),UINT2NUM(numRows)));
|
|
62
|
+
}
|
|
63
|
+
bool RubyGridTable::InsertCols( size_t pos, size_t numCols)
|
|
64
|
+
{
|
|
65
|
+
return RTEST(rb_funcall(mRuby,rb_intern("insert_cols"),2,UINT2NUM(pos),UINT2NUM(numCols)));
|
|
66
|
+
}
|
|
67
|
+
bool RubyGridTable::AppendCols( size_t numCols)
|
|
68
|
+
{
|
|
69
|
+
return RTEST(rb_funcall(mRuby,rb_intern("append_cols"),1,UINT2NUM(numCols)));
|
|
70
|
+
}
|
|
71
|
+
bool RubyGridTable::DeleteCols( size_t pos, size_t numCols)
|
|
72
|
+
{
|
|
73
|
+
return RTEST(rb_funcall(mRuby,rb_intern("delete_cols"),2,UINT2NUM(pos),UINT2NUM(numCols)));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
template <>
|
|
78
|
+
wxGridTableBase* unwrap<wxGridTableBase*>(const VALUE &arg)
|
|
79
|
+
{
|
|
80
|
+
return unwrapTypedPtr<wxGridTableBase>(arg,rb_cWXGridTable);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
namespace RubyWX {
|
|
85
|
+
namespace GridTable {
|
|
86
|
+
#define _self unwrap<wxGridTableBase*>(self)
|
|
87
|
+
//macro_attr(Path,wxString)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
DLL_LOCAL VALUE _alloc(VALUE self)
|
|
91
|
+
{
|
|
92
|
+
return wrapTypedPtr(new RubyGridTable(self),self);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#endif
|
|
99
|
+
|
|
100
|
+
DLL_LOCAL void Init_WXGridTable(VALUE rb_mWX)
|
|
101
|
+
{
|
|
102
|
+
#if wxUSE_GRID
|
|
103
|
+
using namespace RubyWX::GridTable;
|
|
104
|
+
rb_cWXGridTable = rb_define_class_under(rb_mWX,"GridTable",rb_cObject);
|
|
105
|
+
rb_define_alloc_func(rb_cWXGridTable,_alloc);
|
|
106
|
+
|
|
107
|
+
registerInfo<wxGridTableBase>(rb_cWXGridTable);
|
|
108
|
+
#endif
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
data/ext/wxGridTable.hpp
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* wxGridTable.hpp
|
|
3
|
+
*
|
|
4
|
+
* Created on: 15.04.2012
|
|
5
|
+
* Author: hanmac
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#ifndef WXGRIDTABLE_HPP_
|
|
9
|
+
#define WXGRIDTABLE_HPP_
|
|
10
|
+
|
|
11
|
+
#include "main.hpp"
|
|
12
|
+
|
|
13
|
+
extern VALUE rb_cWXGridTable;
|
|
14
|
+
void Init_WXGridTable(VALUE rb_mWX);
|
|
15
|
+
|
|
16
|
+
#if wxUSE_GRID
|
|
17
|
+
#include <wx/grid.h>
|
|
18
|
+
|
|
19
|
+
class RubyGridTable : public wxGridTableBase
|
|
20
|
+
{
|
|
21
|
+
public:
|
|
22
|
+
RubyGridTable(VALUE klass);
|
|
23
|
+
|
|
24
|
+
int GetNumberRows();
|
|
25
|
+
int GetNumberCols();
|
|
26
|
+
|
|
27
|
+
wxString GetValue( int row, int col );
|
|
28
|
+
void SetValue( int row, int col, const wxString& value );
|
|
29
|
+
|
|
30
|
+
wxString GetTypeName( int row, int col );
|
|
31
|
+
|
|
32
|
+
void Clear();
|
|
33
|
+
bool InsertRows( size_t pos = 0, size_t numRows = 1 );
|
|
34
|
+
bool AppendRows( size_t numRows = 1 );
|
|
35
|
+
bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
|
|
36
|
+
bool InsertCols( size_t pos = 0, size_t numCols = 1 );
|
|
37
|
+
bool AppendCols( size_t numCols = 1 );
|
|
38
|
+
bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
|
|
39
|
+
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
template <>
|
|
43
|
+
wxGridTableBase* unwrap<wxGridTableBase*>(const VALUE &arg);
|
|
44
|
+
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
#endif /* WXGRIDTABLE_HPP_ */
|
data/ext/wxHyperLink.cpp
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* wxHyperLink.cpp
|
|
3
|
+
*
|
|
4
|
+
* Created on: 12.03.2012
|
|
5
|
+
* Author: hanmac
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#include "wxHyperLink.hpp"
|
|
10
|
+
#include "wxColor.hpp"
|
|
11
|
+
|
|
12
|
+
VALUE rb_cWXHyperLink;
|
|
13
|
+
|
|
14
|
+
#if wxUSE_HYPERLINKCTRL
|
|
15
|
+
#define _self unwrap<wxHyperlinkCtrl*>(self)
|
|
16
|
+
|
|
17
|
+
namespace RubyWX {
|
|
18
|
+
namespace HyperLink {
|
|
19
|
+
|
|
20
|
+
macro_attr(HoverColour,wxColour)
|
|
21
|
+
macro_attr(NormalColour,wxColour)
|
|
22
|
+
macro_attr(VisitedColour,wxColour)
|
|
23
|
+
|
|
24
|
+
macro_attr(URL,wxString)
|
|
25
|
+
|
|
26
|
+
macro_attr(Visited,bool)
|
|
27
|
+
|
|
28
|
+
APP_PROTECT(wxHyperlinkCtrl)
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* call-seq:
|
|
32
|
+
* HyperLink.new(parent, name, [options])
|
|
33
|
+
* HyperLink.new(parent, [options])
|
|
34
|
+
*
|
|
35
|
+
* creates a new HyperLink widget.
|
|
36
|
+
* ===Arguments
|
|
37
|
+
* * parent of this window or nil
|
|
38
|
+
* * name is a String describing a resource in a loaded xrc
|
|
39
|
+
*
|
|
40
|
+
* *options: Hash with possible options to set:
|
|
41
|
+
* * url String
|
|
42
|
+
* * hover_color wxColor
|
|
43
|
+
* * normal_color wxColor
|
|
44
|
+
* * visited_color wxColor
|
|
45
|
+
* * visited true/false
|
|
46
|
+
*/
|
|
47
|
+
DLL_LOCAL VALUE _initialize(int argc,VALUE *argv,VALUE self)
|
|
48
|
+
{
|
|
49
|
+
VALUE parent,name,hash;
|
|
50
|
+
rb_scan_args(argc, argv, "11:",&parent,&name,&hash);
|
|
51
|
+
|
|
52
|
+
if(NIL_P(hash))
|
|
53
|
+
name = hash;
|
|
54
|
+
|
|
55
|
+
if(!_created && !rb_obj_is_kind_of(name,rb_cString))
|
|
56
|
+
{
|
|
57
|
+
wxWindowID id(wxID_ANY);
|
|
58
|
+
wxString label("label");
|
|
59
|
+
wxString url(wxEmptyString);
|
|
60
|
+
int style(wxHL_DEFAULT_STYLE);
|
|
61
|
+
|
|
62
|
+
if(rb_obj_is_kind_of(hash,rb_cHash))
|
|
63
|
+
{
|
|
64
|
+
set_hash_option(hash,"id",id,unwrapID);
|
|
65
|
+
set_hash_option(hash,"label",label);
|
|
66
|
+
set_hash_option(hash,"url",url);
|
|
67
|
+
set_hash_option(hash,"style",style);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_self->Create(
|
|
71
|
+
unwrap<wxWindow*>(parent),id,label,url,
|
|
72
|
+
wxDefaultPosition,wxDefaultSize,style
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
rb_call_super(argc,argv);
|
|
78
|
+
|
|
79
|
+
if(rb_obj_is_kind_of(hash,rb_cHash))
|
|
80
|
+
{
|
|
81
|
+
VALUE temp;
|
|
82
|
+
set_option(hover_color,HoverColour,wxColour)
|
|
83
|
+
set_option(normal_color,NormalColour,wxColour)
|
|
84
|
+
set_option(visited_color,VisitedColour,wxColour)
|
|
85
|
+
|
|
86
|
+
set_option(visited,Visited,bool)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return self;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
#endif
|
|
95
|
+
|
|
96
|
+
/* Document-attr: hover_color
|
|
97
|
+
* the hover color of the HyperLink. WX::Color
|
|
98
|
+
*/
|
|
99
|
+
/* Document-attr: normal_color
|
|
100
|
+
* the normal color of the HyperLink. WX::Color
|
|
101
|
+
*/
|
|
102
|
+
/* Document-attr: visited_color
|
|
103
|
+
* the visited color of the HyperLink. WX::Color
|
|
104
|
+
*/
|
|
105
|
+
/* Document-attr: url
|
|
106
|
+
* the url of the HyperLink. String
|
|
107
|
+
*/
|
|
108
|
+
/* Document-attr: visited_color
|
|
109
|
+
* the visited of the HyperLink. bool
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
DLL_LOCAL void Init_WXHyperLink(VALUE rb_mWX)
|
|
113
|
+
{
|
|
114
|
+
#if 0
|
|
115
|
+
rb_mWX = rb_define_module("WX");
|
|
116
|
+
rb_cWXWindow = rb_define_class_under(rb_mWX,"Window",rb_cObject);
|
|
117
|
+
|
|
118
|
+
rb_cWXControl = rb_define_class_under(rb_mWX,"Control",rb_cWXWindow);
|
|
119
|
+
|
|
120
|
+
rb_define_attr(rb_cWXHyperLink,"hover_color",1,1);
|
|
121
|
+
rb_define_attr(rb_cWXHyperLink,"normal_color",1,1);
|
|
122
|
+
rb_define_attr(rb_cWXHyperLink,"visited_color",1,1);
|
|
123
|
+
|
|
124
|
+
rb_define_attr(rb_cWXHyperLink,"url",1,1);
|
|
125
|
+
rb_define_attr(rb_cWXHyperLink,"visited",1,1);
|
|
126
|
+
|
|
127
|
+
#endif
|
|
128
|
+
|
|
129
|
+
#if wxUSE_HYPERLINKCTRL
|
|
130
|
+
using namespace RubyWX::HyperLink;
|
|
131
|
+
rb_cWXHyperLink = rb_define_class_under(rb_mWX,"HyperLink",rb_cWXControl);
|
|
132
|
+
rb_define_alloc_func(rb_cWXHyperLink,_alloc);
|
|
133
|
+
|
|
134
|
+
rb_define_method(rb_cWXHyperLink,"initialize",RUBY_METHOD_FUNC(_initialize),-1);
|
|
135
|
+
|
|
136
|
+
rb_define_attr_method(rb_cWXHyperLink,"hover_color",_getHoverColour,_setHoverColour);
|
|
137
|
+
rb_define_attr_method(rb_cWXHyperLink,"normal_color",_getNormalColour,_setNormalColour);
|
|
138
|
+
rb_define_attr_method(rb_cWXHyperLink,"visited_color",_getVisitedColour,_setVisitedColour);
|
|
139
|
+
|
|
140
|
+
rb_define_attr_method(rb_cWXHyperLink,"url",_getURL,_setURL);
|
|
141
|
+
rb_define_attr_method(rb_cWXHyperLink,"visited",_getVisited,_setVisited);
|
|
142
|
+
|
|
143
|
+
registerInfo<wxHyperlinkCtrl>(rb_cWXHyperLink);
|
|
144
|
+
#endif
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
data/ext/wxHyperLink.hpp
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* wxHyperLink.hpp
|
|
3
|
+
*
|
|
4
|
+
* Created on: 12.03.2012
|
|
5
|
+
* Author: hanmac
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#ifndef WXHYPERLINK_HPP_
|
|
9
|
+
#define WXHYPERLINK_HPP_
|
|
10
|
+
|
|
11
|
+
#include "wxEvtHandler.hpp"
|
|
12
|
+
|
|
13
|
+
extern VALUE rb_cWXHyperLink;
|
|
14
|
+
|
|
15
|
+
void Init_WXHyperLink(VALUE rb_mWX);
|
|
16
|
+
|
|
17
|
+
#if wxUSE_HYPERLINKCTRL
|
|
18
|
+
#include <wx/hyperlink.h>
|
|
19
|
+
#endif
|
|
20
|
+
#endif /* WXHYPERLINK_HPP_ */
|
data/ext/wxImage.cpp
ADDED
|
@@ -0,0 +1,884 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* wxImage.cpp
|
|
3
|
+
*
|
|
4
|
+
* Created on: 16.02.2012
|
|
5
|
+
* Author: hanmac
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "wxSize.hpp"
|
|
9
|
+
#include "wxRect.hpp"
|
|
10
|
+
#include "wxPoint.hpp"
|
|
11
|
+
|
|
12
|
+
#include "wxImage.hpp"
|
|
13
|
+
#include "wxBitmap.hpp"
|
|
14
|
+
#include "wxDC.hpp"
|
|
15
|
+
#include "wxColor.hpp"
|
|
16
|
+
|
|
17
|
+
#include "wxStream.hpp"
|
|
18
|
+
|
|
19
|
+
#if wxUSE_PALETTE
|
|
20
|
+
#include "wxPalette.hpp"
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
#if wxUSE_IMAGE
|
|
24
|
+
|
|
25
|
+
#define _self unwrap<wxImage*>(self)
|
|
26
|
+
|
|
27
|
+
VALUE rb_cWXImage;
|
|
28
|
+
|
|
29
|
+
template <>
|
|
30
|
+
wxImage* unwrap< wxImage* >(const VALUE &vimage)
|
|
31
|
+
{
|
|
32
|
+
if(rb_obj_is_kind_of(vimage,rb_cWXImage))
|
|
33
|
+
return unwrapTypedPtr<wxImage>(vimage, rb_cWXImage);
|
|
34
|
+
if(is_wrapable<wxSize>(vimage))
|
|
35
|
+
return new wxImage(unwrap<wxSize>(vimage));
|
|
36
|
+
return unwrapTypedPtr<wxImage>(rb_class_new_instance(1,const_cast<VALUE*>(&vimage),rb_cWXImage), rb_cWXImage);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
template <>
|
|
41
|
+
wxImage unwrap< wxImage >(const VALUE &vimage)
|
|
42
|
+
{
|
|
43
|
+
return *unwrap<wxImage*>(vimage);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
namespace RubyWX {
|
|
48
|
+
namespace Image {
|
|
49
|
+
|
|
50
|
+
#if wxUSE_PALETTE
|
|
51
|
+
macro_attr(Palette,wxPalette)
|
|
52
|
+
#endif
|
|
53
|
+
|
|
54
|
+
DLL_LOCAL VALUE _load(int argc,VALUE *argv,VALUE self)
|
|
55
|
+
{
|
|
56
|
+
VALUE name,mime,nr;
|
|
57
|
+
rb_scan_args(argc, argv, "12",&name,&mime,&nr);
|
|
58
|
+
|
|
59
|
+
bool result;
|
|
60
|
+
|
|
61
|
+
if(NIL_P(nr))
|
|
62
|
+
nr = INT2NUM(-1);
|
|
63
|
+
|
|
64
|
+
#if wxUSE_STREAMS
|
|
65
|
+
if(!rb_respond_to(name,rb_intern("read")))
|
|
66
|
+
{
|
|
67
|
+
#endif
|
|
68
|
+
if(!check_file_loadable(unwrap<wxString>(name)))
|
|
69
|
+
return Qfalse;
|
|
70
|
+
|
|
71
|
+
wxFileName file(unwrap<wxString>(name));
|
|
72
|
+
file.MakeAbsolute(wxGetCwd());
|
|
73
|
+
|
|
74
|
+
if(NIL_P(mime)){
|
|
75
|
+
result = _self->LoadFile(file.GetFullPath(), wxBITMAP_TYPE_ANY, NUM2INT(nr));
|
|
76
|
+
}else if(SYMBOL_P(mime) || FIXNUM_P(mime)){
|
|
77
|
+
// result = _self->LoadFile(file.GetFullPath(),unwrap<wxBitmapType>(mime),NUM2INT(nr));
|
|
78
|
+
}else
|
|
79
|
+
result = _self->LoadFile(file.GetFullPath(),unwrap<wxString>(mime),NUM2INT(nr));
|
|
80
|
+
#if wxUSE_STREAMS
|
|
81
|
+
}else{
|
|
82
|
+
RubyInputStream st(name);
|
|
83
|
+
|
|
84
|
+
if(NIL_P(mime)){
|
|
85
|
+
result = _self->LoadFile(st, wxBITMAP_TYPE_ANY, NUM2INT(nr));
|
|
86
|
+
}else if(SYMBOL_P(mime) || FIXNUM_P(mime)){
|
|
87
|
+
// result = _self->LoadFile(st,unwrap<wxBitmapType>(mime),NUM2INT(nr));
|
|
88
|
+
}else
|
|
89
|
+
result = _self->LoadFile(st,unwrap<wxString>(mime),NUM2INT(nr));
|
|
90
|
+
}
|
|
91
|
+
#endif
|
|
92
|
+
return wrap(result);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
DLL_LOCAL VALUE _alloc(VALUE self) {
|
|
96
|
+
return wrap(new wxImage);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
* call-seq:
|
|
102
|
+
* Image.new(path,[type,[id]])
|
|
103
|
+
* Image.new(width,height)
|
|
104
|
+
*
|
|
105
|
+
* creates a new Image Object.
|
|
106
|
+
*/
|
|
107
|
+
DLL_LOCAL VALUE _initialize(int argc,VALUE *argv,VALUE self)
|
|
108
|
+
{
|
|
109
|
+
VALUE width,height,arg1;
|
|
110
|
+
rb_scan_args(argc, argv, "12",&width,&height,&arg1);
|
|
111
|
+
if(rb_obj_is_kind_of(width, rb_cWXSize))
|
|
112
|
+
{
|
|
113
|
+
_self->Create(unwrap<wxSize>(width));
|
|
114
|
+
} else if(! rb_obj_is_kind_of(width, rb_cNumeric) || NIL_P(height) || !NIL_P(arg1))
|
|
115
|
+
_load(argc,argv,self);
|
|
116
|
+
else
|
|
117
|
+
_self->Create(NUM2INT(width),NUM2INT(height));
|
|
118
|
+
//_self->InitAlpha();
|
|
119
|
+
return self;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
DLL_LOCAL VALUE _getHeight(VALUE self)
|
|
124
|
+
{
|
|
125
|
+
if(_self->IsOk())
|
|
126
|
+
return ULONG2NUM(_self->GetHeight());
|
|
127
|
+
return Qnil;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
DLL_LOCAL VALUE _getWidth(VALUE self)
|
|
131
|
+
{
|
|
132
|
+
if(_self->IsOk())
|
|
133
|
+
return ULONG2NUM(_self->GetWidth());
|
|
134
|
+
return Qnil;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
DLL_LOCAL VALUE _getSize(VALUE self)
|
|
139
|
+
{
|
|
140
|
+
if(_self->IsOk())
|
|
141
|
+
return wrap(_self->GetSize());
|
|
142
|
+
return Qnil;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
DLL_LOCAL VALUE _getData(VALUE self)
|
|
146
|
+
{
|
|
147
|
+
if(_self->IsOk())
|
|
148
|
+
return rb_str_new((char*)_self->GetData(),_self->GetHeight() * _self->GetWidth() * 3);
|
|
149
|
+
return Qnil;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
DLL_LOCAL VALUE _getAlpha(VALUE self)
|
|
153
|
+
{
|
|
154
|
+
if(_self->IsOk() && _self->HasAlpha())
|
|
155
|
+
{
|
|
156
|
+
return rb_str_new((char*) _self->GetAlpha(),_self->GetHeight() * _self->GetWidth());
|
|
157
|
+
}
|
|
158
|
+
return Qnil;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
bool check_inside(int x, int y, const wxSize& size)
|
|
163
|
+
{
|
|
164
|
+
return x >= 0 && y >= 0 && x < size.GetWidth() && y < size.GetHeight();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
* call-seq:
|
|
169
|
+
* image[rect] -> WX::Image or nil
|
|
170
|
+
* image[x,y] -> WX::Color or nil
|
|
171
|
+
*
|
|
172
|
+
* if giving a WX::Rect, return a sub image of the given place
|
|
173
|
+
* if giving x and y, return the color of the given position or nil when out of range
|
|
174
|
+
* ===Arguments
|
|
175
|
+
* * x and y are Integer
|
|
176
|
+
* * rect is a WX::Rect
|
|
177
|
+
* ===Return value
|
|
178
|
+
* WX::Image, WX::Color or nil
|
|
179
|
+
*/
|
|
180
|
+
DLL_LOCAL VALUE _get(int argc,VALUE *argv,VALUE self)
|
|
181
|
+
{
|
|
182
|
+
VALUE vx,vy;
|
|
183
|
+
rb_scan_args(argc, argv, "11",&vx,&vy);
|
|
184
|
+
if(_self->IsOk())
|
|
185
|
+
{
|
|
186
|
+
if(NIL_P(vy))
|
|
187
|
+
{
|
|
188
|
+
return wrap(_self->GetSubImage(unwrap<wxRect>(vx)));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
int x,y;
|
|
192
|
+
x = NUM2UINT(vx);
|
|
193
|
+
y = NUM2UINT(vy);
|
|
194
|
+
|
|
195
|
+
if(!check_inside(x,y, _self->GetSize()))
|
|
196
|
+
return Qnil;
|
|
197
|
+
|
|
198
|
+
unsigned char red,green,blue,alpha;
|
|
199
|
+
red = _self->GetRed(x,y);
|
|
200
|
+
green = _self->GetGreen(x,y);
|
|
201
|
+
blue = _self->GetBlue(x,y);
|
|
202
|
+
if(_self->HasAlpha())
|
|
203
|
+
alpha = _self->GetAlpha(x,y);
|
|
204
|
+
else
|
|
205
|
+
alpha = wxALPHA_OPAQUE;
|
|
206
|
+
return wrap(new wxColor(red,green,blue,alpha));
|
|
207
|
+
}else
|
|
208
|
+
return Qnil;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
void set_at_pos(int x, int y, wxImage* self, VALUE val)
|
|
212
|
+
{
|
|
213
|
+
if(!check_inside(x, y, self->GetSize()))
|
|
214
|
+
return;
|
|
215
|
+
|
|
216
|
+
if(rb_obj_is_kind_of(val,rb_cWXImage) || rb_obj_is_kind_of(val,rb_cWXBitmap))
|
|
217
|
+
{
|
|
218
|
+
self->Paste(unwrap<wxImage>(val),x,y);
|
|
219
|
+
} else {
|
|
220
|
+
wxColor c(unwrap<wxColor>(val));
|
|
221
|
+
self->SetRGB(x,y,c.Red(),c.Green(),c.Blue());
|
|
222
|
+
if(self->HasAlpha())
|
|
223
|
+
self->SetAlpha(x,y,c.Alpha());
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/*
|
|
228
|
+
* call-seq:
|
|
229
|
+
* image[x,y]= WX::Color or WX::Image or WX::Bitmap
|
|
230
|
+
* image[pos]= WX::Color or WX::Image or WX::Bitmap
|
|
231
|
+
* image[rect]= WX::Color
|
|
232
|
+
*
|
|
233
|
+
* if giving x and y or pos, and as value a color, sets the color at the given position
|
|
234
|
+
* if giving x and y or pos, and an image or bitmap does paste it at the given position
|
|
235
|
+
* if giving a WX::Rect, fill the color at the place with the given one
|
|
236
|
+
* ===Arguments
|
|
237
|
+
* * x and y are Integer
|
|
238
|
+
* * pos is a WX::Point
|
|
239
|
+
* * rect is a WX::Rect
|
|
240
|
+
*
|
|
241
|
+
* === Exceptions
|
|
242
|
+
* [ArgumentError]
|
|
243
|
+
* * rect does not fit into the Size of the Image
|
|
244
|
+
*/
|
|
245
|
+
DLL_LOCAL VALUE _set(int argc,VALUE *argv,VALUE self)
|
|
246
|
+
{
|
|
247
|
+
VALUE vx,vy,value;
|
|
248
|
+
rb_scan_args(argc, argv, "21",&vx,&vy,&value);
|
|
249
|
+
if(_self->IsOk())
|
|
250
|
+
{
|
|
251
|
+
if(NIL_P(value)) {
|
|
252
|
+
if(is_wrapable<wxRect>(vx)) {
|
|
253
|
+
wxColor c(unwrap<wxColor>(vy));
|
|
254
|
+
wxSize size(_self->GetSize());
|
|
255
|
+
wxRect vrect(unwrap<wxRect>(vx));
|
|
256
|
+
|
|
257
|
+
if(wxRect(size).Contains(vrect))
|
|
258
|
+
{
|
|
259
|
+
_self->SetRGB(vrect,c.Red(),c.Green(),c.Blue());
|
|
260
|
+
if(_self->HasAlpha()) {
|
|
261
|
+
for(int i = vrect.x; i < vrect.width; ++i)
|
|
262
|
+
for(int j = vrect.y; j < vrect.height; ++j)
|
|
263
|
+
if(check_inside(i, j, size))
|
|
264
|
+
_self->SetAlpha(i,j,c.Alpha());
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
rb_raise(rb_eArgError,
|
|
268
|
+
"%"PRIsVALUE" does not fit into image of %"PRIsVALUE,
|
|
269
|
+
rb_inspect(vx), rb_inspect(wrap(size))
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
wxPoint vpoint(unwrap<wxPoint>(vx));
|
|
274
|
+
set_at_pos(vpoint.x, vpoint.y, _self, vy);
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
set_at_pos(NUM2UINT(vx), NUM2UINT(vy), _self, value);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return NIL_P(value) ? value : vy;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/*
|
|
285
|
+
* call-seq:
|
|
286
|
+
* image.resize(size, pos [, color]) -> WX::Image
|
|
287
|
+
* image.resize(rect [, color]) -> WX::Image
|
|
288
|
+
*
|
|
289
|
+
* returns a new resized image, if color is given use this one to fill new space
|
|
290
|
+
* ===Arguments
|
|
291
|
+
* * size WX::Size
|
|
292
|
+
* * pos WX::Point
|
|
293
|
+
* * rect WX::Rect
|
|
294
|
+
* * color WX::Color
|
|
295
|
+
* ===Return value
|
|
296
|
+
* WX::Image
|
|
297
|
+
*
|
|
298
|
+
* === Exceptions
|
|
299
|
+
* [ArgumentError]
|
|
300
|
+
* * size is invalid
|
|
301
|
+
*/
|
|
302
|
+
DLL_LOCAL VALUE _resize(int argc,VALUE *argv,VALUE self)
|
|
303
|
+
{
|
|
304
|
+
VALUE size, pos, color;
|
|
305
|
+
rb_scan_args(argc, argv, "12",&size,&pos, &color);
|
|
306
|
+
|
|
307
|
+
wxSize csize;
|
|
308
|
+
if(!check_negative_size(size,csize))
|
|
309
|
+
return Qnil;
|
|
310
|
+
|
|
311
|
+
wxPoint cpos;
|
|
312
|
+
|
|
313
|
+
if(is_wrapable<wxColor>(pos))
|
|
314
|
+
{
|
|
315
|
+
std::swap(color,pos);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if(NIL_P(pos) && is_wrapable<wxPoint>(size))
|
|
319
|
+
cpos = unwrap<wxPoint>(size);
|
|
320
|
+
else
|
|
321
|
+
cpos = unwrap<wxPoint>(pos);
|
|
322
|
+
|
|
323
|
+
if(NIL_P(color))
|
|
324
|
+
return wrap(_self->Size(csize, cpos));
|
|
325
|
+
else {
|
|
326
|
+
wxColor c(unwrap<wxColor>(size));
|
|
327
|
+
|
|
328
|
+
return wrap(_self->Size(csize, cpos, c.Red(), c.Green(), c.Blue()));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/*
|
|
333
|
+
* call-seq:
|
|
334
|
+
* image.resize!(size, pos [, color]) -> self
|
|
335
|
+
* image.resize!(rect [, color]) -> self
|
|
336
|
+
*
|
|
337
|
+
* returns this image resized, if color is given use this one to fill new space
|
|
338
|
+
* ===Arguments
|
|
339
|
+
* * size WX::Size
|
|
340
|
+
* * pos WX::Point
|
|
341
|
+
* * rect WX::Rect
|
|
342
|
+
* * color WX::Color
|
|
343
|
+
* ===Return value
|
|
344
|
+
* self
|
|
345
|
+
* === Exceptions
|
|
346
|
+
* [ArgumentError]
|
|
347
|
+
* * size is invalid
|
|
348
|
+
*/
|
|
349
|
+
DLL_LOCAL VALUE _resize_self(int argc,VALUE *argv,VALUE self)
|
|
350
|
+
{
|
|
351
|
+
VALUE size, pos, color;
|
|
352
|
+
rb_scan_args(argc, argv, "12",&size,&pos, &color);
|
|
353
|
+
|
|
354
|
+
wxSize csize;
|
|
355
|
+
if(!check_negative_size(size,csize))
|
|
356
|
+
return self;
|
|
357
|
+
|
|
358
|
+
wxPoint cpos;
|
|
359
|
+
|
|
360
|
+
if(is_wrapable<wxColor>(pos))
|
|
361
|
+
{
|
|
362
|
+
std::swap(color,pos);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if(NIL_P(pos) && is_wrapable<wxPoint>(size))
|
|
366
|
+
cpos = unwrap<wxPoint>(size);
|
|
367
|
+
else
|
|
368
|
+
cpos = unwrap<wxPoint>(pos);
|
|
369
|
+
|
|
370
|
+
if(NIL_P(color))
|
|
371
|
+
_self->Resize(csize, cpos);
|
|
372
|
+
else {
|
|
373
|
+
wxColor c(unwrap<wxColor>(size));
|
|
374
|
+
|
|
375
|
+
_self->Resize(csize, cpos, c.Red(), c.Green(), c.Blue());
|
|
376
|
+
}
|
|
377
|
+
return self;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
/*
|
|
382
|
+
* call-seq:
|
|
383
|
+
* image.scale(size) -> WX::Image
|
|
384
|
+
* image.scale(x_ratio, y_ratio) -> WX::Image
|
|
385
|
+
*
|
|
386
|
+
* returns a new scaled image
|
|
387
|
+
* ===Arguments
|
|
388
|
+
* * size WX::Size
|
|
389
|
+
* * x_ratio and y_ratio are Float
|
|
390
|
+
* ===Return value
|
|
391
|
+
* WX::Image
|
|
392
|
+
* === Exceptions
|
|
393
|
+
* [ArgumentError]
|
|
394
|
+
* * size is invalid or x_ratio or y_ratio is zero
|
|
395
|
+
*/
|
|
396
|
+
DLL_LOCAL VALUE _scale(int argc,VALUE *argv,VALUE self)
|
|
397
|
+
{
|
|
398
|
+
VALUE x_scale, y_scale;
|
|
399
|
+
rb_scan_args(argc, argv, "11",&x_scale,&y_scale);
|
|
400
|
+
|
|
401
|
+
if(NIL_P(y_scale))
|
|
402
|
+
{
|
|
403
|
+
wxSize size;
|
|
404
|
+
if(!check_negative_size(x_scale,size))
|
|
405
|
+
return Qnil;
|
|
406
|
+
|
|
407
|
+
return wrap(_self->Scale(size.GetWidth(),size.GetHeight()));
|
|
408
|
+
}else {
|
|
409
|
+
|
|
410
|
+
double x,y;
|
|
411
|
+
x = NUM2DBL(x_scale);
|
|
412
|
+
y = NUM2DBL(y_scale);
|
|
413
|
+
|
|
414
|
+
if(x == 0 || y == 0)
|
|
415
|
+
{
|
|
416
|
+
if(!check_negative_size(x, y))
|
|
417
|
+
return Qnil;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
wxImage result(*_self);
|
|
421
|
+
|
|
422
|
+
if(x < 0)
|
|
423
|
+
{
|
|
424
|
+
x *= -1;
|
|
425
|
+
result = result.Mirror(false);
|
|
426
|
+
}
|
|
427
|
+
if(y < 0)
|
|
428
|
+
{
|
|
429
|
+
y *= -1;
|
|
430
|
+
result = result.Mirror();
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
result.Rescale(result.GetWidth() * x,result.GetHeight() * y);
|
|
434
|
+
return wrap(result);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
/*
|
|
440
|
+
* call-seq:
|
|
441
|
+
* image.scale!(size) -> self
|
|
442
|
+
* image.scale!(x_ratio, y_ratio) -> self
|
|
443
|
+
*
|
|
444
|
+
* scaled this image, return self
|
|
445
|
+
* ===Arguments
|
|
446
|
+
* * size WX::Size
|
|
447
|
+
* * x_ratio and y_ratio are Float
|
|
448
|
+
* ===Return value
|
|
449
|
+
* self
|
|
450
|
+
* === Exceptions
|
|
451
|
+
* [ArgumentError]
|
|
452
|
+
* * size is invalid or x_ratio or y_ratio is zero
|
|
453
|
+
*/
|
|
454
|
+
DLL_LOCAL VALUE _scale_self(int argc,VALUE *argv,VALUE self)
|
|
455
|
+
{
|
|
456
|
+
VALUE x_scale, y_scale;
|
|
457
|
+
rb_scan_args(argc, argv, "11",&x_scale,&y_scale);
|
|
458
|
+
|
|
459
|
+
if(NIL_P(y_scale))
|
|
460
|
+
{
|
|
461
|
+
wxSize size;
|
|
462
|
+
if(check_negative_size(x_scale,size))
|
|
463
|
+
_self->Rescale(size.GetWidth(),size.GetHeight());
|
|
464
|
+
}else {
|
|
465
|
+
double x,y;
|
|
466
|
+
x = NUM2DBL(x_scale);
|
|
467
|
+
y = NUM2DBL(y_scale);
|
|
468
|
+
|
|
469
|
+
if(x == 0 || y == 0)
|
|
470
|
+
{
|
|
471
|
+
if(!check_negative_size(x, y))
|
|
472
|
+
return Qnil;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if(x < 0)
|
|
476
|
+
{
|
|
477
|
+
x *= -1;
|
|
478
|
+
*_self = _self->Mirror(false);
|
|
479
|
+
}
|
|
480
|
+
if(y < 0)
|
|
481
|
+
{
|
|
482
|
+
y *= -1;
|
|
483
|
+
*_self = _self->Mirror();
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
_self->Rescale(_self->GetWidth() * x,_self->GetHeight() * y);
|
|
487
|
+
}
|
|
488
|
+
return self;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/*
|
|
492
|
+
* call-seq:
|
|
493
|
+
* image.replace_color(color1, color2) -> WX::Image
|
|
494
|
+
*
|
|
495
|
+
* replaces color1 with color2, return new image
|
|
496
|
+
* ===Arguments
|
|
497
|
+
* * color1 and color2 are WX::Color
|
|
498
|
+
* ===Return value
|
|
499
|
+
* WX::Image
|
|
500
|
+
*/
|
|
501
|
+
DLL_LOCAL VALUE _replace_color(VALUE self, VALUE color1, VALUE color2)
|
|
502
|
+
{
|
|
503
|
+
wxColor c1(unwrap<wxColor>(color1));
|
|
504
|
+
wxColor c2(unwrap<wxColor>(color2));
|
|
505
|
+
wxImage result(*_self);
|
|
506
|
+
result.Replace(c1.Red(),c1.Green(),c1.Blue(),c2.Red(),c2.Green(),c2.Blue());
|
|
507
|
+
return wrap(result);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
/*
|
|
512
|
+
* call-seq:
|
|
513
|
+
* image.replace_color!(color1, color2) -> self
|
|
514
|
+
*
|
|
515
|
+
* replaces color1 with color2, return self
|
|
516
|
+
* ===Arguments
|
|
517
|
+
* * color1 and color2 are WX::Color
|
|
518
|
+
* ===Return value
|
|
519
|
+
* self
|
|
520
|
+
*/
|
|
521
|
+
DLL_LOCAL VALUE _replace_color_self(VALUE self, VALUE color1, VALUE color2)
|
|
522
|
+
{
|
|
523
|
+
wxColor c1(unwrap<wxColor>(color1));
|
|
524
|
+
wxColor c2(unwrap<wxColor>(color2));
|
|
525
|
+
_self->Replace(c1.Red(),c1.Green(),c1.Blue(),c2.Red(),c2.Green(),c2.Blue());
|
|
526
|
+
return self;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
/*
|
|
531
|
+
* call-seq:
|
|
532
|
+
* image.rotate_hue(angle) -> WX::Image
|
|
533
|
+
*
|
|
534
|
+
* rotates the hue, where -1.0 is -360 degrees and 1.0 is 360 degrees, return new image
|
|
535
|
+
* ===Arguments
|
|
536
|
+
* * angle is Float
|
|
537
|
+
* ===Return value
|
|
538
|
+
* WX::Image
|
|
539
|
+
* === Exceptions
|
|
540
|
+
* [RangeError]
|
|
541
|
+
* * angle is outside of -1..1
|
|
542
|
+
*/
|
|
543
|
+
DLL_LOCAL VALUE _rotate_hue(VALUE self, VALUE angle)
|
|
544
|
+
{
|
|
545
|
+
wxImage result(*_self);
|
|
546
|
+
double val = NUM2DBL(angle);
|
|
547
|
+
if(val >= -1.0 && val <= 1.0)
|
|
548
|
+
result.RotateHue(val);
|
|
549
|
+
else
|
|
550
|
+
rb_raise(rb_eRangeError,"%f is out of range (-1..1)", val);
|
|
551
|
+
return wrap(result);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/*
|
|
555
|
+
* call-seq:
|
|
556
|
+
* image.rotate_hue!(angle) -> self
|
|
557
|
+
*
|
|
558
|
+
* rotates the hue, where -1.0 is -360 degrees and 1.0 is 360 degrees, return self
|
|
559
|
+
* ===Arguments
|
|
560
|
+
* * angle is Float
|
|
561
|
+
* ===Return value
|
|
562
|
+
* self
|
|
563
|
+
* === Exceptions
|
|
564
|
+
* [RangeError]
|
|
565
|
+
* * angle is outside of -1..1
|
|
566
|
+
*/
|
|
567
|
+
DLL_LOCAL VALUE _rotate_hue_self(VALUE self, VALUE angle)
|
|
568
|
+
{
|
|
569
|
+
double val = NUM2DBL(angle);
|
|
570
|
+
if(val >= -1.0 && val <= 1.0)
|
|
571
|
+
_self->RotateHue(val);
|
|
572
|
+
else
|
|
573
|
+
rb_raise(rb_eRangeError,"%f is out of range (-1..1)", val);
|
|
574
|
+
|
|
575
|
+
return self;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
DLL_LOCAL VALUE _mal(VALUE self,VALUE obj)
|
|
579
|
+
{
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
wxImage *result = new wxImage(_self->GetWidth(),_self->GetHeight());
|
|
583
|
+
//result->SetData(_self->GetData(),true);
|
|
584
|
+
//result->SetAlpha(_self->GetAlpha());
|
|
585
|
+
result->Paste(*_self,0,0);
|
|
586
|
+
if(rb_obj_is_kind_of(obj,rb_cNumeric))
|
|
587
|
+
{
|
|
588
|
+
double d = NUM2DBL(obj);
|
|
589
|
+
for(int x = 0; x < result->GetWidth();++x)
|
|
590
|
+
for(int y = 0; y < result->GetHeight();++y)
|
|
591
|
+
{
|
|
592
|
+
unsigned char alpha;
|
|
593
|
+
if(result->HasAlpha())
|
|
594
|
+
alpha = result->GetAlpha(x,y);
|
|
595
|
+
else
|
|
596
|
+
{
|
|
597
|
+
result->InitAlpha();
|
|
598
|
+
alpha = wxALPHA_OPAQUE;
|
|
599
|
+
}
|
|
600
|
+
result->SetAlpha(x,y,d * alpha);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
}else
|
|
604
|
+
{
|
|
605
|
+
wxColor c(unwrap<wxColor>(obj));
|
|
606
|
+
for(int x = 0; x < result->GetWidth();++x)
|
|
607
|
+
for(int y = 0; y < result->GetHeight();++y)
|
|
608
|
+
{
|
|
609
|
+
unsigned char red,green,blue,alpha;
|
|
610
|
+
red = result->GetRed(x,y);
|
|
611
|
+
green = result->GetGreen(x,y);
|
|
612
|
+
blue = result->GetBlue(x,y);
|
|
613
|
+
|
|
614
|
+
if(result->HasAlpha())
|
|
615
|
+
alpha = result->GetAlpha(x,y);
|
|
616
|
+
else
|
|
617
|
+
alpha = wxALPHA_OPAQUE;
|
|
618
|
+
result->SetRGB(x,y,
|
|
619
|
+
red * c.Red() / 256,
|
|
620
|
+
green * c.Green() / 256,
|
|
621
|
+
blue * c.Blue() / 256);
|
|
622
|
+
result->SetAlpha(x,y,alpha * c.Alpha() / wxALPHA_OPAQUE);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
}
|
|
626
|
+
return wrap(result);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
DLL_LOCAL VALUE _getMask(VALUE self)
|
|
630
|
+
{
|
|
631
|
+
unsigned char r,g,b;
|
|
632
|
+
if(_self->GetOrFindMaskColour(&r,&g,&b))
|
|
633
|
+
return wrap(new wxColor(r,g,b));
|
|
634
|
+
else
|
|
635
|
+
return Qnil;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
DLL_LOCAL VALUE _setMask(VALUE self,VALUE val)
|
|
639
|
+
{
|
|
640
|
+
rb_check_frozen(self);
|
|
641
|
+
if(NIL_P(val))
|
|
642
|
+
_self->SetMask(false);
|
|
643
|
+
else
|
|
644
|
+
{
|
|
645
|
+
wxColor c(wrap<wxColor>(val));
|
|
646
|
+
_self->SetMaskColour(c.Red(),c.Green(),c.Blue());
|
|
647
|
+
}
|
|
648
|
+
return val;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
DLL_LOCAL VALUE _save(int argc,VALUE *argv,VALUE self)
|
|
653
|
+
{
|
|
654
|
+
VALUE name,mime;
|
|
655
|
+
rb_scan_args(argc, argv, "11",&name,&mime);
|
|
656
|
+
if(!_self->IsOk())
|
|
657
|
+
return Qfalse;
|
|
658
|
+
|
|
659
|
+
if(!check_file_saveable(unwrap<wxString>(name)))
|
|
660
|
+
return Qfalse;
|
|
661
|
+
|
|
662
|
+
wxFileName file(unwrap<wxString>(name));
|
|
663
|
+
file.MakeAbsolute(wxGetCwd());
|
|
664
|
+
|
|
665
|
+
bool result = false;
|
|
666
|
+
|
|
667
|
+
if(NIL_P(mime)){
|
|
668
|
+
result = _self->SaveFile(file.GetFullPath());
|
|
669
|
+
}else if(SYMBOL_P(mime) || FIXNUM_P(mime)){
|
|
670
|
+
// if(wxImage::FindHandler(unwrap<wxBitmapType>(mime)))
|
|
671
|
+
// result = _self->SaveFile(file.GetFullPath(),unwrap<wxBitmapType>(mime));
|
|
672
|
+
// else
|
|
673
|
+
// rb_raise(rb_eArgError,"%s type not known",rb_id2name(SYM2ID(mime)));
|
|
674
|
+
}else{
|
|
675
|
+
// if(wxImage::FindHandlerMime(unwrap<wxString>(mime)))
|
|
676
|
+
result = _self->SaveFile(file.GetFullPath(),unwrap<wxString>(mime));
|
|
677
|
+
// else
|
|
678
|
+
// rb_raise(rb_eArgError,"%s mime not known",unwrap<wxString>(mime).c_str().AsChar());
|
|
679
|
+
}
|
|
680
|
+
return wrap(result);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
DLL_LOCAL VALUE _draw(VALUE self)
|
|
686
|
+
{
|
|
687
|
+
wxDC *dc;
|
|
688
|
+
|
|
689
|
+
#if wxUSE_GRAPHICS_CONTEXT
|
|
690
|
+
dc = new wxGCDC(wxGraphicsContext::Create(*_self));
|
|
691
|
+
#else
|
|
692
|
+
wxBitmap bit(*_self);
|
|
693
|
+
wxMemoryDC *mdc = new wxMemoryDC;
|
|
694
|
+
mdc->SelectObject(bit);
|
|
695
|
+
dc = mdc;
|
|
696
|
+
#endif
|
|
697
|
+
rb_yield(wrap(dc));
|
|
698
|
+
|
|
699
|
+
#if !wxUSE_GRAPHICS_CONTEXT
|
|
700
|
+
(*_self) = bit.ConvertToImage();
|
|
701
|
+
mdc->SelectObject(wxNullBitmap);
|
|
702
|
+
#endif
|
|
703
|
+
//TODO add a way to delete the DCs again
|
|
704
|
+
return self;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
DLL_LOCAL VALUE _to_image(VALUE self)
|
|
709
|
+
{
|
|
710
|
+
return self;
|
|
711
|
+
}
|
|
712
|
+
DLL_LOCAL VALUE _to_bitmap(VALUE self)
|
|
713
|
+
{
|
|
714
|
+
return wrap(unwrap<wxBitmap*>(self));
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/*
|
|
718
|
+
*/
|
|
719
|
+
DLL_LOCAL VALUE _initialize_copy(VALUE self, VALUE other)
|
|
720
|
+
{
|
|
721
|
+
VALUE result = rb_call_super(1,&other);
|
|
722
|
+
_self->SetData(unwrap<wxImage*>(other)->GetData());
|
|
723
|
+
_self->SetAlpha(unwrap<wxImage*>(other)->GetAlpha());
|
|
724
|
+
_setMask(self,_getMask(other));
|
|
725
|
+
|
|
726
|
+
#if wxUSE_PALETTE
|
|
727
|
+
_setPalette(self,_getPalette(other));
|
|
728
|
+
#endif
|
|
729
|
+
return result;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
/*
|
|
734
|
+
* call-seq:
|
|
735
|
+
* marshal_dump -> Array
|
|
736
|
+
*
|
|
737
|
+
* Provides marshalling support for use by the Marshal library.
|
|
738
|
+
* ===Return value
|
|
739
|
+
* Array
|
|
740
|
+
*/
|
|
741
|
+
DLL_LOCAL VALUE _marshal_dump(VALUE self)
|
|
742
|
+
{
|
|
743
|
+
VALUE result = rb_ary_new();
|
|
744
|
+
|
|
745
|
+
rb_ary_push(result,_getHeight(self));
|
|
746
|
+
rb_ary_push(result,_getWidth(self));
|
|
747
|
+
rb_ary_push(result,_getData(self));
|
|
748
|
+
rb_ary_push(result,_getAlpha(self));
|
|
749
|
+
rb_ary_push(result,_getMask(self));
|
|
750
|
+
#if wxUSE_PALETTE
|
|
751
|
+
rb_ary_push(result,_getPalette(self));
|
|
752
|
+
#else
|
|
753
|
+
rb_ary_push(result,Qnil);
|
|
754
|
+
#endif
|
|
755
|
+
return result;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/*
|
|
759
|
+
* call-seq:
|
|
760
|
+
* marshal_load(array) -> self
|
|
761
|
+
*
|
|
762
|
+
* Provides marshalling support for use by the Marshal library.
|
|
763
|
+
*
|
|
764
|
+
*
|
|
765
|
+
*/
|
|
766
|
+
DLL_LOCAL VALUE _marshal_load(VALUE self,VALUE data)
|
|
767
|
+
{
|
|
768
|
+
VALUE tmp = RARRAY_AREF(data,3);
|
|
769
|
+
unsigned char* alpha = NULL;
|
|
770
|
+
if(!NIL_P(tmp))
|
|
771
|
+
alpha = (unsigned char*)StringValuePtr(tmp);
|
|
772
|
+
|
|
773
|
+
VALUE val = RARRAY_AREF(data,2);
|
|
774
|
+
_self->Create(
|
|
775
|
+
NUM2UINT(RARRAY_AREF(data,0)),NUM2UINT(RARRAY_AREF(data,1)),
|
|
776
|
+
(unsigned char*)StringValuePtr(val),alpha);
|
|
777
|
+
|
|
778
|
+
_setMask(self,RARRAY_AREF(data,4));
|
|
779
|
+
|
|
780
|
+
#if wxUSE_PALETTE
|
|
781
|
+
_setPalette(self,RARRAY_AREF(data,5));
|
|
782
|
+
#endif
|
|
783
|
+
|
|
784
|
+
return self;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
#endif
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
/* Document-attr: width
|
|
794
|
+
* returns the width of the Image. Integer
|
|
795
|
+
*/
|
|
796
|
+
/* Document-attr: height
|
|
797
|
+
* returns the height of the Image. Integer
|
|
798
|
+
*/
|
|
799
|
+
/* Document-attr: size
|
|
800
|
+
* returns the size of the Image. WX::Size
|
|
801
|
+
*/
|
|
802
|
+
|
|
803
|
+
/* Document-attr: data
|
|
804
|
+
* returns the data of the Image. String
|
|
805
|
+
*/
|
|
806
|
+
/* Document-attr: alpha
|
|
807
|
+
* returns the alpha of the Image. String
|
|
808
|
+
*/
|
|
809
|
+
|
|
810
|
+
/* Document-attr: mask
|
|
811
|
+
* returns the mask color of the Image. WX::Color
|
|
812
|
+
*/
|
|
813
|
+
/* Document-attr: palette
|
|
814
|
+
* returns the color palette of the Image. WX::Palette
|
|
815
|
+
*/
|
|
816
|
+
|
|
817
|
+
DLL_LOCAL void Init_WXImage(VALUE rb_mWX)
|
|
818
|
+
{
|
|
819
|
+
#if 0
|
|
820
|
+
rb_define_attr(rb_cWXImage,"width",1,0);
|
|
821
|
+
rb_define_attr(rb_cWXImage,"height",1,0);
|
|
822
|
+
rb_define_attr(rb_cWXImage,"size",1,0);
|
|
823
|
+
rb_define_attr(rb_cWXImage,"data",1,0);
|
|
824
|
+
rb_define_attr(rb_cWXImage,"alpha",1,0);
|
|
825
|
+
|
|
826
|
+
rb_define_attr(rb_cWXImage,"mask",1,1);
|
|
827
|
+
rb_define_attr(rb_cWXImage,"palette",1,1);
|
|
828
|
+
#endif
|
|
829
|
+
|
|
830
|
+
#if wxUSE_IMAGE
|
|
831
|
+
|
|
832
|
+
wxInitAllImageHandlers();
|
|
833
|
+
|
|
834
|
+
using namespace RubyWX::Image;
|
|
835
|
+
rb_cWXImage = rb_define_class_under(rb_mWX,"Image",rb_cObject);
|
|
836
|
+
rb_define_alloc_func(rb_cWXImage,_alloc);
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
rb_define_method(rb_cWXImage,"initialize",RUBY_METHOD_FUNC(_initialize),-1);
|
|
840
|
+
rb_define_private_method(rb_cWXImage,"initialize_copy",RUBY_METHOD_FUNC(_initialize_copy),1);
|
|
841
|
+
|
|
842
|
+
rb_define_attr_method(rb_cWXImage,"height",_getHeight,NULL);
|
|
843
|
+
rb_define_attr_method(rb_cWXImage,"width",_getWidth,NULL);
|
|
844
|
+
rb_define_attr_method(rb_cWXImage,"size",_getSize,NULL);
|
|
845
|
+
rb_define_attr_method(rb_cWXImage,"data",_getData,NULL);
|
|
846
|
+
rb_define_attr_method(rb_cWXImage,"alpha",_getAlpha,NULL);
|
|
847
|
+
|
|
848
|
+
rb_define_method(rb_cWXImage,"to_image",RUBY_METHOD_FUNC(_to_image),0);
|
|
849
|
+
rb_define_method(rb_cWXImage,"to_bitmap",RUBY_METHOD_FUNC(_to_bitmap),0);
|
|
850
|
+
|
|
851
|
+
rb_define_method(rb_cWXImage,"marshal_dump",RUBY_METHOD_FUNC(_marshal_dump),0);
|
|
852
|
+
rb_define_method(rb_cWXImage,"marshal_load",RUBY_METHOD_FUNC(_marshal_load),1);
|
|
853
|
+
|
|
854
|
+
rb_define_attr_method(rb_cWXImage,"mask",_getMask,_setMask);
|
|
855
|
+
#if wxUSE_PALETTE
|
|
856
|
+
rb_define_attr_method(rb_cWXImage,"palette",_getPalette,_setPalette);
|
|
857
|
+
#endif
|
|
858
|
+
|
|
859
|
+
rb_define_method(rb_cWXImage,"*",RUBY_METHOD_FUNC(_mal),1);
|
|
860
|
+
|
|
861
|
+
rb_define_method(rb_cWXImage,"scale",RUBY_METHOD_FUNC(_scale),-1);
|
|
862
|
+
rb_define_method(rb_cWXImage,"scale!",RUBY_METHOD_FUNC(_scale_self),-1);
|
|
863
|
+
|
|
864
|
+
rb_define_method(rb_cWXImage,"resize",RUBY_METHOD_FUNC(_resize),-1);
|
|
865
|
+
rb_define_method(rb_cWXImage,"resize!",RUBY_METHOD_FUNC(_resize_self),-1);
|
|
866
|
+
|
|
867
|
+
rb_define_method(rb_cWXImage,"replace_color",RUBY_METHOD_FUNC(_replace_color),2);
|
|
868
|
+
rb_define_method(rb_cWXImage,"replace_color!",RUBY_METHOD_FUNC(_replace_color_self),2);
|
|
869
|
+
|
|
870
|
+
rb_define_method(rb_cWXImage,"rotate_hue",RUBY_METHOD_FUNC(_rotate_hue),1);
|
|
871
|
+
rb_define_method(rb_cWXImage,"rotate_hue!",RUBY_METHOD_FUNC(_rotate_hue_self),1);
|
|
872
|
+
|
|
873
|
+
rb_define_method(rb_cWXImage,"[]",RUBY_METHOD_FUNC(_get),-1);
|
|
874
|
+
rb_define_method(rb_cWXImage,"[]=",RUBY_METHOD_FUNC(_set),-1);
|
|
875
|
+
|
|
876
|
+
rb_define_method(rb_cWXImage,"load",RUBY_METHOD_FUNC(_load),-1);
|
|
877
|
+
rb_define_method(rb_cWXImage,"save",RUBY_METHOD_FUNC(_save),-1);
|
|
878
|
+
|
|
879
|
+
registerInfo<wxImage>(rb_cWXImage, true);
|
|
880
|
+
#endif
|
|
881
|
+
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
|