1 | /* GtkToolkit.java -- Implements an AWT Toolkit using GTK for peers
|
---|
2 | Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of the peer AWT libraries of GNU Classpath.
|
---|
5 |
|
---|
6 | This library is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU Library General Public License as published
|
---|
8 | by the Free Software Foundation, either version 2 of the License, or
|
---|
9 | (at your option) any later verion.
|
---|
10 |
|
---|
11 | This library 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
|
---|
14 | GNU Library General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU Library General Public License
|
---|
17 | along with this library; if not, write to the Free Software Foundation
|
---|
18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. */
|
---|
19 |
|
---|
20 |
|
---|
21 | package gnu.awt.gtk;
|
---|
22 |
|
---|
23 | import java.awt.*;
|
---|
24 | import java.net.*;
|
---|
25 | import java.util.Hashtable;
|
---|
26 | import java.util.Properties;
|
---|
27 | import java.util.MissingResourceException;
|
---|
28 | import java.awt.datatransfer.*;
|
---|
29 | import java.awt.image.*;
|
---|
30 | import java.awt.peer.*;
|
---|
31 |
|
---|
32 | public class GtkToolkit extends java.awt.Toolkit
|
---|
33 | {
|
---|
34 | static GtkMainThread gtkthread;
|
---|
35 | static EventQueue evtqueue;
|
---|
36 | static Hashtable containers = new Hashtable();
|
---|
37 | static Clipboard systemClipboard;
|
---|
38 | static GtkToolkit instance = null;
|
---|
39 |
|
---|
40 | public GtkToolkit ()
|
---|
41 | {
|
---|
42 | gtkInit();
|
---|
43 | instance = this;
|
---|
44 | //systemClipboard = new GtkClipboard ();
|
---|
45 | }
|
---|
46 |
|
---|
47 | // Start the thread to run the GTK event loop. This is called from
|
---|
48 | // a GtkComponentPeer static initializer.
|
---|
49 | void init ()
|
---|
50 | {
|
---|
51 | gtkthread = new GtkMainThread ();
|
---|
52 | gtkthread.start();
|
---|
53 | }
|
---|
54 |
|
---|
55 | static native void gtkInit();
|
---|
56 |
|
---|
57 | native public void beep ();
|
---|
58 |
|
---|
59 | public int checkImage (Image image, int width, int height,
|
---|
60 | ImageObserver observer)
|
---|
61 | {
|
---|
62 | return ImageObserver.ALLBITS;
|
---|
63 |
|
---|
64 | // GtkImage i = (GtkImage) image;
|
---|
65 | // return i.checkImage ();
|
---|
66 | }
|
---|
67 |
|
---|
68 | public Image createImage(String filename)
|
---|
69 | {
|
---|
70 | return null;
|
---|
71 | }
|
---|
72 |
|
---|
73 | public Image createImage(URL url)
|
---|
74 | {
|
---|
75 | return null;
|
---|
76 | }
|
---|
77 |
|
---|
78 | public Image createImage (ImageProducer producer)
|
---|
79 | {
|
---|
80 | // return new GtkImage (producer, null);
|
---|
81 | return null;
|
---|
82 | }
|
---|
83 |
|
---|
84 | public Image createImage (byte[] imagedata, int imageoffset,
|
---|
85 | int imagelength)
|
---|
86 | {
|
---|
87 | System.out.println ("createImage byte[] NOT SUPPORTED");
|
---|
88 | return null;
|
---|
89 | }
|
---|
90 |
|
---|
91 | public ColorModel getColorModel ()
|
---|
92 | {
|
---|
93 | return ColorModel.getRGBdefault ();
|
---|
94 | }
|
---|
95 |
|
---|
96 | public String[] getFontList ()
|
---|
97 | {
|
---|
98 | return (new String[] { "Dialog",
|
---|
99 | "DialogInput",
|
---|
100 | "Monospaced",
|
---|
101 | "Serif",
|
---|
102 | "SansSerif" });
|
---|
103 | }
|
---|
104 |
|
---|
105 | public FontMetrics getFontMetrics (Font font)
|
---|
106 | {
|
---|
107 | // return new GdkFontMetrics (font);
|
---|
108 | return null;
|
---|
109 | }
|
---|
110 |
|
---|
111 | public Image getImage (String filename)
|
---|
112 | {
|
---|
113 | // return new GtkImage (new GdkPixbufDecoder (filename), null);
|
---|
114 | return null;
|
---|
115 | }
|
---|
116 |
|
---|
117 | public Image getImage (URL url)
|
---|
118 | {
|
---|
119 | // return new GtkImage (new GdkPixbufDecoder (url), null);
|
---|
120 | return null;
|
---|
121 | }
|
---|
122 |
|
---|
123 | /*
|
---|
124 | public PrintJob getPrintJob (Frame frame, String jobtitle, Properties props)
|
---|
125 | {
|
---|
126 | return null;
|
---|
127 | }
|
---|
128 | */
|
---|
129 | native public int getScreenResolution();
|
---|
130 |
|
---|
131 | native public Dimension getScreenSize ();
|
---|
132 |
|
---|
133 | public Clipboard getSystemClipboard()
|
---|
134 | {
|
---|
135 | return systemClipboard;
|
---|
136 | }
|
---|
137 |
|
---|
138 | public boolean prepareImage (Image image, int width, int height,
|
---|
139 | ImageObserver observer)
|
---|
140 | {
|
---|
141 | return false;
|
---|
142 | }
|
---|
143 |
|
---|
144 | native public void sync ();
|
---|
145 |
|
---|
146 | protected void setComponentState (Component c, GtkComponentPeer cp)
|
---|
147 | {
|
---|
148 | /* Make the Peer reflect the state of the Component */
|
---|
149 | if (! (c instanceof Window))
|
---|
150 | {
|
---|
151 | cp.setCursor (c.getCursor ());
|
---|
152 |
|
---|
153 | Rectangle bounds = c.getBounds ();
|
---|
154 | cp.setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
|
---|
155 | if (c instanceof Canvas)
|
---|
156 | System.out.println ("width " + bounds.width + " height " + bounds.height);
|
---|
157 |
|
---|
158 | cp.setVisible (c.isVisible ());
|
---|
159 | }
|
---|
160 | }
|
---|
161 |
|
---|
162 | protected ButtonPeer createButton (Button b)
|
---|
163 | {
|
---|
164 | return null;
|
---|
165 | /*
|
---|
166 | GtkButtonPeer bp = new GtkButtonPeer (b);
|
---|
167 | Rectangle bounds = b.getBounds ();
|
---|
168 | bp.setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
|
---|
169 | return bp;
|
---|
170 | */
|
---|
171 | }
|
---|
172 |
|
---|
173 | protected CanvasPeer createCanvas (Canvas c)
|
---|
174 | {
|
---|
175 | // return new GtkCanvasPeer (c);
|
---|
176 | return null;
|
---|
177 | }
|
---|
178 |
|
---|
179 | protected CheckboxPeer createCheckbox (Checkbox cb)
|
---|
180 | {
|
---|
181 | return null;
|
---|
182 | /*
|
---|
183 | if (cb.getCheckboxGroup () != null)
|
---|
184 | return new GtkRadioButtonPeer (cb);
|
---|
185 | else
|
---|
186 | return new GtkCheckButtonPeer (cb);
|
---|
187 | */
|
---|
188 | }
|
---|
189 |
|
---|
190 | protected CheckboxMenuItemPeer createCheckboxMenuItem (CheckboxMenuItem cmi)
|
---|
191 | {
|
---|
192 | return null;
|
---|
193 | //return new GtkCheckboxMenuItemPeer (cmi);
|
---|
194 | }
|
---|
195 |
|
---|
196 | protected ChoicePeer createChoice (Choice c)
|
---|
197 | {
|
---|
198 | return null;
|
---|
199 | //return new GtkChoicePeer (c);
|
---|
200 | }
|
---|
201 |
|
---|
202 | protected DialogPeer createDialog (Dialog d)
|
---|
203 | {
|
---|
204 | return null;
|
---|
205 | //return new GtkDialogPeer (d);
|
---|
206 | }
|
---|
207 |
|
---|
208 | protected FileDialogPeer createFileDialog (FileDialog fd)
|
---|
209 | {
|
---|
210 | return null;
|
---|
211 | //return new GtkFileDialogPeer (fd);
|
---|
212 | }
|
---|
213 |
|
---|
214 | protected FramePeer createFrame (Frame f)
|
---|
215 | {
|
---|
216 | return new GtkFramePeer (f);
|
---|
217 | }
|
---|
218 |
|
---|
219 | protected LabelPeer createLabel (Label label)
|
---|
220 | {
|
---|
221 | return null;
|
---|
222 | //return new GtkLabelPeer (label);
|
---|
223 | }
|
---|
224 |
|
---|
225 | protected ListPeer createList (List list)
|
---|
226 | {
|
---|
227 | return null;
|
---|
228 | //return new GtkListPeer (list);
|
---|
229 | }
|
---|
230 |
|
---|
231 | protected MenuPeer createMenu (Menu m)
|
---|
232 | {
|
---|
233 | return null;
|
---|
234 | //return new GtkMenuPeer (m);
|
---|
235 | }
|
---|
236 |
|
---|
237 | protected MenuBarPeer createMenuBar (MenuBar mb)
|
---|
238 | {
|
---|
239 | return null;
|
---|
240 | //return new GtkMenuBarPeer (mb);
|
---|
241 | }
|
---|
242 |
|
---|
243 | protected MenuItemPeer createMenuItem (MenuItem mi)
|
---|
244 | {
|
---|
245 | return null;
|
---|
246 | //return new GtkMenuItemPeer (mi);
|
---|
247 | }
|
---|
248 |
|
---|
249 | protected PanelPeer createPanel (Panel p)
|
---|
250 | {
|
---|
251 | return null;
|
---|
252 | //return new GtkPanelPeer (p);
|
---|
253 | }
|
---|
254 |
|
---|
255 | protected PopupMenuPeer createPopupMenu (PopupMenu target)
|
---|
256 | {
|
---|
257 | return null;
|
---|
258 | //return new GtkPopupMenuPeer (target);
|
---|
259 | }
|
---|
260 |
|
---|
261 | protected ScrollPanePeer createScrollPane (ScrollPane sp)
|
---|
262 | {
|
---|
263 | return null;
|
---|
264 | //return new GtkScrollPanePeer (sp);
|
---|
265 | }
|
---|
266 |
|
---|
267 | protected ScrollbarPeer createScrollbar (Scrollbar sb)
|
---|
268 | {
|
---|
269 | return null;
|
---|
270 | //return new GtkScrollbarPeer (sb);
|
---|
271 | }
|
---|
272 |
|
---|
273 | protected TextAreaPeer createTextArea (TextArea ta)
|
---|
274 | {
|
---|
275 | return null;
|
---|
276 | //return new GtkTextAreaPeer (ta);
|
---|
277 | }
|
---|
278 |
|
---|
279 | protected TextFieldPeer createTextField (TextField tf)
|
---|
280 | {
|
---|
281 | return null;
|
---|
282 | //return new GtkTextFieldPeer (tf);
|
---|
283 | }
|
---|
284 |
|
---|
285 | protected WindowPeer createWindow (Window w)
|
---|
286 | {
|
---|
287 | return new GtkWindowPeer (w);
|
---|
288 | }
|
---|
289 |
|
---|
290 | protected FontPeer getFontPeer (String name, int style)
|
---|
291 | {
|
---|
292 | return null;
|
---|
293 | /*
|
---|
294 | try
|
---|
295 | {
|
---|
296 | GtkFontPeer fp = new GtkFontPeer (name, style);
|
---|
297 | return fp;
|
---|
298 | }
|
---|
299 | catch (MissingResourceException ex)
|
---|
300 | {
|
---|
301 | return null;
|
---|
302 | }
|
---|
303 | */
|
---|
304 | }
|
---|
305 |
|
---|
306 | protected EventQueue getSystemEventQueueImpl()
|
---|
307 | {
|
---|
308 | return GtkComponentPeer.eventQueue;
|
---|
309 | }
|
---|
310 |
|
---|
311 | protected void loadSystemColors (int[] systemColors)
|
---|
312 | {
|
---|
313 | }
|
---|
314 | }
|
---|