00001
00014 #ifndef _SHAPE_H_
00015 #define _SHAPE_H_
00016
00017 #include "../jnilib.h"
00018 #include "color.h"
00019
00020 #ifdef __cplusplus
00021 extern "C" {
00022 #endif
00023
00025 #define CLS_SHAPE "at/fhv/sgr/graphiclib/draw/DrawableGeneralPath"
00026
00027 struct Shape_;
00028
00029 struct ShapeCPP_;
00030
00031 #ifdef __cplusplus
00032 typedef ShapeCPP_ Shape;
00033 #define createShape createShapeCPP
00034 #define deleteShape deleteShapeCPP
00035 #else
00036 typedef struct Shape_ Shape;
00037 #define createShape createShapeC
00038 #define deleteShape deleteShapeC
00039 #endif
00040
00044 typedef struct ShapeData {
00045 jclass clsshape;
00046 jobject shape;
00047 jmethodID msetColor;
00048 jmethodID mgetColor;
00049 jmethodID misFilled;
00050 jmethodID msetFilled;
00051 jmethodID mclosePath;
00052 jmethodID mmoveTo;
00053 jmethodID mlineTo;
00054 jmethodID mcurveTo;
00055 jmethodID mquadTo;
00056 } ShapeData;
00057
00061 typedef struct Shape_ {
00062 ShapeData shape;
00063 void (*setColor)(Shape* shape, const Color* c);
00064 Color (*getColor)(Shape* shape);
00065 jboolean (*isFilled)(Shape* shape);
00066 void (*setFilled)(Shape* shape, jboolean filled);
00067 void (*closePath)(Shape* shape);
00068 void (*moveTo)(Shape* shape, jfloat x, jfloat y);
00069 void (*lineTo)(Shape* shape, jfloat x, jfloat y);
00070 void (*curveTo)(Shape* shape, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3);
00071 void (*quadTo)(Shape* shape, jfloat x1, jfloat y1, jfloat x2, jfloat y2);
00072 } Shape_;
00073
00077 typedef struct ShapeCPP_ {
00078 ShapeData shape;
00079 struct Shape_ *functions;
00080
00081 #ifdef __cplusplus
00082 void setColor(const Color* c) {
00083 functions->setColor(this, c);
00084 }
00085
00086 Color getColor() {
00087 return functions->getColor(this);
00088 }
00089
00090 jboolean isFilled() {
00091 return functions->isFilled(this);
00092 }
00093
00094 void setFilled(jboolean filled) {
00095 functions->setFilled(this, filled);
00096 }
00097
00098 void closePath() {
00099 functions->closePath(this);
00100 }
00101
00102 void moveTo(jfloat x, jfloat y) {
00103 functions->moveTo(this, x, y);
00104 }
00105
00106 void lineTo(jfloat x, jfloat y) {
00107 functions->lineTo(this, x, y);
00108 }
00109
00110 void curveTo(jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) {
00111 functions->curveTo(this, x1, y1, x2, y2, x3, y3);
00112 }
00113
00114 void quadTo(jfloat x1, jfloat y1, jfloat x2, jfloat y2) {
00115 functions->quadTo(this, x1, y1, x2, y2);
00116 }
00117 #endif
00118 } ShapeCPP_;
00119
00120
00121 void createShapeC(Shape_* shape);
00122 void createShapeCPP(ShapeCPP_* shape);
00123 void deleteShapeC(Shape_* shape);
00124 void deleteShapeCPP(ShapeCPP_* shape);
00125
00126 #ifdef __cplusplus
00127 }
00128 #endif
00129
00130 #endif
00131
00132