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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [native/] [jni/] [gtk-peer/] [gtk_jawt.c] - Blame information for rev 774

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 774 jeremybenn
/* gtk_jawt.c -- GTK implementation of classpath_jawt.h
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
 
39
#include "gtkpeer.h"
40
#include <gtk/gtk.h>
41
#include <gdk/gdkx.h>
42
#include "classpath_jawt.h"
43
 
44
jint
45
classpath_jawt_get_awt_version ()
46
{
47
  return CLASSPATH_JAWT_VERSION;
48
}
49
 
50
/* Does not require locking: meant to be called after the drawing
51
   surface is locked. */
52
Display*
53
classpath_jawt_get_default_display (JNIEnv* env, jobject canvas)
54
{
55
  GdkDisplay *display;
56
  Display *xdisplay;
57
  GtkWidget *widget;
58
  void *ptr;
59
  jobject peer;
60
  jclass class_id;
61
  jmethodID method_id;
62
 
63
  /* retrieve peer object */
64
  class_id = (*env)->GetObjectClass (env, canvas);
65
 
66
  method_id = (*env)->GetMethodID (env, class_id,
67
                                   "getPeer",
68
                                   "()Ljava/awt/peer/ComponentPeer;");
69
 
70
  peer = (*env)->CallObjectMethod (env, canvas, method_id);
71
 
72
  ptr = gtkpeer_get_widget (env, peer);
73
 
74
  widget = GTK_WIDGET (ptr);
75
 
76
  if (GTK_WIDGET_REALIZED (widget))
77
    {
78
      display = gtk_widget_get_display (widget);
79
 
80
      xdisplay = GDK_DISPLAY_XDISPLAY (display);
81
 
82
      return xdisplay;
83
    }
84
  else
85
    return NULL;
86
}
87
 
88
/* Does not require locking: meant to be called after the drawing
89
   surface is locked. */
90
VisualID
91
classpath_jawt_get_visualID (JNIEnv* env, jobject canvas)
92
{
93
  GtkWidget *widget;
94
  Visual *visual;
95
  void *ptr;
96
  jobject peer;
97
  jclass class_id;
98
  jmethodID method_id;
99
 
100
  class_id = (*env)->GetObjectClass (env, canvas);
101
 
102
  method_id = (*env)->GetMethodID (env, class_id,
103
                                   "getPeer",
104
                                   "()Ljava/awt/peer/ComponentPeer;");
105
 
106
  peer = (*env)->CallObjectMethod (env, canvas, method_id);
107
 
108
  ptr = gtkpeer_get_widget (env, peer);
109
 
110
  widget = GTK_WIDGET (ptr);
111
 
112
  if (GTK_WIDGET_REALIZED (widget))
113
    {
114
      visual = gdk_x11_visual_get_xvisual (gtk_widget_get_visual (widget));
115
      g_assert (visual != NULL);
116
 
117
      return visual->visualid;
118
    }
119
  else
120
    return (VisualID) NULL;
121
}
122
 
123
/* Does not require locking: meant to be called after the drawing
124
   surface is locked. */
125
int
126
classpath_jawt_get_depth (JNIEnv* env, jobject canvas)
127
{
128
  GtkWidget *widget;
129
  GdkVisual *visual;
130
  void *ptr;
131
  jobject peer;
132
  jclass class_id;
133
  jmethodID method_id;
134
 
135
  class_id = (*env)->GetObjectClass (env, canvas);
136
 
137
  method_id = (*env)->GetMethodID (env, class_id,
138
                                   "getPeer",
139
                                   "()Ljava/awt/peer/ComponentPeer;");
140
 
141
  peer = (*env)->CallObjectMethod (env, canvas, method_id);
142
 
143
  ptr = gtkpeer_get_widget (env, peer);
144
 
145
  widget = GTK_WIDGET (ptr);
146
 
147
  if (GTK_WIDGET_REALIZED (widget))
148
    {
149
      visual = gtk_widget_get_visual (widget);
150
      g_assert (visual != NULL);
151
 
152
      return visual->depth;
153
    }
154
  else
155
    return (VisualID) NULL;
156
}
157
 
158
/* Does not require locking: meant to be called after the drawing
159
   surface is locked. */
160
Drawable
161
classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
162
{
163
  GtkWidget *widget;
164
  int drawable;
165
  void *ptr;
166
  jobject peer;
167
  jclass class_id;
168
  jmethodID method_id;
169
 
170
  class_id = (*env)->GetObjectClass (env, canvas);
171
 
172
  method_id = (*env)->GetMethodID (env, class_id,
173
                                   "getPeer",
174
                                   "()Ljava/awt/peer/ComponentPeer;");
175
 
176
  peer = (*env)->CallObjectMethod (env, canvas, method_id);
177
 
178
  ptr = gtkpeer_get_widget (env, peer);
179
 
180
  widget = GTK_WIDGET (ptr);
181
 
182
  if (GTK_WIDGET_REALIZED (widget))
183
    {
184
      drawable = GDK_DRAWABLE_XID (widget->window);
185
 
186
      return drawable;
187
    }
188
  else
189
    return (Drawable) NULL;
190
}
191
 
192
jint
193
classpath_jawt_lock ()
194
{
195
  gdk_threads_enter ();
196
  return 0;
197
}
198
 
199
void
200
classpath_jawt_unlock ()
201
{
202
  gdk_threads_leave ();
203
}

powered by: WebSVN 2.1.0

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