OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [native/] [jni/] [qt-peer/] [componentevent.cpp] - Blame information for rev 774

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 774 jeremybenn
/* componentevent.cpp --
2
   Copyright (C)  2005  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
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)
9
any later version.
10
 
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.
15
 
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
19
02110-1301 USA.
20
 
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
24
combination.
25
 
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. */
37
 
38
#include <assert.h>
39
#include <QWidget>
40
#include <QPoint>
41
 
42
#include "componentevent.h"
43
 
44
AWTInitEvent::AWTInitEvent(JNIEnv *env, jobject obj) : AWTEvent()
45
{
46
  env->GetJavaVM( &vm );
47
  target = env->NewGlobalRef( obj );
48
}
49
 
50
void AWTInitEvent::runEvent()
51
{
52
  JNIEnv *env;
53
  vm->GetEnv((void **)&env, JNI_VERSION_1_1);
54
  jclass targetCls = env->GetObjectClass( target );
55
  // call init()
56
  jmethodID mID = env->GetMethodID( targetCls,
57
                                       "init",
58
                                       "()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 );
67
  env->CallVoidMethod( target, mID );
68
  env->MonitorExit( target );
69
 
70
  env->DeleteGlobalRef( target );
71
}
72
 
73
AWTShowEvent::AWTShowEvent(QWidget *w, bool v) : AWTEvent()
74
{
75
  widget = w;
76
  visible = v;
77
}
78
 
79
void AWTShowEvent::runEvent()
80
{
81
  widget->setVisible( visible );
82
}
83
 
84
AWTEnableEvent::AWTEnableEvent(QWidget *w, bool v) : AWTEvent()
85
{
86
  widget = w;
87
  enabled = v;
88
}
89
 
90
void AWTEnableEvent::runEvent()
91
{
92
  widget->setEnabled( enabled );
93
}
94
 
95
AWTCursorEvent::AWTCursorEvent(QWidget *w, Qt::CursorShape s) : AWTEvent()
96
{
97
  widget = w;
98
  shape = s;
99
}
100
 
101
void AWTCursorEvent::runEvent()
102
{
103
  QCursor *s = new QCursor(shape);
104
  widget->setCursor( *s );
105
}
106
 
107
AWTResizeEvent::AWTResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0)
108
{
109
  widget = wid;
110
  x = x0; y = y0;
111
  w = w0; h = h0;
112
  if(w == 0 && h == 0) w = h = 10;
113
}
114
 
115
void AWTResizeEvent::runEvent()
116
{
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 );
120
}
121
 
122
AWTBackgroundEvent::AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr)
123
{
124
  widget = wid;
125
  foreground = fg;
126
  color = clr;
127
}
128
 
129
void AWTBackgroundEvent::runEvent()
130
{
131
  QPalette p = widget->palette();
132
  if (foreground)
133
    {
134
      p.setColor(QPalette::Active, QPalette::Foreground, *color);
135
      p.setColor(QPalette::Active, QPalette::Text, *color);
136
    }
137
  else
138
    {
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);
143
    }
144
  widget->setPalette(p);
145
  widget->repaint();
146
  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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.