1 /* componentevent.cpp --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
42 #include "componentevent.h"
44 AWTInitEvent::AWTInitEvent(JNIEnv
*env
, jobject obj
) : AWTEvent()
46 env
->GetJavaVM( &vm
);
47 target
= env
->NewGlobalRef( obj
);
50 void AWTInitEvent::runEvent()
53 vm
->GetEnv((void **)&env
, JNI_VERSION_1_1
);
54 jclass targetCls
= env
->GetObjectClass( target
);
56 jmethodID mID
= env
->GetMethodID( targetCls
,
59 env
->CallVoidMethod( target
, mID
);
62 mID
= env
->GetMethodID( targetCls
,
66 env
->MonitorEnter( target
);
67 env
->CallVoidMethod( target
, mID
);
68 env
->MonitorExit( target
);
70 env
->DeleteGlobalRef( target
);
73 AWTShowEvent::AWTShowEvent(QWidget
*w
, bool v
) : AWTEvent()
79 void AWTShowEvent::runEvent()
81 widget
->setVisible( visible
);
84 AWTEnableEvent::AWTEnableEvent(QWidget
*w
, bool v
) : AWTEvent()
90 void AWTEnableEvent::runEvent()
92 widget
->setEnabled( enabled
);
95 AWTCursorEvent::AWTCursorEvent(QWidget
*w
, Qt::CursorShape s
) : AWTEvent()
101 void AWTCursorEvent::runEvent()
103 QCursor
*s
= new QCursor(shape
);
104 widget
->setCursor( *s
);
107 AWTResizeEvent::AWTResizeEvent(QWidget
*wid
, int x0
, int y0
, int w0
, int h0
)
112 if(w
== 0 && h
== 0) w
= h
= 10;
115 void AWTResizeEvent::runEvent()
117 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
);
122 AWTBackgroundEvent::AWTBackgroundEvent(QWidget
*wid
, bool fg
, QColor
*clr
)
129 void AWTBackgroundEvent::runEvent()
131 QPalette p
= widget
->palette();
134 p
.setColor(QPalette::Active
, QPalette::Foreground
, *color
);
135 p
.setColor(QPalette::Active
, QPalette::Text
, *color
);
139 p
.setColor(QPalette::Active
, QPalette::Background
, *color
);
140 p
.setColor(QPalette::Active
, QPalette::Button
, *color
);
141 p
.setColor(QPalette::Active
, QPalette::Base
, *color
);
142 p
.setColor(QPalette::Active
, QPalette::AlternateBase
, *color
);
144 widget
->setPalette(p
);
149 AWTGetOriginEvent::AWTGetOriginEvent(QWidget
*w
, JNIEnv
*env
, jobject obj
) : AWTEvent()
152 env
->GetJavaVM( &vm
);
153 target
= env
->NewGlobalRef( obj
);
156 void AWTGetOriginEvent::runEvent()
159 vm
->GetEnv((void **)&env
, JNI_VERSION_1_1
);
160 jclass targetCls
= env
->GetObjectClass( target
);
162 QPoint
*p
= new QPoint( widget
->mapToGlobal( QPoint(0, 0) ) );
164 jmethodID mID
= env
->GetMethodID( targetCls
,
167 env
->CallVoidMethod( target
, mID
, p
->x(), p
->y() );
171 mID
= env
->GetMethodID( targetCls
,
175 env
->MonitorEnter( target
);
176 env
->CallVoidMethod( target
, mID
);
177 env
->MonitorExit( target
);
179 env
->DeleteGlobalRef( target
);
182 GetSizeEvent::GetSizeEvent(QWidget
*w
, JNIEnv
*env
, jobject obj
, bool p
) : AWTEvent()
185 env
->GetJavaVM( &vm
);
186 target
= env
->NewGlobalRef( obj
);
190 void GetSizeEvent::runEvent()
193 vm
->GetEnv((void **)&env
, JNI_VERSION_1_1
);
194 jclass targetCls
= env
->GetObjectClass( target
);
196 QPoint
*p
= new QPoint( widget
->mapToGlobal( QPoint(0, 0) ) );
199 s
= widget
->sizeHint();
201 s
= widget
->minimumSizeHint();
204 jmethodID mID
= env
->GetMethodID( targetCls
,
207 env
->CallVoidMethod( target
, mID
, s
.width(), s
.height() );
210 mID
= env
->GetMethodID( targetCls
,
214 env
->MonitorEnter( target
);
215 env
->CallVoidMethod( target
, mID
);
216 env
->MonitorExit( target
);
218 env
->DeleteGlobalRef( target
);