PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/ucblogo-6.0/wxTurtleGraphics.h

#
C Header | 261 lines | 198 code | 45 blank | 18 comment | 0 complexity | 473226003ad69e0f0e5cd17a8c0c73a0 MD5 | raw file
Possible License(s): GPL-2.0
  1. #include <wx/wx.h>
  2. #include <wx/colordlg.h>
  3. #include <wx/image.h>
  4. #include <wx/artprov.h>
  5. #include <vector>
  6. #include "LogoFrame.h"
  7. #include "logo.h"
  8. #include "wxTerminal.h"
  9. #include <wx/colordlg.h>
  10. #include <wx/image.h>
  11. #include <wx/artprov.h>
  12. #include "wxGlobals.h"
  13. // ----------------------------------------------------------------------------
  14. // structs
  15. // ----------------------------------------------------------------------------
  16. struct line {
  17. short int x1;
  18. short int y1;
  19. short int x2;
  20. short int y2;
  21. short int pw;
  22. unsigned char color;
  23. unsigned char pm;
  24. int vis;
  25. };
  26. typedef struct {
  27. int color;
  28. int xpos;
  29. int ypos;
  30. int vis;
  31. int pw;
  32. int ph;
  33. int pen_mode;
  34. } pen_info;
  35. // ----------------------------------------------------------------------------
  36. // constants
  37. // ----------------------------------------------------------------------------
  38. // what do we show on screen (there are too many shapes to put them all on
  39. // screen simultaneously)
  40. enum ScreenToShow
  41. {
  42. Show_Default,
  43. Show_Text,
  44. Show_Lines,
  45. Show_Brushes,
  46. Show_Polygons,
  47. Show_Mask,
  48. Show_Ops,
  49. Show_Regions,
  50. Show_Circles
  51. };
  52. enum messageEnum {
  53. PREPARE = 0,
  54. SPLITSCREEN,
  55. FULLSCREEN,
  56. TEXTSCREEN,
  57. DRAWLINE,
  58. EDITCALL,
  59. CLEARSCREEN,
  60. SAVEPEN,
  61. RESTOREPEN,
  62. KILLAPPLICATION,
  63. SETPENCOLOR,
  64. ADDLINE,
  65. SETPENWIDTH,
  66. GETPALETTE,
  67. FLOODFILL,
  68. TOPRINTER,
  69. GETMOUSECOORDS,
  70. GETMOUSEDOWN,
  71. SETINFO,
  72. GETINFO,
  73. DRAWLABEL,
  74. CATCHUP,
  75. PRINTPICT,
  76. PRINTPREVIEWPICT,
  77. PRINTTEXT,
  78. PRINTPREVIEWTEXT
  79. };
  80. #define PEN_REVERSE 0
  81. #define PEN_ERASE 1
  82. #define PEN_DOWN 2
  83. #define NUMCOLORS 512
  84. #define NUMINITCOLORS 16
  85. // ----------------------------------------------------------------------------
  86. // Classes
  87. // ----------------------------------------------------------------------------
  88. class TurtleCanvas;
  89. // This frame will contain the TurtleCanvas
  90. class TurtleFrame : public wxFrame
  91. {
  92. public:
  93. TurtleFrame( wxFrame * parent, const wxString& title, const wxPoint& pos, const wxSize& size);
  94. // event handlers (these functions should _not_ be virtual)
  95. void OnQuit(wxCommandEvent& event);
  96. void OnShow(wxCommandEvent &event);
  97. static int
  98. back_ground,
  99. screen_height,
  100. screen_width,
  101. in_graphics_mode,
  102. in_splitscreen;
  103. static pen_info xgr_pen;
  104. int m_backgroundMode;
  105. int m_textureBackground;
  106. int m_mapMode;
  107. double m_xUserScale;
  108. double m_yUserScale;
  109. int m_xLogicalOrigin;
  110. int m_yLogicalOrigin;
  111. bool m_xAxisReversed,
  112. m_yAxisReversed;
  113. wxColour m_colourForeground, // these are _text_ colours
  114. m_colourBackground;
  115. wxBrush m_backgroundBrush;
  116. TurtleCanvas *m_canvas;
  117. TurtleCanvas * GetCanvas ();
  118. private:
  119. // any class wishing to process wxWindows events must use this macro
  120. DECLARE_EVENT_TABLE()
  121. };
  122. struct mypoint {
  123. int x,y;
  124. };
  125. // define a scrollable canvas for drawing onto
  126. class TurtleCanvas: public wxWindow
  127. {
  128. public:
  129. TurtleCanvas( wxFrame *parent );
  130. virtual ~TurtleCanvas();
  131. wxFrame *m_owner;
  132. wxPaintDC * dc;
  133. static void FinishedEvent();
  134. static void WaitForEvent();
  135. void OnPaint(wxPaintEvent &event);
  136. void OnSize(wxSizeEvent &event);
  137. void OnDraw(wxDC &dc);
  138. bool SetFont(const wxFont &f);
  139. void Show(ScreenToShow show) { m_show = show; Refresh(); }
  140. void internalPrepare();
  141. void TurtlePrintPreview(wxCommandEvent& event);
  142. void PrintTurtleWindow(wxCommandEvent& event);
  143. void SetOwner (wxFrame * frame);
  144. void SetDC (wxPaintDC * dc);
  145. void drawLine(wxCommandEvent & e);
  146. void editCall();
  147. void logoHandle ( wxCommandEvent & e);
  148. void exitApplication();
  149. void OnFocus (wxFocusEvent & event);
  150. void LoseFocus (wxFocusEvent & event);
  151. void OnLeftDown(wxMouseEvent& event) ;
  152. void OnLeftUp(wxMouseEvent& event);
  153. void OnMiddleDown(wxMouseEvent& event) ;
  154. void OnMiddleUp(wxMouseEvent& event);
  155. void OnRightDown(wxMouseEvent& event) ;
  156. void OnRightUp(wxMouseEvent& event);
  157. void OnMouseMove(wxMouseEvent& event) ;
  158. void OnChar(wxKeyEvent& event);
  159. static void setInfo(int type, int val);
  160. static int getInfo(int type);
  161. void OnTimer (wxTimerEvent& event);
  162. void OnEraseBackGround(wxEraseEvent& event) ;
  163. void OnPageSetup(wxCommandEvent& event);
  164. static void drawOneLine(struct line *, wxDC *);
  165. static void realFloodFill(int, wxDC *);
  166. static void realdoFilled(int fillcolor, int count,
  167. struct mypoint *points, wxDC *dc);
  168. static void realDrawLabel(char *, wxDC *);
  169. static void realClearScreen(wxDC *);
  170. void PaintBackground(wxDC& dc) ;
  171. wxFrame * GetOwner();
  172. wxDC * GetDC();
  173. static int mousePosition_x;
  174. static int mousePosition_y;
  175. static int clickPosition_x;
  176. static int clickPosition_y;
  177. static int mouse_down_left;
  178. static int mouse_down_middle;
  179. static int mouse_down_right;
  180. static int mouse_down_last;
  181. static wxColour colors[NUMCOLORS+SPECIAL_COLORS];
  182. private:
  183. wxBitmap
  184. *m_bitmap;
  185. int resized;
  186. ScreenToShow m_show;
  187. wxBitmap m_smile_bmp;
  188. wxIcon m_std_icon;
  189. bool m_clip;
  190. wxTimer * m_timer;
  191. DECLARE_EVENT_TABLE()
  192. };
  193. // ----------------------------------------------------------------------------
  194. // Accessed by interpreter
  195. // ----------------------------------------------------------------------------
  196. extern "C" void nop();
  197. extern "C" void set_palette(int, unsigned int, unsigned int, unsigned int);
  198. extern "C" void get_palette(int, unsigned int*, unsigned int*, unsigned int*);
  199. extern "C" void save_pen(pen_info *p);
  200. extern "C" void restore_pen(pen_info *p);
  201. extern "C" void set_pen_patter();
  202. extern "C" void logofill();
  203. extern "C" void wx_clear();
  204. extern "C" NODE lclearscreen(NODE *);
  205. extern "C" void wxDrawLine(int x1, int y1, int x2, int y2, int vis);
  206. extern "C" void wxSplitScreen();
  207. extern "C" void wxFullScreen();
  208. extern "C" void wxTextScreen();
  209. extern "C" void wxPrepare();
  210. extern "C" int wxEditFile(char * f);
  211. extern "C" int wxGetMouseX();
  212. extern "C" int wxGetMouseY();
  213. extern "C" int wxGetButton();
  214. extern "C" void redraw_graphics();
  215. extern "C" void wxSetInfo(int type, int val);
  216. extern "C" int wxGetInfo(int type);