pseudodc.i 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. %{
  2. #include <wx/wxPython/wxPython.h>
  3. #include <wx/wxPython/pyclasses.h>
  4. #include <wx/dcbuffer.h>
  5. %}
  6. %{
  7. #include "pseudodc.h"
  8. %}
  9. %rename(PseudoDC) gwxPseudoDC;
  10. %typemap(in) wxString& (bool temp=false) {
  11. $1 = wxString_in_helper($input);
  12. if ($1 == NULL) SWIG_fail;
  13. temp = true;
  14. }
  15. %typemap(freearg) wxString& {
  16. if (temp$argnum)
  17. delete $1;
  18. }
  19. %apply wxString& { wxString* };
  20. %typemap(in) wxRect& (wxRect temp) {
  21. $1 = &temp;
  22. if ( ! wxRect_helper($input, &$1)) SWIG_fail;
  23. }
  24. %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxRect& {
  25. $1 = wxPySimple_typecheck($input, wxT("wxRect"), 4);
  26. }
  27. %apply wxRect& { wxRect* };
  28. %typemap(out) wxRect {
  29. $result = Py_BuildValue("[iiii]", $1.x, $1.y, $1.width, $1.height);
  30. }
  31. %typemap(out) wxArrayInt& {
  32. $result = wxArrayInt2PyList_helper(*$1);
  33. }
  34. %typemap(out) wxArrayInt {
  35. $result = wxArrayInt2PyList_helper($1);
  36. }
  37. class gwxPseudoDC
  38. {
  39. public:
  40. gwxPseudoDC();
  41. ~gwxPseudoDC();
  42. void Clear();
  43. void ClearId(int);
  44. void RemoveAll();
  45. void RemoveId(int);
  46. void BeginDrawing();
  47. void EndDrawing();
  48. void SetBackground(const wxBrush&);
  49. void SetId(int);
  50. void DrawBitmap(const wxBitmap&, const wxPoint&,
  51. bool);
  52. void SetBrush(const wxBrush&);
  53. void SetPen(const wxPen&);
  54. void SetIdBounds(int, wxRect&);
  55. void DrawLine(const wxPoint&, const wxPoint&);
  56. void SetFont(const wxFont&);
  57. void SetTextForeground(const wxColour&);
  58. %extend {
  59. void DrawToDC(void *dc) {
  60. self->DrawToDC((wxDC *) dc);
  61. }
  62. void DrawToDCClipped(void *dc, const wxRect& rect) {
  63. self->DrawToDCClipped((wxDC *) dc, rect);
  64. }
  65. wxRect GetIdBounds(int id) {
  66. wxRect rect;
  67. self->GetIdBounds(id, rect);
  68. return rect;
  69. }
  70. void TranslateId(int id, float dx, float dy) {
  71. self->TranslateId(id, (wxCoord) dx, (wxCoord) dy);
  72. }
  73. PyObject *FindObjects(float x, float y, int radius) {
  74. return self->FindObjects((wxCoord) x, (wxCoord) y,
  75. (wxCoord) radius, *wxWHITE);
  76. }
  77. void DrawRectangleRect(const wxRect& rect) {
  78. return self->DrawRectangle(rect);
  79. }
  80. void DrawText(const wxString& text, float x, float y) {
  81. return self->DrawText(text, (wxCoord) x, (wxCoord) y);
  82. }
  83. void DrawRotatedText(const wxString& text, float x, float y, double angle) {
  84. return self->DrawRotatedText(text, (wxCoord) x, (wxCoord) y, angle);
  85. }
  86. }
  87. };