/[classpath]/classpath/native/jni/qt-peer/slotcallbacks.cpp
ViewVC logotype

Diff of /classpath/native/jni/qt-peer/slotcallbacks.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by smarothy, Thu Aug 11 17:06:48 2005 UTC revision 1.2 by smarothy, Tue Aug 16 23:22:09 2005 UTC
# Line 40  exception statement from your version. * Line 40  exception statement from your version. *
40  #include <QAbstractSlider>  #include <QAbstractSlider>
41  #include <QAction>  #include <QAction>
42  #include <QComboBox>  #include <QComboBox>
43    #include <QListWidget>
44    #include <QLineEdit>
45  #include <QPushButton>  #include <QPushButton>
46    #include <QTextEdit>
47  #include <gnu_java_awt_peer_qt_QtButtonPeer.h>  #include <gnu_java_awt_peer_qt_QtButtonPeer.h>
48  #include "qtcomponent.h"  #include "qtcomponent.h"
49  #include "qtstrings.h"  #include "qtstrings.h"
# Line 67  private: Line 70  private:
70    
71  public:  public:
72    QScrollBar *sb; // used only by the scrollbar method.    QScrollBar *sb; // used only by the scrollbar method.
73      QListWidget *lw; // used only by the listitemclicked method
74    
75    SlotCallback(JNIEnv *env, jobject t)    SlotCallback(JNIEnv *env, jobject t)
76    {      {  
# Line 82  public: Line 86  public:
86      env->DeleteGlobalRef(target);      env->DeleteGlobalRef(target);
87    }    }
88    
89  public slots:    public slots:
90    
91    void buttonClicked()    void buttonClicked()
92    {    {
93      JNIEnv *env;      JNIEnv *env;
# Line 91  public slots: Line 96  public slots:
96      fireEventID = env->GetMethodID( componentCls,      fireEventID = env->GetMethodID( componentCls,
97                                      "fireClick",                                      "fireClick",
98                                      "(I)V" );                                      "(I)V" );
99      int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );      int modifiers = getAEKeyModifiers( QApplication::keyboardModifiers() );
100      env->CallVoidMethod( target, fireEventID, modifiers );      env->CallVoidMethod( target, fireEventID, modifiers );
101      env->DeleteLocalRef( componentCls );      env->DeleteLocalRef( componentCls );
102    }    }
# Line 110  public slots: Line 115  public slots:
115        env->CallVoidMethod( target, fireEventID, JNI_FALSE );        env->CallVoidMethod( target, fireEventID, JNI_FALSE );
116      env->DeleteLocalRef( componentCls );      env->DeleteLocalRef( componentCls );
117    }    }
118      
119      // Used for List and Choice
120    void choiceActivated( int index )    void choiceActivated( int index )
121    {    {
122      JNIEnv *env;      JNIEnv *env;
# Line 123  public slots: Line 129  public slots:
129      env->DeleteLocalRef( componentCls );      env->DeleteLocalRef( componentCls );
130    }    }
131    
132      void textChanged()
133      {
134        JNIEnv *env;
135        vm->GetEnv((void **)&env, JNI_VERSION_1_1);
136        componentCls = env->GetObjectClass( target );
137        fireEventID = env->GetMethodID( componentCls,
138                                        "textChanged",
139                                        "()V" );
140        env->CallVoidMethod( target, fireEventID );
141        env->DeleteLocalRef( componentCls );
142      }
143    
144    void scrollBarAction( int action )    void scrollBarAction( int action )
145    {    {
146      JNIEnv *env;      JNIEnv *env;
# Line 163  public slots: Line 181  public slots:
181      env->CallVoidMethod( target, fireEventID, (jint)type, (jint)index );      env->CallVoidMethod( target, fireEventID, (jint)type, (jint)index );
182      env->DeleteLocalRef( componentCls );      env->DeleteLocalRef( componentCls );
183    }    }
184    
185      void listItemClicked( QListWidgetItem * item )
186      {
187        int index = lw->row( item );
188        JNIEnv *env;
189        vm->GetEnv((void **)&env, JNI_VERSION_1_1);
190        componentCls = env->GetObjectClass( target );
191        fireEventID = env->GetMethodID( componentCls,
192                                        "itemDoubleClicked",
193                                        "(II)V" );
194        int modifiers = getAEKeyModifiers( QApplication::keyboardModifiers() );
195        env->CallVoidMethod( target, fireEventID, index, modifiers );
196        env->DeleteLocalRef( componentCls );
197      }
198  };  };
199    
200  #include "slotcallbacks.moc"  #include "slotcallbacks.moc.h"
201    
202  void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj)  void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj)
203  {  {
# Line 179  void connectChoice(QComboBox *choice, JN Line 211  void connectChoice(QComboBox *choice, JN
211    QObject::connect( choice, SIGNAL( activated(int) ), scb, SLOT( choiceActivated(int) ) );    QObject::connect( choice, SIGNAL( activated(int) ), scb, SLOT( choiceActivated(int) ) );
212  }  }
213    
214    void connectList(QListWidget *list, JNIEnv *env, jobject listobj)
215    {
216      SlotCallback *scb = new SlotCallback(env, listobj);
217      scb->lw = list;
218      QObject::connect( list, SIGNAL( currentRowChanged(int) ),
219                        scb, SLOT( choiceActivated(int) ) );
220      QObject::connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem * )),
221                        scb, SLOT( listItemClicked( QListWidgetItem * )));
222    }
223    
224  void connectAction(QAction *action, JNIEnv *env, jobject obj)  void connectAction(QAction *action, JNIEnv *env, jobject obj)
225  {  {
226    SlotCallback *scb = new SlotCallback(env, obj);    SlotCallback *scb = new SlotCallback(env, obj);
# Line 197  void connectScrollBar(QScrollBar *scroll Line 239  void connectScrollBar(QScrollBar *scroll
239    scb->sb = scroll;    scb->sb = scroll;
240    QObject::connect( scroll, SIGNAL( actionTriggered(int) ), scb, SLOT( scrollBarAction(int) ) );    QObject::connect( scroll, SIGNAL( actionTriggered(int) ), scb, SLOT( scrollBarAction(int) ) );
241  }  }
242    
243    void connectTextEdit(QTextEdit *edit, JNIEnv *env, jobject obj)
244    {
245      SlotCallback *scb = new SlotCallback(env, obj);
246      QObject::connect( edit, SIGNAL( textChanged() ),
247                        scb, SLOT( textChanged() ) );
248    }
249    
250    void connectLineEdit(QLineEdit *edit, JNIEnv *env, jobject obj)
251    {
252      SlotCallback *scb = new SlotCallback(env, obj);
253      QObject::connect( edit, SIGNAL(textChanged( QString ) ),
254                        scb, SLOT( textChanged() ) );
255    }
256    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26