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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef CANVAS_H
00037 #define CANVAS_H
00038
00039 #include <PalmOS.h>
00040 #include "RazorSections.h"
00041
00042 #include "gfx/Geometry.h"
00043 #include "gfx/Color.h"
00044
00045
00046 namespace prvrazor
00047 {
00048 class Blitter;
00049 }
00050
00051 using namespace prvrazor;
00052
00053
00054 class Canvas;
00055
00056
00057 class BitmapArray
00058 {
00059 public:
00060 virtual ~BitmapArray() SEC_RAZOR_INIT = 0;
00061 virtual void draw(const Canvas *canvas, UInt16 index, Coord x, Coord y) const = 0;
00062
00063 Coord width;
00064 Coord height;
00065 UInt16 numBitmaps;
00066
00067 protected:
00068 BitmapArray(UInt16 numBitmaps) SEC_RAZOR_INIT;
00069 };
00070
00071
00072
00073 class SaveBufferArray
00074 {
00075 public:
00076 virtual ~SaveBufferArray() SEC_RAZOR_INIT = 0;
00077 virtual void save(const Canvas *canvas, UInt16 index, Coord x, Coord y) const = 0;
00078 virtual void restore(const Canvas *canvas, UInt16 index) const = 0;
00079
00080 Int16 width;
00081 Int16 height;
00082 UInt16 numBuffers;
00083
00084 protected:
00085 SaveBufferArray(UInt16 numBuffers, Coord width, Coord height) SEC_RAZOR_INIT;
00086 };
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 class Canvas
00101 {
00102 public:
00103
00104 enum CoordSystem {COORDS_STANDARD = 1, COORDS_NATIVE = 2};
00105
00106
00107
00108
00109
00110
00111 Canvas(Coord width, Coord height, CoordSystem coordSystem) SEC_RAZOR_INIT;
00112
00113
00114
00115
00116 virtual ~Canvas() SEC_RAZOR_INIT;
00117
00118
00119
00120
00121 virtual void setCoordSystem(CoordSystem coordSystem) SEC_RAZOR_INIT;
00122
00123
00124
00125
00126 const BitmapArray *prepareTransparentBitmaps(UInt16 numBitmaps, DmResID bitmapID, DmResID maskID) const SEC_RAZOR_INIT;
00127 const BitmapArray *prepareTransparentBitmap(DmResID bitmapID, DmResID maskID) const SEC_RAZOR_INIT;
00128 const BitmapArray *prepareSolidBitmaps(UInt16 numBitmaps, DmResID bitmapID) const SEC_RAZOR_INIT;
00129 const BitmapArray *prepareSolidBitmap(DmResID bitmapID) const SEC_RAZOR_INIT;
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 void drawBitmap(UInt16 index, const BitmapArray *bitmapArray, Coord x, Coord y) const SEC_RAZOR;
00140
00141
00142
00143
00144
00145
00146
00147
00148 void drawBitmap(const BitmapArray *bitmapArray, Coord x, Coord y) const SEC_RAZOR;
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 void drawText(Color textColor, Color bgColor, FontID font, const Char *chars, Int16 len, Coord x, Coord y) const SEC_RAZOR;
00162
00163 void fillRectangle(Color color, Coord topX, Coord topY, Coord bottomX, Coord bottomY) const SEC_RAZOR;
00164
00165 void drawPolygon(const xy *e, int edgeCount, const Color color) const SEC_RAZOR;
00166
00167
00168
00169
00170
00171 SaveBufferArray *prepareSaveBuffers(UInt16 numBuffers, Coord width, Coord height) const SEC_RAZOR_INIT;
00172 void saveBitmap(UInt16 index, SaveBufferArray *bufferArray, Coord x, Coord y) const SEC_RAZOR;
00173 void restoreBitmap(UInt16 index, SaveBufferArray *bufferArray) const SEC_RAZOR;
00174
00175
00176
00177
00178
00179
00180
00181
00182 virtual void setOSCanvas() const = 0;
00183
00184
00185
00186
00187
00188
00189 virtual Boolean setForegroundColor(const Color color) const = 0;
00190
00191
00192
00193
00194
00195
00196 virtual Boolean setBackgroundColor(const Color color) const = 0;
00197
00198
00199
00200
00201 Coord width;
00202 Coord height;
00203 Coord rows;
00204 Coord cols;
00205
00206 Int8 shiftFactor;
00207 CoordSystem coordSystem;
00208
00209
00210
00211
00212
00213 WinHandle drawWindow;
00214
00215
00216
00217
00218 BitmapType *_drawBitmap;
00219
00220
00221
00222
00223 void *drawBits;
00224
00225
00226
00227
00228 UInt16 rowBytes;
00229
00230
00231 protected:
00232
00233
00234
00235 Blitter *blitter;
00236
00237
00238 private:
00239 static int calcShiftFactor(UInt16 coordSystem);
00240 };
00241
00242
00243 #endif