00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023
00024
00025 #ifndef CANVAS_H
00026 #define CANVAS_H
00027
00028 #include <PalmOS.h>
00029
00030 00031 00032 00033
00034 class Canvas
00035 {
00036 public:
00037 00038 00039 00040 00041 00042
00043 Canvas()
00044 {
00045 WinGetDisplayExtent(&width, &height);
00046
00047 displayBounds.topLeft.x = 0;
00048 displayBounds.topLeft.y = 0;
00049 displayBounds.extent.x = width;
00050 displayBounds.extent.y = height;
00051 }
00052
00053 00054 00055 00056
00057 virtual ~Canvas() {}00058 00059
00060 00061 00062 00063 00064 00065
00066 virtual void beginDraw(WinLockInitType initMode) = 0;
00067 00068 00069 00070 00071 00072
00073 virtual void endDraw(RectangleType *bounds) = 0;
00074 00075 00076 00077
00078 virtual void show() = 0; 00079 00080
00081 00082 00083 00084 00085 00086
00087 Coord getWidth() const
00088 {
00089 return width;
00090 }
00091
00092 00093 00094 00095
00096 Coord getHeight() const
00097 {
00098 return height;
00099 }00100 00101
00102
00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113
00114 static void uniteBounds(RectangleType *rect1Bound, RectangleType *rect2Bound, RectangleType *resultBound)
00115 {
00116 Coord rect1RightEdge = rect1Bound->topLeft.x + rect1Bound->extent.x;
00117 Coord rect2RightEdge = rect2Bound->topLeft.x + rect2Bound->extent.x;
00118
00119 if (rect1Bound->topLeft.x < rect2Bound->topLeft.x)
00120 resultBound->topLeft.x = rect1Bound->topLeft.x;
00121 else
00122 resultBound->topLeft.x = rect2Bound->topLeft.x;
00123
00124 if (rect1RightEdge > rect2RightEdge)
00125 resultBound->extent.x = rect1RightEdge - resultBound->topLeft.x;
00126 else
00127 resultBound->extent.x = rect2RightEdge - resultBound->topLeft.x;
00128
00129
00130 Coord rect1BottomEdge = rect1Bound->topLeft.y + rect1Bound->extent.y;
00131 Coord rect2BottomEdge = rect2Bound->topLeft.y + rect2Bound->extent.y;
00132
00133 if (rect1Bound->topLeft.y < rect2Bound->topLeft.y)
00134 resultBound->topLeft.y = rect1Bound->topLeft.y;
00135 else
00136 resultBound->topLeft.y = rect2Bound->topLeft.y;
00137
00138 if (rect1BottomEdge > rect2BottomEdge)
00139 resultBound->extent.y = rect1BottomEdge - resultBound->topLeft.y;
00140 else
00141 resultBound->extent.y = rect2BottomEdge - resultBound->topLeft.y;
00142 }00143 00144
00145 protected:
00146 RectangleType displayBounds;
00147
00148 private:
00149 Coord width;
00150 Coord height;
00151 };
00152
00153
00154 #endif