JQAbstractButtonBridge.h

00001 /*
00002  * @(#)JQAbstractButtonBridge.h  0.2.0 / 2007-08-16
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 JQABSTRACTBUTTONBRIDGE_H
00010 #define JQABSTRACTBUTTONBRIDGE_H
00011 
00012 #include "JavaQxQSwing.h"
00013 
00014 #include "JQComponentBridge.h"
00015 #include "QIconAdapter.h"
00016 
00017 /*^**************************************************************************^*/
00018 /*- JQAbstractButtonBridge Class.                                            -*/
00019 /*^**************************************************************************^*/
00020 
00027 class JAVAQX_EXPORT JQAbstractButtonBridge : public JQComponentBridge
00028 {
00029   Q_OBJECT
00030 protected:
00031   JQAbstractButtonBridge(JNIEnv *env, jobject obj, QAbstractButton *button);
00032   JQAbstractButtonBridge(JNIEnv *env, jobject obj);
00033 public slots: // native calls
00034   void setPressed(JNIEnv *env, jboolean pressed);
00035   void setText(JNIEnv *env, jstring text);
00036   void setIcon(JNIEnv *env, jobject iconSet);
00037   void setIconSize(JNIEnv *env, jint width, jint height);
00038 public: // native calls
00039   static void initialize(JNIEnv *env, jclass cls);
00040   static jlong newInstance(JNIEnv *env, jobject obj);
00041 public: // native callbacks
00042   jboolean buttonPressed();
00043   jboolean buttonReleased();
00044   void buttonClicked(jint modifiers);
00045 public:
00046   inline QAbstractButton *qAbstractButton() const;
00047 public:
00048   virtual jobject getBackground(JNIEnv *env, jclass colorClass);
00049   virtual void setBackground(JNIEnv *env, jint argb);
00050   virtual void setNullBackground(JNIEnv *env);
00051   virtual jobject getForeground(JNIEnv *env, jclass colorClass);
00052   virtual void setForeground(JNIEnv *env, jint argb);
00053   virtual void setNullForeground(JNIEnv *env);
00054 protected slots:
00055   void pressedSlot();
00056   void releasedSlot();
00057   void clickedSlot();
00058 protected:
00059   inline void setIconType(QIconAdapter::IconType iconType);
00060 protected:
00061   virtual bool filterKeyPressedEvent(QObject *obj, QKeyEvent *e);
00062   virtual bool filterKeyReleasedEvent(QObject *obj, QKeyEvent *e);
00063   virtual bool filterMouseEnterEvent(QObject *obj, QMouseEvent *e);
00064   virtual bool filterMouseLeaveEvent(QObject *obj, QMouseEvent *e);
00065 private:
00066   Qt::KeyboardModifiers m_modifiers;
00067   QIconAdapter::IconType m_iconType;
00068 private:
00069   static jmethodID sm_buttonPressedMID;
00070   static jmethodID sm_buttonReleasedMID;
00071   static jmethodID sm_buttonClickedMID;
00072 };
00073 
00074 /*^**************************************************************************^*/
00075 /*- JQAbstractButtonBridge :: Public Inline Member Function.                 -*/
00076 /*^**************************************************************************^*/
00077 
00083 inline QAbstractButton *JQAbstractButtonBridge::qAbstractButton() const
00084 {
00085   return static_cast<QAbstractButton *>(qObject());
00086 }
00087 
00088 /*^**************************************************************************^*/
00089 /*- JQAbstractButtonBridge :: Protected Inline Member Function.              -*/
00090 /*^**************************************************************************^*/
00091 
00097 inline void JQAbstractButtonBridge::setIconType(QIconAdapter::IconType iconType)
00098 {
00099   m_iconType = iconType;
00100 }
00101 
00102 /*^**************************************************************************^*/
00103 /*- Macro Definition.                                                        -*/
00104 /*^**************************************************************************^*/
00105 
00106 #define jqAbstractButtonBridge \
00107     (reinterpret_cast<JQAbstractButtonBridge *>(bridge))
00108 
00109 #endif //JQABSTRACTBUTTONBRIDGE_H
00110 
00111 /*^*****************************************************************************
00112   File History:
00113 
00114  - 2007-08-16 07:56:37 Slobodan
00115    Initial version
00116 
00117 *****************************************************************************^*/

Copyright © 2007 ETF and contributors. All Rights Reserved.