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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [gnu/] [java/] [awt/] [peer/] [qt/] [QtToolkit.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* QtToolkit.java --
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
package gnu.java.awt.peer.qt;
39
 
40
import gnu.classpath.Configuration;
41
import gnu.java.awt.EmbeddedWindow;
42
import gnu.java.awt.peer.ClasspathFontPeer;
43
import gnu.java.awt.peer.EmbeddedWindowPeer;
44
import gnu.java.awt.peer.ClasspathTextLayoutPeer;
45
import java.awt.AWTEvent;
46
import java.awt.AWTException;
47
import java.awt.Button;
48
import java.awt.Canvas;
49
import java.awt.Checkbox;
50
import java.awt.CheckboxMenuItem;
51
import java.awt.Choice;
52
import java.awt.Component;
53
import java.awt.Dialog;
54
import java.awt.Dimension;
55
import java.awt.EventQueue;
56
import java.awt.Font;
57
import java.awt.FontMetrics;
58
import java.awt.Frame;
59
import java.awt.Image;
60
import java.awt.Label;
61
import java.awt.List;
62
import java.awt.MenuBar;
63
import java.awt.Menu;
64
import java.awt.MenuItem;
65
import java.awt.Panel;
66
import java.awt.TextArea;
67
import java.awt.TextField;
68
import java.awt.FileDialog;
69
import java.awt.GraphicsDevice;
70
import java.awt.GraphicsEnvironment;
71
import java.awt.HeadlessException;
72
import java.awt.PopupMenu;
73
import java.awt.PrintJob;
74
import java.awt.Scrollbar;
75
import java.awt.ScrollPane;
76
import java.awt.Toolkit;
77
import java.awt.Window;
78
import java.awt.datatransfer.Clipboard;
79
import java.awt.dnd.DragGestureEvent;
80
import java.awt.dnd.DragGestureListener;
81
import java.awt.dnd.DragGestureRecognizer;
82
import java.awt.dnd.DragSource;
83
import java.awt.dnd.peer.DragSourceContextPeer;
84
import java.awt.event.AWTEventListener;
85
import java.awt.image.ColorModel;
86
import java.awt.image.DirectColorModel;
87
import java.awt.image.ImageObserver;
88
import java.awt.image.ImageProducer;
89
import java.awt.im.InputMethodHighlight;
90
import java.awt.peer.ButtonPeer;
91
import java.awt.peer.FontPeer;
92
import java.awt.peer.PanelPeer;
93
import java.awt.peer.CanvasPeer;
94
import java.awt.peer.FramePeer;
95
import java.awt.peer.PopupMenuPeer;
96
import java.awt.peer.CheckboxMenuItemPeer;
97
import java.awt.peer.LabelPeer;
98
import java.awt.peer.RobotPeer;
99
import java.awt.peer.CheckboxPeer;
100
import java.awt.peer.LightweightPeer;
101
import java.awt.peer.ScrollPanePeer;
102
import java.awt.peer.ChoicePeer;
103
import java.awt.peer.ListPeer;
104
import java.awt.peer.ScrollbarPeer;
105
import java.awt.peer.ComponentPeer;
106
import java.awt.peer.MenuBarPeer;
107
import java.awt.peer.TextAreaPeer;
108
import java.awt.peer.ContainerPeer;
109
import java.awt.peer.MenuComponentPeer;
110
import java.awt.peer.TextComponentPeer;
111
import java.awt.peer.DialogPeer;
112
import java.awt.peer.MenuItemPeer;
113
import java.awt.peer.TextFieldPeer;
114
import java.awt.peer.FileDialogPeer;
115
import java.awt.peer.MenuPeer;
116
import java.awt.peer.WindowPeer;
117
import java.awt.font.FontRenderContext;
118
import java.io.InputStream;
119
import java.net.URL;
120
import java.text.AttributedString;
121
import java.util.HashMap;
122
import java.util.Map;
123
import java.util.Properties;
124
import javax.imageio.spi.IIORegistry;
125
 
126
import gnu.java.awt.ClasspathToolkit;
127
 
128
public class QtToolkit extends ClasspathToolkit
129
{
130
  public static EventQueue eventQueue = null; // the native event queue
131
  public static QtRepaintThread repaintThread = null;
132
  public static MainQtThread guiThread = null;
133
  public static QtGraphicsEnvironment graphicsEnv = null;
134
 
135
  private static void initToolkit()
136
  {
137
    eventQueue = new EventQueue();
138
    repaintThread = new QtRepaintThread();
139
    if (Configuration.INIT_LOAD_LIBRARY)
140
      System.loadLibrary("qtpeer");
141
 
142
    String theme = null;
143
    try
144
      {
145
        String style = System.getProperty("qtoptions.style");
146
        if(style != null)
147
          theme = style;
148
      }
149
    catch(SecurityException e)
150
      {
151
      }
152
    catch(IllegalArgumentException e)
153
      {
154
      }
155
 
156
    boolean doublebuffer = true;
157
    try
158
      {
159
        String style = System.getProperty("qtoptions.nodoublebuffer");
160
        if(style != null)
161
          doublebuffer = false;
162
      }
163
    catch(SecurityException e)
164
      {
165
      }
166
    catch(IllegalArgumentException e)
167
      {
168
      }
169
 
170
    guiThread = new MainQtThread( theme, doublebuffer );
171
    guiThread.start();
172
    repaintThread.start();
173
  }
174
 
175
  /**
176
   * Construct the toolkit!
177
   */
178
  public QtToolkit()
179
  {
180
    if( guiThread == null )
181
      initToolkit();
182
 
183
    while (!guiThread.isRunning()); // make sure the GUI thread has started.
184
 
185
    if( graphicsEnv == null )
186
      graphicsEnv = new QtGraphicsEnvironment( this );
187
  }
188
 
189
  native String[] nativeFontFamilies();
190
 
191
  native int numScreens();
192
 
193
  native int defaultScreen();
194
 
195
  // ************ Public methods *********************
196
 
197
  public synchronized native void beep();
198
 
199
  public int checkImage(Image image, int w, int h, ImageObserver observer)
200
  {
201
    if(image instanceof QtImage)
202
      return ((QtImage)image).checkImage(observer);
203
 
204
    return ImageObserver.ERROR; // FIXME
205
  }
206
 
207
  protected ButtonPeer createButton( Button target )
208
  {
209
    return new QtButtonPeer( this, target );
210
  }
211
 
212
  protected CanvasPeer createCanvas(Canvas target)
213
  {
214
    return new QtCanvasPeer( this, target );
215
  }
216
 
217
  protected CheckboxPeer createCheckbox(Checkbox target)
218
  {
219
    return new QtCheckboxPeer( this, target );
220
  }
221
 
222
  protected  ChoicePeer createChoice(Choice target)
223
  {
224
    return new QtChoicePeer( this, target );
225
  }
226
 
227
  protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
228
  {
229
    return new QtMenuItemPeer( this, target );
230
  }
231
 
232
  public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
233
  {
234
    throw new RuntimeException("Not implemented");
235
  }
236
 
237
  protected FramePeer createFrame(Frame target)
238
  {
239
    return new QtFramePeer( this, target );
240
  }
241
 
242
  protected FileDialogPeer createFileDialog(FileDialog target)
243
  {
244
    return new QtFileDialogPeer( this, target );
245
  }
246
 
247
  public Image createImage(ImageProducer producer)
248
  {
249
    return new QtImage( producer );
250
  }
251
 
252
  public Image createImage(byte[] imageData,
253
                           int imageOffset,
254
                           int imageLength)
255
  {
256
    byte[] dataCopy = new byte[imageLength];
257
    System.arraycopy(imageData, imageOffset, dataCopy, 0, imageLength);
258
    return new QtImage( dataCopy );
259
  }
260
 
261
  public Image createImage(String filename)
262
  {
263
    return new QtImage( filename );
264
  }
265
 
266
  public Image createImage(URL url)
267
  {
268
    return new QtImage( url );
269
  }
270
 
271
  protected TextFieldPeer createTextField(TextField target)
272
  {
273
    return new QtTextFieldPeer(this,target);
274
  }
275
 
276
  protected LabelPeer createLabel(Label target)
277
  {
278
    return new QtLabelPeer( this, target );
279
  }
280
 
281
  protected ListPeer createList(List target)
282
  {
283
    return new QtListPeer( this, target );
284
  }
285
 
286
  protected ScrollbarPeer createScrollbar(Scrollbar target)
287
  {
288
    return new QtScrollbarPeer( this, target );
289
  }
290
 
291
  protected ScrollPanePeer createScrollPane(ScrollPane target)
292
  {
293
    return new QtScrollPanePeer( this, target );
294
  }
295
 
296
  protected TextAreaPeer createTextArea(TextArea target)
297
  {
298
    return new QtTextAreaPeer( this, target );
299
  }
300
 
301
  protected PanelPeer createPanel(Panel target)
302
  {
303
    return new QtPanelPeer( this, target);
304
  }
305
 
306
  protected WindowPeer createWindow(Window target)
307
  {
308
    return new QtWindowPeer( this, target );
309
  }
310
 
311
  protected DialogPeer createDialog(Dialog target)
312
  {
313
    return new QtDialogPeer( this, target );
314
  }
315
 
316
  protected MenuBarPeer createMenuBar(MenuBar target)
317
  {
318
    return new QtMenuBarPeer( this, target );
319
  }
320
 
321
  protected MenuPeer createMenu(Menu target)
322
  {
323
    return new QtMenuPeer( this, target );
324
  }
325
 
326
  protected PopupMenuPeer createPopupMenu(PopupMenu target)
327
  {
328
    return new QtPopupMenuPeer( this, target );
329
  }
330
 
331
  protected MenuItemPeer createMenuItem(MenuItem target)
332
  {
333
    return new QtMenuItemPeer( this, target );
334
  }
335
 
336
  /**
337
   * @since 1.4
338
   */
339
  public AWTEventListener[] getAWTEventListeners()
340
  {
341
    return null; // FIXME
342
  }
343
 
344
  /**
345
   * @since 1.4
346
   */
347
  public AWTEventListener[] getAWTEventListeners(long mask)
348
  {
349
    return null; // FIXME
350
  }
351
 
352
  public ColorModel getColorModel()
353
  {
354
    return new DirectColorModel(32,
355
                                0x00FF0000,
356
                                0x0000FF00,
357
                                0x000000FF,
358
                                0xFF000000);
359
  }
360
 
361
  /**
362
   * Just return the defaults.
363
   */
364
  public String[] getFontList()
365
  {
366
    String[] builtIn = new String[] { "Dialog",
367
                                      "DialogInput",
368
                                      "Monospaced",
369
                                      "Serif",
370
                                      "SansSerif" };
371
    String[] nat = nativeFontFamilies();
372
    String[] allFonts = new String[ nat.length + 5 ];
373
    System.arraycopy(builtIn, 0, allFonts, 0, 5);
374
    System.arraycopy(nat, 0, allFonts, 5, nat.length);
375
    return allFonts;
376
  }
377
 
378
  public FontMetrics getFontMetrics(Font font)
379
  {
380
    return new QtFontMetrics(font);
381
  }
382
 
383
  protected FontPeer getFontPeer(String name,
384
                                 int style)
385
  {
386
    Map attrs = new HashMap ();
387
    ClasspathFontPeer.copyStyleToAttrs(style, attrs);
388
    ClasspathFontPeer.copySizeToAttrs(12, attrs); // Default size is 12.
389
    return getClasspathFontPeer (name, attrs);
390
  }
391
 
392
  public Image getImage(String filename)
393
  {
394
    return new QtImage(filename);
395
  }
396
 
397
  public Image getImage(URL url)
398
  {
399
    return createImage( url );
400
  }
401
 
402
  public PrintJob getPrintJob(Frame frame,
403
                              String jobtitle,
404
                              Properties props)
405
  {
406
    throw new RuntimeException("Not implemented");
407
  }
408
 
409
  public Clipboard getSystemClipboard()
410
  {
411
    throw new RuntimeException("Not implemented");
412
  }
413
 
414
  protected EventQueue getSystemEventQueueImpl()
415
  {
416
    return eventQueue;
417
  }
418
 
419
  public native Dimension getScreenSize();
420
 
421
  public native int getScreenResolution();
422
 
423
  public Map mapInputMethodHighlight(InputMethodHighlight highlight)
424
  {
425
    return null; // FIXME
426
  }
427
 
428
  public boolean prepareImage(Image image, int w, int h, ImageObserver observer)
429
  {
430
    if(image instanceof QtImage)
431
      return true;
432
    return false; // FIXME?
433
  }
434
 
435
  public native void sync();
436
 
437
  // ********************** ClasspathToolkit methods
438
 
439
  public GraphicsEnvironment getLocalGraphicsEnvironment()
440
  {
441
    return graphicsEnv;
442
  }
443
 
444
  public ClasspathFontPeer getClasspathFontPeer (String name, Map attrs)
445
  {
446
    return new QtFontPeer (name, attrs);
447
  }
448
 
449
  public ClasspathTextLayoutPeer getClasspathTextLayoutPeer(AttributedString str,
450
                                                            FontRenderContext frc)
451
  {
452
    return null;
453
  }
454
 
455
  // FIXME
456
  public Font createFont(int format, InputStream stream)
457
  {
458
    throw new UnsupportedOperationException();
459
  }
460
 
461
  // FIXME
462
  public RobotPeer createRobot (GraphicsDevice screen) throws AWTException
463
  {
464
    throw new UnsupportedOperationException();
465
  }
466
 
467
  public EmbeddedWindowPeer createEmbeddedWindow(EmbeddedWindow w)
468
  {
469
    //    return new QtEmbeddedWindowPeer( this, w );
470
    return null;
471
  }
472
}

powered by: WebSVN 2.1.0

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