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" |
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 |
{ |
{ |
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; |
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 |
} |
} |
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; |
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; |
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 |
{ |
{ |
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); |
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 |
|
|