QSwingGraphics.h

00001 /*
00002  * @(#)QSwingGraphics.h  0.2.0 / 2007-09-11
00003  *
00004  * Copyright (c) 2007, ETF and contributors. All rights reserved.
00005  *
00006  * This software is licensed under the LGPL, version 2.1, license.
00007  * A copy of the license is included in the file LICENSE-LGPL.txt.
00008  */
00009 #ifndef QSWINGGRAPHICS_H
00010 #define QSWINGGRAPHICS_H
00011 
00012 #include "JavaQxQSwing.h"
00013 
00014 /*^**************************************************************************^*/
00015 /*- QSwingGraphics Class.                                                    -*/
00016 /*^**************************************************************************^*/
00017 
00024 class JAVAQX_EXPORT QSwingGraphics : public QPainter
00025 {
00026 public:
00027   QSwingGraphics(QPaintDevice *device);
00028   QSwingGraphics(QPaintDevice *device, jint x, jint y, jint width, jint height);
00029 public:
00030   jobject getColor();
00031   void setColor(jint argb);
00032   jobject getFont();
00033   void setFont(jobject font);
00034   void setLinearGradient(jint x1, jint y1, jint argb1, jint x2, jint y2,
00035                          jint argb2, jboolean cyclic);
00036   void setTextureGradient(QPixmap *image);
00037   void setBasicStroke(jfloat width, jint cap, jint join, jfloat miterLimit,
00038                       jfloatArray dash, jfloat dashPhase);
00039   void push();
00040   void pop();
00041   void drawImage(jbyteArray imageData, jint length, jint x, jint y);
00042   void fillRect(jint x, jint y, jint w, jint h);
00043   void fillOval(jint x, jint y, jint w, jint h);
00044 public:
00045   inline static bool canPaint(JNIEnv *env, jlong graphicsPointer);
00046 private:
00047   static const Qt::PenCapStyle PEN_CAP_STYLE[];
00048   static const Qt::PenJoinStyle PEN_JOIN_STYLE[];
00049 };
00050 
00051 /*^**************************************************************************^*/
00052 /*- QSwingGraphics :: Public Static Inline Member Function.                  -*/
00053 /*^**************************************************************************^*/
00054 
00063 inline bool QSwingGraphics::canPaint(JNIEnv *env, jlong graphicsPointer)
00064 {
00065   return (graphicsPointer && JNIQSwingWrapper::isQSwingThread(env));
00066 }
00067 
00068 /*^**************************************************************************^*/
00069 /*- Macro Definitions.                                                       -*/
00070 /*^**************************************************************************^*/
00071 
00072 #define qSwingGraphics (reinterpret_cast<QSwingGraphics *>(graphicsPointer))
00073 #define qPainterPath (reinterpret_cast<QPainterPath *>(painterPathPointer))
00074 #define qPaintDevice (reinterpret_cast<QPaintDevice *>(paintDevicePointer))
00075 
00076 #endif //QSWINGGRAPHICS_H
00077 
00078 /*^*****************************************************************************
00079   File History:
00080 
00081  - 2007-09-11 13:03:16 Slobodan
00082    Initial version
00083 
00084 *****************************************************************************^*/

Copyright © 2007 ETF and contributors. All Rights Reserved.