Main Page | Namespaces | Classes | Compounds | Files | Compound Members | Related Canvas.h00001 // 00002 // SYNTOPIA. See http://Syntopia.sourceforge.net for details and documentation. 00003 // 00004 // Author of this file: Mikael Hvidtfeldt Christensen (mikaelc@users.sourceforge.net) 00005 // 00006 00007 00008 #ifndef __Canvas 00009 #define __Canvas 00010 00011 #include <windows.h> 00012 #include <string> 00013 #include "WinForm.h" 00014 #include "GUIControl.h" 00015 00016 namespace GUIToolkit { 00017 00018 00020 /* 00021 * This class creates a double buffered canvas. 00022 * Method are included to manipulate pixels and draw simple objects like lines and circles. 00023 */ 00024 class MCanvas : public Component { 00025 00026 public: 00027 00029 MCanvas(); 00030 00032 ~MCanvas(); 00033 00035 void PutInWinForm(WinForm * WF, int x0, int y0, int x1, int y1); 00036 00040 void HandleEvents(event e); 00041 00043 HWND getHWND() {return hLabel;} 00044 00046 void draw() ; 00048 void doDraw() ; 00049 00051 void clear(); 00052 00053 int getWidth() {return _x1;} 00054 int getHeight() {return _y1;} 00055 00057 void putPixel(int x,int y,int r, int g, int b); 00058 00060 void setColor(int r,int g,int b); 00061 00063 void setColor(COLORREF c); 00064 00066 void deleteColor(); 00067 00069 void setBrush(int r,int g,int b); 00070 00072 void setBrush(COLORREF c); 00073 00075 void deleteBrush(); 00076 00078 void print(int x,int y,std::string s); 00079 00081 void line(int x,int y,int x2, int y2); 00082 00084 void circle(int x,int y,int radius); 00085 00087 void rectangle(int x,int y,int x2, int y2); 00088 00090 void setBGColor(int r, int g, int b); 00091 00093 void setBGColor(COLORREF c); 00094 00096 void setTextColor(int r, int g, int b); 00097 00099 void setTextColor(COLORREF c); 00100 00101 private: 00102 std::string myLabel; 00103 HWND hLabel; 00104 WNDCLASSEX wc; // Used by constructor 00105 HDC OffScreenHdc; 00106 HBITMAP OffScreen; 00107 int _x0, _y0, _x1, _y1; 00108 HPEN myPen, oldPen; 00109 HBRUSH myBrush, oldBrush; 00110 char g_szClassName[80]; 00111 }; 00112 00113 }; 00114 00115 #endif Docs made by Doxygen. Email: Mikael Christensen |