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

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

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

revision 1.1.2.1 by gnu_andrew, Tue Aug 16 16:22:39 2005 UTC revision 1.1.2.2 by gnu_andrew, Sat Sep 10 15:32:03 2005 UTC
# Line 35  this exception to your version of the li Line 35  this exception to your version of the li
35  obligated to do so.  If you do not wish to do so, delete this  obligated to do so.  If you do not wish to do so, delete this
36  exception statement from your version. */  exception statement from your version. */
37    
38    #include <assert.h>
39    #include <QWidget>
40    #include <QPoint>
41    
42  #include "componentevent.h"  #include "componentevent.h"
43        
44  AWTInitEvent::AWTInitEvent(JNIEnv *env, jobject obj) : AWTEvent()  AWTInitEvent::AWTInitEvent(JNIEnv *env, jobject obj) : AWTEvent()
# Line 48  void AWTInitEvent::runEvent() Line 52  void AWTInitEvent::runEvent()
52    JNIEnv *env;    JNIEnv *env;
53    vm->GetEnv((void **)&env, JNI_VERSION_1_1);    vm->GetEnv((void **)&env, JNI_VERSION_1_1);
54    jclass targetCls = env->GetObjectClass( target );    jclass targetCls = env->GetObjectClass( target );
55    jmethodID initID = env->GetMethodID( targetCls,    // call init()
56      jmethodID mID = env->GetMethodID( targetCls,
57                                         "init",                                         "init",
58                                         "()V" );                                         "()V" );
59      env->CallVoidMethod( target, mID );
60    
61      // call notify()
62      mID = env->GetMethodID( targetCls,
63                              "notify",
64                              "()V" );
65      assert(mID != NULL);
66    env->MonitorEnter( target );    env->MonitorEnter( target );
67    env->CallVoidMethod( target, initID );    env->CallVoidMethod( target, mID );
68    env->MonitorExit( target );    env->MonitorExit( target );
69    
70    env->DeleteGlobalRef( target );    env->DeleteGlobalRef( target );
71  }  }
72    
# Line 101  AWTResizeEvent::AWTResizeEvent(QWidget * Line 114  AWTResizeEvent::AWTResizeEvent(QWidget *
114    
115  void AWTResizeEvent::runEvent()  void AWTResizeEvent::runEvent()
116  {  {
117    widget->setGeometry( x, y, w, h );    QRect g = widget->geometry();
118      if(g.x() != x || g.y() != y || g.width() != w || g.height() != h)
119        widget->setGeometry( x, y, w, h );
120  }  }
121    
122  AWTBackgroundEvent::AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr)  AWTBackgroundEvent::AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr)
# Line 131  void AWTBackgroundEvent::runEvent() Line 146  void AWTBackgroundEvent::runEvent()
146    delete color;    delete color;
147  }  }
148    
149    AWTGetOriginEvent::AWTGetOriginEvent(QWidget *w, JNIEnv *env, jobject obj) : AWTEvent()
150    {
151      widget = w;
152      env->GetJavaVM( &vm );
153      target = env->NewGlobalRef( obj );
154    }
155    
156    void AWTGetOriginEvent::runEvent()
157    {
158      JNIEnv *env;
159      vm->GetEnv((void **)&env, JNI_VERSION_1_1);
160      jclass targetCls = env->GetObjectClass( target );
161    
162      QPoint *p = new QPoint( widget->mapToGlobal( QPoint(0, 0) ) );
163      // call init()
164      jmethodID mID = env->GetMethodID( targetCls,
165                                           "setLocation",
166                                           "(II)V" );
167      env->CallVoidMethod( target, mID, p->x(), p->y() );
168      delete p;
169    
170      // call notify()
171      mID = env->GetMethodID( targetCls,
172                              "notify",
173                              "()V" );
174      assert(mID != NULL);
175      env->MonitorEnter( target );
176      env->CallVoidMethod( target, mID );
177      env->MonitorExit( target );
178    
179      env->DeleteGlobalRef( target );
180    }
181    
182    GetSizeEvent::GetSizeEvent(QWidget *w, JNIEnv *env, jobject obj, bool p) : AWTEvent()
183    {
184      widget = w;
185      env->GetJavaVM( &vm );
186      target = env->NewGlobalRef( obj );
187      pref = p;
188    }
189    
190    void GetSizeEvent::runEvent()
191    {
192      JNIEnv *env;
193      vm->GetEnv((void **)&env, JNI_VERSION_1_1);
194      jclass targetCls = env->GetObjectClass( target );
195    
196      QPoint *p = new QPoint( widget->mapToGlobal( QPoint(0, 0) ) );
197      QSize s;
198      if( pref )
199        s = widget->sizeHint();
200      else
201        s = widget->minimumSizeHint();
202    
203      // call init()
204      jmethodID mID = env->GetMethodID( targetCls,
205                                           "setSize",
206                                           "(II)V" );
207      env->CallVoidMethod( target, mID, s.width(), s.height() );
208    
209      // call notify()
210      mID = env->GetMethodID( targetCls,
211                              "notify",
212                              "()V" );
213      assert(mID != NULL);
214      env->MonitorEnter( target );
215      env->CallVoidMethod( target, mID );
216      env->MonitorExit( target );
217    
218      env->DeleteGlobalRef( target );
219    }
220    
221    
222    
223    

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

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