aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/awt/gtk/GtkToolkit.java
blob: 4173e5e9b4061df759025829cf333e5a1572ce74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
/* GtkToolkit.java -- Implements an AWT Toolkit using GTK for peers
   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.

This file is part of the peer AWT libraries of GNU Classpath.

This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published 
by the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation
Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA. */


package gnu.awt.gtk;

import java.awt.*;
import java.net.*;
import java.util.Hashtable;
import java.util.Properties;
import java.util.MissingResourceException;
import java.awt.datatransfer.*;
import java.awt.image.*;
import java.awt.peer.*;

public class GtkToolkit extends java.awt.Toolkit
{
  static GtkMainThread gtkthread;
  static EventQueue evtqueue;
  static Hashtable containers = new Hashtable();
  static Clipboard systemClipboard;
  static GtkToolkit instance = null;

  public GtkToolkit ()
  {
    gtkInit();
    instance = this;
    //systemClipboard = new GtkClipboard ();
  }
  
  // Start the thread to run the GTK event loop. This is called from 
  // a GtkComponentPeer static initializer.
  void init ()
  {
    gtkthread = new GtkMainThread ();
    gtkthread.start();
  }

  static native void gtkInit();
  
  native public void beep ();
  
  public int checkImage (Image image, int width, int height, 
			 ImageObserver observer) 
  {
    return ImageObserver.ALLBITS;

//      GtkImage i = (GtkImage) image;
//      return i.checkImage ();
  }

  public Image createImage(String filename)
  {
    return null;
  }

  public Image createImage(URL url)
  {
    return null;
  }

  public Image createImage (ImageProducer producer) 
  {
//    return new GtkImage (producer, null);
    return null;
  }

  public Image createImage (byte[] imagedata, int imageoffset,
			    int imagelength) 
  {
    System.out.println ("createImage byte[] NOT SUPPORTED");
    return null;
  }

  public ColorModel getColorModel () 
  {
    return ColorModel.getRGBdefault ();
  }

  public String[] getFontList () 
  {
    return (new String[] { "Dialog", 
			   "DialogInput", 
			   "Monospaced", 
			   "Serif", 
			   "SansSerif" });
  }

  public FontMetrics getFontMetrics (Font font) 
  {
//    return new GdkFontMetrics (font);
    return null;
  }

  public Image getImage (String filename) 
  {
//    return new GtkImage (new GdkPixbufDecoder (filename), null);
    return null;
  }

  public Image getImage (URL url) 
  {
//    return new GtkImage (new GdkPixbufDecoder (url), null);
    return null;
  }

  /*
  public PrintJob getPrintJob (Frame frame, String jobtitle, Properties props) 
  {
    return null;
  }
  */
  native public int getScreenResolution();

  native public Dimension getScreenSize ();

  public Clipboard getSystemClipboard() 
  {
    return systemClipboard;
  }

  public boolean prepareImage (Image image, int width, int height, 
			       ImageObserver observer) 
  {
    return false;
  }

  native public void sync ();

  protected void setComponentState (Component c, GtkComponentPeer cp)
  {      
    /* Make the Peer reflect the state of the Component */
    if (! (c instanceof Window))
      {
	cp.setCursor (c.getCursor ());
	
	Rectangle bounds = c.getBounds ();
	cp.setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
	if (c instanceof Canvas)
	  System.out.println ("width " + bounds.width + " height " + bounds.height);
	
	cp.setVisible (c.isVisible ());
      }
  }

  protected ButtonPeer createButton (Button b)
  {
    return null;
    /*    
    GtkButtonPeer bp = new GtkButtonPeer (b);
    Rectangle bounds = b.getBounds ();
    bp.setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
    return bp;
    */
  }

  protected CanvasPeer createCanvas (Canvas c) 
  {
//    return new GtkCanvasPeer (c);
    return null;
  }

  protected CheckboxPeer createCheckbox (Checkbox cb) 
  {
    return null;
    /*
    if (cb.getCheckboxGroup () != null)
      return new GtkRadioButtonPeer (cb);
    else
      return new GtkCheckButtonPeer (cb);
    */
  }

  protected CheckboxMenuItemPeer createCheckboxMenuItem (CheckboxMenuItem cmi)
  {
    return null;
    //return new GtkCheckboxMenuItemPeer (cmi);
  }

  protected ChoicePeer createChoice (Choice c) 
  {
    return null;
    //return new GtkChoicePeer (c);
  }

  protected DialogPeer createDialog (Dialog d)
  {
    return null;  
    //return new GtkDialogPeer (d);
  }

  protected FileDialogPeer createFileDialog (FileDialog fd)
  {
    return null;  
    //return new GtkFileDialogPeer (fd);
  }

  protected FramePeer createFrame (Frame f)
  {  
    return new GtkFramePeer (f);
  }

  protected LabelPeer createLabel (Label label) 
  {
    return null;
    //return new GtkLabelPeer (label);
  }

  protected ListPeer createList (List list)
  {
    return null;
    //return new GtkListPeer (list);
  }

  protected MenuPeer createMenu (Menu m) 
  {
    return null;
    //return new GtkMenuPeer (m);
  }

  protected MenuBarPeer createMenuBar (MenuBar mb) 
  {
    return null;
    //return new GtkMenuBarPeer (mb);
  }

  protected MenuItemPeer createMenuItem (MenuItem mi) 
  {
    return null;
    //return new GtkMenuItemPeer (mi);
  }

  protected PanelPeer createPanel (Panel p) 
  {
    return null;
    //return new GtkPanelPeer (p);
  }

  protected PopupMenuPeer createPopupMenu (PopupMenu target) 
  {
    return null;
    //return new GtkPopupMenuPeer (target);
  }

  protected ScrollPanePeer createScrollPane (ScrollPane sp) 
  {
    return null;
    //return new GtkScrollPanePeer (sp);
  }

  protected ScrollbarPeer createScrollbar (Scrollbar sb) 
  {
    return null;
    //return new GtkScrollbarPeer (sb);
  }

  protected TextAreaPeer createTextArea (TextArea ta) 
  {
    return null;
    //return new GtkTextAreaPeer (ta);
  }

  protected TextFieldPeer createTextField (TextField tf) 
  {
    return null;
    //return new GtkTextFieldPeer (tf);
  }

  protected WindowPeer createWindow (Window w)
  {
    return new GtkWindowPeer (w);
  }

  protected FontPeer getFontPeer (String name, int style) 
  {
    return null;
    /*
    try 
    {
      GtkFontPeer fp = new GtkFontPeer (name, style);
      return fp;
    } 
    catch (MissingResourceException ex) 
    {
      return null;
    }
    */
  }

  protected EventQueue getSystemEventQueueImpl() 
  {
    return GtkComponentPeer.eventQueue;
  }

  protected void loadSystemColors (int[] systemColors) 
  {
  }
}