JQActionComponentBridge.h

00001 /*
00002  * @(#)JQActionComponentBridge.h  0.2.0 / 2007-11-09
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 JQACTIONCOMPONENTBRIDGE_H
00010 #define JQACTIONCOMPONENTBRIDGE_H
00011 
00012 #include "JavaQxQSwing.h"
00013 
00014 #include "JQComponentBridge.h"
00015 
00016 /*^**************************************************************************^*/
00017 /*- JQActionComponentBridge Class.                                           -*/
00018 /*^**************************************************************************^*/
00019 // TODO: test entire module and add better QAction-QWidget switching support
00023 class JAVAQX_EXPORT JQActionComponentData
00024 {
00025   friend class JQActionComponentBridge; // uses all members
00026 protected:
00027   JQActionComponentData();
00028 public:
00029   // TODO: implement getters
00030 protected:
00031   bool focusable;
00032   bool opaque;
00033   bool updatesEnabled;
00034   int orientation;
00035   QRect bounds;
00036   QSize maximumSize;
00037   QSize minimumSize;
00038   QSize fixedSize;
00039   QColor background;
00040   QColor foreground;
00041   QString toolTip;
00042   QString styleSheet;
00043   QCursor cursor;
00044 };
00045 
00052 class JQActionComponentBridge : public JQComponentBridge
00053 {
00054   Q_OBJECT
00055 protected:
00056   JQActionComponentBridge(JNIEnv *env, jobject obj, QAction *action);
00057   JQActionComponentBridge(JNIEnv *env, jobject obj);
00058   virtual ~JQActionComponentBridge();
00059 public slots: // native calls
00060   virtual void setVisible(JNIEnv *env, jboolean visible);
00061   virtual void showWindow(JNIEnv *env);
00062   virtual void setEnabled(JNIEnv *env, jboolean enabled);
00063   virtual void setFocusable(JNIEnv *env, jboolean focusable);
00064   virtual void requestFocus(JNIEnv *env);
00065   virtual void setLocation(JNIEnv *env, jint x, jint y);
00066   virtual jobject getPreferredSize(JNIEnv *env);
00067   virtual void setSize(JNIEnv *env, jint width, jint height);
00068   virtual void setMaximumSize(JNIEnv *env, jint width, jint height);
00069   virtual void setMinimumSize(JNIEnv *env, jint width, jint height);
00070   virtual void setFixedSize(JNIEnv *env, jint width, jint height);
00071   virtual void setBounds(JNIEnv *env, jint x, jint y, jint width, jint height);
00072   virtual jobject getBackground(JNIEnv *env, jclass colorClass);
00073   virtual void setBackground(JNIEnv *env, jint argb);
00074   virtual void setNullBackground(JNIEnv *env);
00075   virtual jobject getForeground(JNIEnv *env, jclass colorClass);
00076   virtual void setForeground(JNIEnv *env, jint argb);
00077   virtual void setNullForeground(JNIEnv *env);
00078   virtual void setOpaque(JNIEnv *env, jboolean opaque);
00079   virtual jobject getFont(JNIEnv *env, jclass fontClass);
00080   virtual void setFont(JNIEnv *env, jobject font);
00081   virtual void setStyleSheet(JNIEnv *env, jstring styleSheetText);
00082   virtual jint getCursor(JNIEnv *env);
00083   virtual void setCursor(JNIEnv *env, jint type);
00084   virtual void repaint(JNIEnv *env);
00085   virtual void repaint(JNIEnv *env, jint x, jint y, jint width, jint height);
00086   virtual void update(JNIEnv *env);
00087   virtual void update(JNIEnv *env, jint x, jint y, jint width, jint height);
00088   virtual void setUpdatesEnabled(JNIEnv *env, jboolean enabled);
00089   virtual void polish(JNIEnv *env);
00090   virtual void setComponentOrientation(JNIEnv *env, jint orientation);
00091   virtual void setToolTipText(JNIEnv *env, jstring text);
00092   virtual void setStatusTipText(JNIEnv *env, jstring text);
00093   virtual void setWhatsThisText(JNIEnv *env, jstring text);
00094 public:
00095   virtual void setParentBridge(JQContainerBridge *parentBridge);
00096   virtual QWidget *qWidget();
00097   virtual QAction *qAction();
00098 protected:
00099   virtual QWidget *createQWidget() = 0;
00100   virtual QAction *createQAction() = 0;
00101 protected:
00102   virtual void deleteQWidget(QWidget *widget);
00103   virtual void deleteQAction(QAction *action);
00104   virtual void switchToQWidget();
00105   virtual void switchToQAction();
00106   virtual QWidget *convertToQWidget(QAction *action);
00107   virtual QAction *convertToQAction(QWidget *widget);
00108   virtual JQActionComponentData *createActionData();
00109 protected:
00110   virtual void filterEnabledEvents();
00111 protected:
00112   bool isQWidget();
00113   JQActionComponentData *actionData();
00114   JQActionComponentData *getActionData(QAction *action);
00115 protected:
00116   inline QWidget *widget() const;
00117   inline QAction *action() const;
00118 protected:
00119   virtual void objectDestroyed(QObject *qObj);
00120 private:
00121   bool m_makeVisible;
00122 };
00123 
00124 /*^**************************************************************************^*/
00125 /*- JQActionComponentBridge :: Protected Inline Member Functions.            -*/
00126 /*^**************************************************************************^*/
00127 
00133 inline QWidget *JQActionComponentBridge::widget() const
00134 {
00135   return m_widget;
00136 }
00137 
00143 inline QAction *JQActionComponentBridge::action() const
00144 {
00145   return m_action;
00146 }
00147 
00148 #endif //JQACTIONCOMPONENTBRIDGE_H
00149 
00150 /*^*****************************************************************************
00151   File History:
00152 
00153  - 2007-11-09 19:51:13 Slobodan
00154    Initial version
00155 
00156 *****************************************************************************^*/

Copyright © 2007 ETF and contributors. All Rights Reserved.