JQTreeBridge.h

00001 /*
00002  * @(#)JQTreeBridge.h  0.2.0 / 2007-12-17
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 JQTREEBRIDGE_H
00010 #define JQTREEBRIDGE_H
00011 
00012 #include "JavaQxQSwing.h"
00013 
00014 #include "JQComponentBridge.h"
00015 #include "QIconAdapter.h"
00016 #include "QTreeViewAdapter.h"
00017 #include "TreeModel.h"
00018 
00019 /*^**************************************************************************^*/
00020 /*- JQTreeBridge Class.                                                      -*/
00021 /*^**************************************************************************^*/
00022 
00029 class JAVAQX_EXPORT JQTreeBridge : public JQComponentBridge
00030 {
00031   Q_OBJECT
00032 protected:
00033   JQTreeBridge(JNIEnv *env, jobject obj);
00034   virtual ~JQTreeBridge();
00035 public: // native calls
00036   void createIcon(JNIEnv *env, jobject iconSet);
00037   void setUseModel(JNIEnv *env, jboolean useModel);
00038 public: // native calls
00039   static void initialize(JNIEnv *env, jclass cls, jclass treeNodeClass);
00040   static jlong newInstance(JNIEnv *env, jobject obj);
00041 public: // native callbacks
00042   jobject getRootNode();
00043   void nodeSelected(jobject node);
00044   jboolean setNodeIcon(jobject node);
00045 public:
00046   QIcon *getNodeIcon(jobject node);
00047 public:
00048   inline QTreeViewAdapter *qTreeView() const;
00049 public:
00050   virtual jobject getBackground(JNIEnv *env, jclass colorClass);
00051   virtual void setBackground(JNIEnv *env, jint argb);
00052   virtual void setNullBackground(JNIEnv *env);
00053   virtual jint getCursor(JNIEnv *env);
00054   virtual void setCursor(JNIEnv *env, jint type);
00055 protected slots:
00056   void selectionChangedSlot(const QItemSelection &selected,
00057                             const QItemSelection &deselected);
00058 private:
00059   QIconAdapter *m_nodeIcon;
00060   TreeModel *m_treeModel;
00061   QItemSelectionModel *m_treeSelectionModel;
00062 private:
00063   static jmethodID sm_getRootNodeMID;
00064   static jmethodID sm_setNodeIconMID;
00065   static jmethodID sm_nodeSelectedMID;
00066 };
00067 
00068 /*^**************************************************************************^*/
00069 /*- JQTreeBridge :: Public Inline Member Function.                           -*/
00070 /*^**************************************************************************^*/
00071 
00077 inline QTreeViewAdapter *JQTreeBridge::qTreeView() const
00078 {
00079   return static_cast<QTreeViewAdapter *>(qObject());
00080 }
00081 
00082 /*^**************************************************************************^*/
00083 /*- Macro Definition.                                                        -*/
00084 /*^**************************************************************************^*/
00085 
00086 #define jqTreeBridge (reinterpret_cast<JQTreeBridge *>(bridge))
00087 
00088 #endif //JQTREEBRIDGE_H
00089 
00090 /*^*****************************************************************************
00091   File History:
00092 
00093  - 2007-12-17 14:20:21 Slobodan
00094    Initial version
00095 
00096 *****************************************************************************^*/

Copyright © 2007 ETF and contributors. All Rights Reserved.