pseudodc.i 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 SetBrush(const wxBrush&);
  51. void SetPen(const wxPen&);
  52. void SetIdBounds(int, wxRect&);
  53. void DrawLine(const wxPoint&, const wxPoint&);
  54. void SetFont(const wxFont&);
  55. void SetTextForeground(const wxColour&);
  56. %extend {
  57. void DrawToDC(void *dc) {
  58. self->DrawToDC((wxDC *) dc);
  59. }
  60. void DrawToDCClipped(void *dc, const wxRect& rect) {
  61. self->DrawToDCClipped((wxDC *) dc, rect);
  62. }
  63. wxRect GetIdBounds(int id) {
  64. wxRect rect;
  65. self->GetIdBounds(id, rect);
  66. return rect;
  67. }
  68. void TranslateId(int id, float dx, float dy) {
  69. self->TranslateId(id, (wxCoord) dx, (wxCoord) dy);
  70. }
  71. PyObject *FindObjects(float x, float y, int radius) {
  72. return self->FindObjects((wxCoord) x, (wxCoord) y,
  73. (wxCoord) radius, *wxWHITE);
  74. }
  75. void DrawRectangleRect(const wxRect& rect) {
  76. return self->DrawRectangle(rect);
  77. }
  78. void DrawText(const wxString& text, float x, float y) {
  79. return self->DrawText(text, (wxCoord) x, (wxCoord) y);
  80. }
  81. void DrawRotatedText(const wxString& text, float x, float y, double angle) {
  82. return self->DrawRotatedText(text, (wxCoord) x, (wxCoord) y, angle);
  83. }
  84. void DrawBitmap(const wxBitmap& bitmap, float x, float y, bool useMask) {
  85. return self->DrawBitmap(bitmap, (wxCoord) x, (wxCoord) y, useMask);
  86. }
  87. void DrawLinePoint(const wxPoint& p1, const wxPoint& p2) {
  88. return self->DrawLine(p1, p2);
  89. }
  90. }
  91. };