00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef JQCOMPONENTBRIDGE_H
00010 #define JQCOMPONENTBRIDGE_H
00011
00012 #include "JavaQxQSwing.h"
00013
00014 #include "QObjectBridge.h"
00015 #include "QSwingUtilitiesBridge.h"
00016
00017
00018
00019
00020
00021 class JQContainerBridge;
00022
00029 class JAVAQX_EXPORT JQComponentBridge : public QObjectBridge
00030 {
00031 Q_OBJECT
00032 protected:
00033 JQComponentBridge(JNIEnv *env, jobject obj, QWidget *widget);
00034 JQComponentBridge(JNIEnv *env, jobject obj);
00035 private:
00036 friend class JQActionComponentBridge;
00037 JQComponentBridge(JNIEnv *env, jobject obj, QAction *action);
00038 protected:
00039 virtual ~JQComponentBridge();
00040 public slots:
00041 virtual void setVisible(JNIEnv *env, jboolean visible);
00042 virtual void showWindow(JNIEnv *env);
00043 virtual void setEnabled(JNIEnv *env, jboolean enabled);
00044 virtual void setFocusable(JNIEnv *env, jboolean focusable);
00045 virtual void requestFocus(JNIEnv *env);
00046 virtual void setLocation(JNIEnv *env, jint x, jint y);
00047 virtual jobject getPreferredSize(JNIEnv *env);
00048 virtual void setSize(JNIEnv *env, jint width, jint height);
00049 virtual void setMaximumSize(JNIEnv *env, jint width, jint height);
00050 virtual void setMinimumSize(JNIEnv *env, jint width, jint height);
00051 virtual void setFixedSize(JNIEnv *env, jint width, jint height);
00052 virtual void setBounds(JNIEnv *env, jint x, jint y, jint width, jint height);
00053 virtual jobject getBackground(JNIEnv *env, jclass colorClass);
00054 virtual void setBackground(JNIEnv *env, jint argb);
00055 virtual void setNullBackground(JNIEnv *env);
00056 virtual jobject getForeground(JNIEnv *env, jclass colorClass);
00057 virtual void setForeground(JNIEnv *env, jint argb);
00058 virtual void setNullForeground(JNIEnv *env);
00059 virtual void setOpaque(JNIEnv *env, jboolean opaque);
00060 virtual jobject getFont(JNIEnv *env, jclass fontClass);
00061 virtual void setFont(JNIEnv *env, jobject font);
00062 virtual void setStyleSheet(JNIEnv *env, jstring styleSheetText);
00063 virtual void setStyleSheetProperties(JNIEnv *env);
00064 virtual void removeStyleSheetProperties(JNIEnv *env);
00065 virtual jint getCursor(JNIEnv *env);
00066 virtual void setCursor(JNIEnv *env, jint type);
00067 virtual void repaint(JNIEnv *env);
00068 virtual void repaint(JNIEnv *env, jint x, jint y, jint width, jint height);
00069 virtual void update(JNIEnv *env);
00070 virtual void update(JNIEnv *env, jint x, jint y, jint width, jint height);
00071 virtual void setUpdatesEnabled(JNIEnv *env, jboolean enabled);
00072 virtual void polish(JNIEnv *env);
00073 virtual void setComponentOrientation(JNIEnv *env, jint orientation);
00074 virtual void setToolTipText(JNIEnv *env, jstring text);
00075 virtual void setStatusTipText(JNIEnv *env, jstring text);
00076 virtual void setWhatsThisText(JNIEnv *env, jstring text);
00077 virtual void setEnabledEvents(JNIEnv *env, jlong events);
00078 virtual void paintComponent(JNIEnv *env, jlong graphicsBridge);
00079 public:
00080 static void initialize(JNIEnv *env, jclass cls);
00081 static jlong newInstance(JNIEnv *env, jobject obj);
00082 public:
00083 void visibleChanged(bool visible);
00084 void enabledChanged(bool enabled);
00085 void positionChanged(jint x, jint y);
00086 void sizeChanged(jint width, jint height);
00087 void paint(jint x, jint y, jint width, jint height);
00088 void styleChanged();
00089 void styleSheetChanged(bool removed);
00090 void focusGained();
00091 void focusLost();
00092 void keyPressed(jint modifiers, jint keyCode, jchar keyChar);
00093 void keyReleased(jint modifiers, jint keyCode, jchar keyChar);
00094 void keyTyped(jint modifiers, jint keyCode, jchar keyChar);
00095 void mouseEntered(jint button, jint modifiers, jint x, jint y);
00096 void mouseExited(jint button, jint modifiers, jint x, jint y);
00097 void mousePressed(jint button, jint modifiers, jint x, jint y);
00098 void mouseReleased(jint button, jint modifiers, jint x, jint y);
00099 void mouseClicked(jint button, jint modifiers, jint x, jint y);
00100 void mouseDoubleClicked(jint button, jint modifiers, jint x, jint y);
00101 void contextMenuTriggered(jint reason, jint modifiers, jint x, jint y,
00102 jint globalX, jint globalY);
00103 void mouseMoved(jint button, jint modifiers, jint x, jint y);
00104 void mouseDragged(jint button, jint modifiers, jint x, jint y);
00105 void mouseWheelMoved(jint modifiers, jint x, jint y, jint wheelRotation);
00106 QSize getPreferredSize();
00107 jstring getToolTipText(int x, int y);
00108 public:
00109 virtual void setParentBridge(JQContainerBridge *parentBridge);
00110 virtual QWidget *qWidget();
00111 virtual QAction *qAction();
00112 public:
00113 inline bool eventFilterEnabled() const;
00114 inline void setEventFilterEnabled(bool enabled);
00115 public:
00116 virtual void destroy(JNIEnv *env, bool notify = false);
00117 protected:
00118 friend class QWidgetActionAdapter;
00119 virtual void widgetActionDeleted(QAction *action);
00120 virtual bool filterEvent(QObject *obj, QEvent *e);
00121 virtual bool filterShowEvent(QObject *obj, QShowEvent *e);
00122 virtual bool filterHideEvent(QObject *obj, QHideEvent *e);
00123 virtual bool filterEnabledChangeEvent(QObject *obj, QEvent *e);
00124 virtual bool filterStyleChangeEvent(QObject *obj, QEvent *e);
00125 virtual bool filterResizeEvent(QObject *obj, QResizeEvent *e);
00126 virtual bool filterMoveEvent(QObject *obj, QMoveEvent *e);
00127 virtual bool filterFocusGainedEvent(QObject *obj, QFocusEvent *e);
00128 virtual bool filterFocusLostEvent(QObject *obj, QFocusEvent *e);
00129 virtual bool filterKeyPressedEvent(QObject *obj, QKeyEvent *e);
00130 virtual bool filterKeyReleasedEvent(QObject *obj, QKeyEvent *e);
00131 virtual bool filterKeyTypedEvent(QObject *obj, QKeyEvent *e);
00132 virtual bool filterMouseEnterEvent(QObject *obj, QMouseEvent *e);
00133 virtual bool filterMouseMoveEvent(QObject *obj, QMouseEvent *e);
00134 virtual bool filterMouseLeaveEvent(QObject *obj, QMouseEvent *e);
00135 virtual bool filterMousePressedEvent(QObject *obj, QMouseEvent *e);
00136 virtual bool filterMouseReleasedEvent(QObject *obj, QMouseEvent *e);
00137 virtual bool filterMouseClickedEvent(QObject *obj, QMouseEvent *e);
00138 virtual bool filterMouseDoubleClickedEvent(QObject *obj, QMouseEvent *e);
00139 virtual bool filterMouseWheelEvent(QObject *obj, QWheelEvent *e);
00140 virtual bool filterToolTipEvent(QObject *obj, QHelpEvent *e);
00141 virtual bool filterWhatsThisEvent(QObject *obj, QHelpEvent *e);
00142 virtual bool filterContextMenuEvent(QObject *obj, QContextMenuEvent *e);
00143 virtual void filterEnabledEvents();
00144 virtual QWidget *paintingWidget();
00145 protected:
00146 inline jlong enabledEvents() const;
00147 inline bool eventEnabled(jlong eventMask) const;
00148 inline QEvent *currentEvent() const;
00149 inline int previousEventType() const;
00150 inline JQContainerBridge *parentBridge() const;
00151 protected:
00152 inline static jmethodID createMID();
00153 protected:
00154 virtual jfieldID bridgePointerFID() const;
00155 virtual bool eventFilter(QObject *obj, QEvent *e);
00156 private:
00157 void fillStyleSheetProperties(JNIEnv *env, const QVariant *value);
00158 private:
00159 bool m_eventFilterEnabled;
00160 jlong m_enabledEvents;
00161 QEvent *m_currentEvent;
00162 QPaintEvent *m_paintEvent;
00163 int m_previousEventType;
00164 int m_previousKey;
00165 Qt::MouseButton m_previousMouseButton;
00166 int m_previousMouseX;
00167 int m_previousMouseY;
00168 JQContainerBridge *m_parentBridge;
00169 QWidget *m_widget;
00170 QAction *m_action;
00171 private:
00172 static jclass sm_abstractDisposableClass;
00173 static jmethodID sm_classGetNameMID;
00174 static jfieldID sm_bridgeFID;
00175 static jmethodID sm_getPreferredSizeMID;
00176 static jmethodID sm_visibleChangedMID;
00177 static jmethodID sm_enabledChangedMID;
00178 static jmethodID sm_sizeChangedMID;
00179 static jmethodID sm_positionChangedMID;
00180 static jmethodID sm_paintMID;
00181 static jmethodID sm_styleChangedMID;
00182 static jmethodID sm_styleSheetChangedMID;
00183 static jmethodID sm_focusGainedMID;
00184 static jmethodID sm_focusLostMID;
00185 static jmethodID sm_keyPressedMID;
00186 static jmethodID sm_keyReleasedMID;
00187 static jmethodID sm_keyTypedMID;
00188 static jmethodID sm_mouseEnteredMID;
00189 static jmethodID sm_mouseExitedMID;
00190 static jmethodID sm_mousePressedMID;
00191 static jmethodID sm_mouseReleasedMID;
00192 static jmethodID sm_mouseClickedMID;
00193 static jmethodID sm_mouseDoubleClickedMID;
00194 static jmethodID sm_contextMenuTriggeredMID;
00195 static jmethodID sm_mouseMovedMID;
00196 static jmethodID sm_mouseDraggedMID;
00197 static jmethodID sm_mouseWheelMovedMID;
00198 static jmethodID sm_getToolTipTextMID;
00199 static jmethodID sm_createMID;
00200 public:
00201 static const QVariant STYLE_SHEET_PROPERTY_VALUE;
00202 };
00203
00204
00205
00206
00207
00213 inline bool JQComponentBridge::eventFilterEnabled() const
00214 {
00215 return m_eventFilterEnabled;
00216 }
00217
00223 inline void JQComponentBridge::setEventFilterEnabled(bool enabled)
00224 {
00225 m_eventFilterEnabled = enabled;
00226 }
00227
00228
00229
00230
00231
00237 inline jlong JQComponentBridge::enabledEvents() const
00238 {
00239 return m_enabledEvents;
00240 }
00241
00249 inline bool JQComponentBridge::eventEnabled(jlong eventMask) const
00250 {
00251 return (m_enabledEvents & eventMask);
00252 }
00253
00259 inline QEvent *JQComponentBridge::currentEvent() const
00260 {
00261 return m_currentEvent;
00262 }
00263
00269 inline int JQComponentBridge::previousEventType() const
00270 {
00271 return m_previousEventType;
00272 }
00273
00279 JQContainerBridge *JQComponentBridge::parentBridge() const
00280 {
00281 return m_parentBridge;
00282 }
00283
00284
00285
00286
00287
00293 inline jmethodID JQComponentBridge::createMID()
00294 {
00295 return sm_createMID;
00296 }
00297
00298
00299
00300
00301
00302 #define jqComponentCast(bridge) (reinterpret_cast<JQComponentBridge *>(bridge))
00303 #define jqComponentBridge jqComponentCast(bridge)
00304
00305 #endif //JQCOMPONENTBRIDGE_H
00306
00307
00308
00309
00310
00311
00312
00313