Source Code Cross Referenced for QtToolkit.java in  » 6.0-JDK-Modules » j2me » sun » awt » qt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » sun.awt.qt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)QtToolkit.java	1.46 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation. 
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt). 
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA 
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions. 
025:         *
026:         */
027:        package sun.awt.qt;
028:
029:        import java.awt.*;
030:        import sun.awt.peer.*;
031:        import java.awt.image.*;
032:        import java.net.*;
033:        import java.awt.datatransfer.Clipboard;
034:        import sun.awt.PeerBasedToolkit;
035:        import sun.awt.im.*;
036:        import sun.awt.AppContext;
037:        import sun.awt.image.BufferedImagePeer;
038:        import sun.awt.image.ImageDecoderFactory;
039:
040:        public class QtToolkit extends PeerBasedToolkit implements  Runnable {
041:            private static native void initIDs();
042:
043:            ////////////////////////////////////
044:            // Begin of CDC Ams modification. //
045:            ////////////////////////////////////
046:
047:            private static Class amsClazz = null;
048:
049:            private static Object lock = new Object();
050:
051:            private static boolean amsInited = false;
052:
053:            private static java.lang.reflect.Method gotoHomeScreen;
054:
055:            private static java.lang.reflect.Method gotoNextApp;
056:
057:            /*
058:             * Convenience functions to allow the CDCAmsLifecycleService
059:             * methods be invoked in the event dispatch thread.
060:             */
061:
062:            private static void amsInit() {
063:                synchronized (lock) {
064:                    if (!amsInited) {
065:                        try {
066:                            amsClazz = Class
067:                                    .forName("com.sun.appmanager.impl.client.CDCAmsLifecycleService");
068:                            gotoHomeScreen = amsClazz.getDeclaredMethod(
069:                                    "gotoHomeScreen", new Class[] {});
070:                            gotoNextApp = amsClazz.getDeclaredMethod(
071:                                    "gotoNextApp", new Class[] {});
072:                        } catch (Exception e) {
073:                            e.printStackTrace();
074:                        }
075:                        amsInited = true;
076:                    }
077:                }
078:            }
079:
080:            // Called from QtToolkit.cc.
081:            private static void gotoHomeScreenEDT() {
082:                amsInit();
083:                if (amsClazz != null) {
084:                    java.awt.EventQueue.invokeLater(new Runnable() {
085:                        public void run() {
086:                            try {
087:                                gotoHomeScreen.invoke(null, new Object[] {});
088:                            } catch (Exception e) {
089:                                e.printStackTrace();
090:                            }
091:                        }
092:                    });
093:                }
094:            }
095:
096:            // Called from QtToolkit.cc.
097:            private static void gotoNextAppEDT() {
098:                amsInit();
099:                if (amsClazz != null) {
100:                    java.awt.EventQueue.invokeLater(new Runnable() {
101:                        public void run() {
102:                            try {
103:                                gotoNextApp.invoke(null, new Object[] {});
104:                            } catch (Exception e) {
105:                                e.printStackTrace();
106:                            }
107:                        }
108:                    });
109:                }
110:            }
111:
112:            native void synthesizeFocusIn(QtWindowPeer windowPeer);
113:
114:            /**
115:             *  Show the specified window in a multi-vm environment
116:             */
117:            public void activate(Window window) {
118:                if (window == null) {
119:                    return;
120:                }
121:                window.setVisible(true);
122:
123:                // synthesizeFocusIn is only useful on the zaurus, where doing a hide(),
124:                // then show() doesn't produce a Focus In event.  This is most likely due
125:                // to the QPE desktop.
126:                QtWindowPeer peer = (QtWindowPeer) QtToolkit
127:                        .getComponentPeer(window);
128:                if (peer != null) {
129:                    synthesizeFocusIn(peer);
130:                }
131:            }
132:
133:            /**
134:             *  Hide the specified window in a multi-vm environment
135:             */
136:            public void deactivate(Window window) {
137:                if (window == null) {
138:                    return;
139:                }
140:                window.setVisible(false);
141:            }
142:
143:            //////////////////////////////////
144:            // End of CDC Ams modification. //
145:            //////////////////////////////////
146:
147:            public static String getAppName() {
148:                return System.getProperty("appName");
149:            }
150:
151:            private Clipboard systemClipboard;
152:
153:            private QtWindowPeer mainWidgetPeer = null;
154:
155:            private ColorModel toolkitColorModel = null;
156:
157:            static boolean smw;
158:
159:            static {
160:                smw = "true".equals(System
161:                        .getProperty("sun.awt.qt.setMainWidget"));
162:            }
163:
164:            void setMainWidget(QtWindowPeer mainWidgetPeer) {
165:                if (smw) {
166:                    setMainWidgetNative(mainWidgetPeer);
167:                }
168:            }
169:
170:            private native void setMainWidgetNative(QtWindowPeer mainWidgetPeer);
171:
172:            protected native void finalize() throws Throwable;
173:
174:            /** Runs the qt_main function for event processing. */
175:
176:            public void run() {
177:                while (true) {
178:                    synchronized (this ) {
179:                        if (!appInit) {
180:                            createNativeApp();
181:                            appInit = true;
182:                            this .notifyAll();
183:                        }
184:                    }
185:
186:                    // 6224133: PP-TCK interactive hangs after running long batch tests.
187:                    // On Qt/X11, the session manager sends a QUIT command to the
188:                    // QApplication after a long delay.  Therefore, we start the event
189:                    // loop without any further delay.
190:                    /*
191:                    synchronized(this) {
192:                    if (!run) {
193:                    try {
194:                    this.wait();
195:                    } catch (InterruptedException e) {
196:                    e.printStackTrace();
197:                    }
198:                    }
199:                    }
200:                     */
201:                    // 6224133.
202:                    runNative();
203:
204:                    // 6176847
205:                    // if the loop was terminated due to a shutdown sequence, exit 
206:                    // the thread
207:                    if (this .shutdown)
208:                        break;
209:                    // 6176847
210:
211:                    // 6224133.
212:                    // No longer needed.
213:                    /*
214:                    synchronized(this) {
215:                    run = false;
216:                    }
217:                     */
218:                    // 6224133.
219:                }
220:            }
221:
222:            private boolean appInit = false;
223:            // 6224133.
224:            // No longer needed.
225:            // private boolean run = false;
226:            // 6224133.
227:            private boolean shutdown = false; // 6176847
228:
229:            // 6224133.
230:            // No longer needed.
231:            /*
232:            synchronized void setRun(boolean b) 
233:            {
234:            this.run = b;
235:            this.notifyAll();
236:            }
237:             */
238:            // 6224133.
239:            private native void createNativeApp();
240:
241:            private native void runNative();
242:
243:            private native void shutdownEventLoop(); // 6176847
244:
245:            static {
246:                java.security.AccessController
247:                        .doPrivileged(new sun.security.action.LoadLibraryAction(
248:                                "qtawt"));
249:                initIDs();
250:            }
251:
252:            /**
253:             * Installs the <code>QtImageDecoderFactory</code> as the 
254:             * <code>ImageDecoderFactory</code>, provided the application has not
255:             * disabled it using the system property
256:             * <b>sun.awt.qt.img.decoder.factory.enable=false</b>. 
257:             * <p>
258:             * This is invoked from <code>QtToolkit.initIDs()</code> if the 
259:             * platform we are running supports native image decoders.
260:             *
261:             * @param formats Image formats supported by QT
262:             */
263:            private static void installImageDecoderFactory(String[] formats) {
264:                if ("true".equals(System.getProperty(
265:                        "sun.awt.qt.img.decoder.factory.enable", "true"))) {
266:                    QtImageDecoderFactory factory = new QtImageDecoderFactory(
267:                            formats);
268:                    ImageDecoderFactory.setFactory(factory);
269:                }
270:            }
271:
272:            public QtToolkit() {
273:                super ();
274:
275:                // Create a thread for processing main Qt events.
276:                Thread mainThread = new Thread(this , "AWT-Qt");
277:                mainThread.setDaemon(false); // Don't exit when main finishes.
278:                mainThread.start();
279:
280:                synchronized (this ) {
281:                    while (this .appInit == false) {
282:                        try {
283:                            this .wait();
284:                        } catch (InterruptedException e) {
285:                            e.printStackTrace();
286:                        }
287:                    }
288:                }
289:
290:                systemClipboard = new QtClipboard("system");
291:
292:                // 6176847	
293:                // Add a shutdown hook so that we can shutdown the qt event loop
294:                // before the application shuts down.
295:                Runtime.getRuntime().addShutdownHook(new Thread() {
296:                    public void run() {
297:                        QtToolkit.this .shutdown = true;
298:                        shutdownEventLoop();
299:                        QtToolkit.cleanup(); //6228133
300:                    }
301:                });
302:                // 6176847	
303:            }
304:
305:            /*
306:             * 6228133
307:             *
308:             * Called by the shutdown hook callback when the VM is shutting down.
309:             * Cleans up and code required before VM shutdown.
310:             */
311:            static private void cleanup() {
312:                QtFontPeer.cleanup();
313:            }
314:
315:            static native BufferedImagePeer getBufferedImagePeer(
316:                    BufferedImage image);
317:
318:            static native BufferedImage createBufferedImage(
319:                    BufferedImagePeer peer);
320:
321:            /*
322:             * Gets the default encoding used on the current platform
323:             * to transfer text (character) data. 
324:             */
325:            public String getDefaultCharacterEncoding() {
326:                return "iso8859-1";
327:            }
328:
329:            /**
330:             * Creates this toolkit's implementation of <code>Button</code> using
331:             * the specified peer interface.
332:             * @param     target the button to be implemented.
333:             * @return    this toolkit's implementation of <code>Button</code>.
334:             * @see       java.awt.Button
335:             * @see       java.awt.peer.ButtonPeer
336:             * @since     JDK1.0
337:             */
338:            public ButtonPeer createButton(Button target) {
339:                QtButtonPeer bp = new QtButtonPeer(this , target);
340:                // add a check to see if we need to set focusable to false on the 
341:                // native peer.  This needs to be added for all components
342:                if (!target.isFocusable()) {
343:                    bp.setFocusable(false);
344:                }
345:                return (ButtonPeer) bp;
346:            }
347:
348:            /**
349:             * Creates this toolkit's implementation of <code>TextField</code> using
350:             * the specified peer interface.
351:             * @param     target the text field to be implemented.
352:             * @return    this toolkit's implementation of <code>TextField</code>.
353:             * @see       java.awt.TextField
354:             * @see       java.awt.peer.TextFieldPeer
355:             * @since     JDK1.0
356:             */
357:            public TextFieldPeer createTextField(TextField target) {
358:                return new QtTextFieldPeer(this , target);
359:            }
360:
361:            /**
362:             * Creates this toolkit's implementation of <code>Label</code> using
363:             * the specified peer interface.
364:             * @param     target the label to be implemented.
365:             * @return    this toolkit's implementation of <code>Label</code>.
366:             * @see       java.awt.Label
367:             * @see       java.awt.peer.LabelPeer
368:             * @since     JDK1.0
369:             */
370:            public LabelPeer createLabel(Label target) {
371:                return new QtLabelPeer(this , target);
372:            }
373:
374:            /**
375:             * Creates this toolkit's implementation of <code>List</code> using
376:             * the specified peer interface.
377:             * @param     target the list to be implemented.
378:             * @return    this toolkit's implementation of <code>List</code>.
379:             * @see       java.awt.List
380:             * @see       java.awt.peer.ListPeer
381:             * @since     JDK1.0
382:             */
383:            public ListPeer createList(List target) {
384:                return new QtListPeer(this , target);
385:            }
386:
387:            /**
388:             * Creates this toolkit's implementation of <code>Checkbox</code> using
389:             * the specified peer interface.
390:             * @param     target the check box to be implemented.
391:             * @return    this toolkit's implementation of <code>Checkbox</code>.
392:             * @see       java.awt.Checkbox
393:             * @see       java.awt.peer.CheckboxPeer
394:             * @since     JDK1.0
395:             */
396:            public CheckboxPeer createCheckbox(Checkbox target) {
397:                return new QtCheckboxPeer(this , target);
398:            }
399:
400:            /**
401:             * Creates this toolkit's implementation of <code>Scrollbar</code> using
402:             * the specified peer interface.
403:             * @param     target the scroll bar to be implemented.
404:             * @return    this toolkit's implementation of <code>Scrollbar</code>.
405:             * @see       java.awt.Scrollbar
406:             * @see       java.awt.peer.ScrollbarPeer
407:             * @since     JDK1.0
408:             */
409:            public ScrollbarPeer createScrollbar(Scrollbar target) {
410:                return new QtScrollbarPeer(this , target);
411:            }
412:
413:            /**
414:             * Creates this toolkit's implementation of <code>ScrollPane</code> using
415:             * the specified peer interface.
416:             * @param     target the scroll pane to be implemented.
417:             * @return    this toolkit's implementation of <code>ScrollPane</code>.
418:             * @see       java.awt.ScrollPane
419:             * @see       java.awt.peer.ScrollPanePeer
420:             * @since     JDK1.1
421:             */
422:            public ScrollPanePeer createScrollPane(ScrollPane target) {
423:                return new QtScrollPanePeer(this , target);
424:            }
425:
426:            /**
427:             * Creates this toolkit's implementation of <code>TextArea</code> using
428:             * the specified peer interface.
429:             * @param     target the text area to be implemented.
430:             * @return    this toolkit's implementation of <code>TextArea</code>.
431:             * @see       java.awt.TextArea
432:             * @see       java.awt.peer.TextAreaPeer
433:             * @since     JDK1.0
434:             */
435:            public TextAreaPeer createTextArea(TextArea target) {
436:                return new QtTextAreaPeer(this , target);
437:            }
438:
439:            /**
440:             * Creates this toolkit's implementation of <code>Choice</code> using
441:             * the specified peer interface.
442:             * @param     target the choice to be implemented.
443:             * @return    this toolkit's implementation of <code>Choice</code>.
444:             * @see       java.awt.Choice
445:             * @see       java.awt.peer.ChoicePeer
446:             * @since     JDK1.0
447:             */
448:            public ChoicePeer createChoice(Choice target) {
449:                return new QtChoicePeer(this , target);
450:            }
451:
452:            /**
453:             * Creates this toolkit's implementation of <code>Frame</code> using
454:             * the specified peer interface.
455:             * @param     target the frame to be implemented.
456:             * @return    this toolkit's implementation of <code>Frame</code>.
457:             * @see       java.awt.Frame
458:             * @see       java.awt.peer.FramePeer
459:             * @since     JDK1.0
460:             */
461:            public FramePeer createFrame(Frame target) {
462:                return new QtFramePeer(this , target);
463:            }
464:
465:            /**
466:             * Creates this toolkit's implementation of <code>Canvas</code> using
467:             * the specified peer interface.
468:             * @param     target the canvas to be implemented.
469:             * @return    this toolkit's implementation of <code>Canvas</code>.
470:             * @see       java.awt.Canvas
471:             * @see       java.awt.peer.CanvasPeer
472:             * @since     JDK1.0
473:             */
474:            public CanvasPeer createCanvas(Canvas target) {
475:                return new QtCanvasPeer(this , target);
476:            }
477:
478:            /**
479:             * Creates this toolkit's implementation of <code>Panel</code> using
480:             * the specified peer interface.
481:             * @param     target the panel to be implemented.
482:             * @return    this toolkit's implementation of <code>Panel</code>.
483:             * @see       java.awt.Panel
484:             * @see       java.awt.peer.PanelPeer
485:             * @since     JDK1.0
486:             */
487:            public PanelPeer createPanel(Panel target) {
488:                return new QtPanelPeer(this , target);
489:            }
490:
491:            /**
492:             * Creates this toolkit's implementation of <code>Window</code> using
493:             * the specified peer interface.
494:             * @param     target the window to be implemented.
495:             * @return    this toolkit's implementation of <code>Window</code>.
496:             * @see       java.awt.Window
497:             * @see       java.awt.peer.WindowPeer
498:             * @since     JDK1.0
499:             */
500:            public WindowPeer createWindow(Window target) {
501:                return new QtWindowPeer(this , target);
502:            }
503:
504:            /**
505:             * Creates this toolkit's implementation of <code>Dialog</code> using
506:             * the specified peer interface.
507:             * @param     target the dialog to be implemented.
508:             * @return    this toolkit's implementation of <code>Dialog</code>.
509:             * @see       java.awt.Dialog
510:             * @see       java.awt.peer.DialogPeer
511:             * @since     JDK1.0
512:             */
513:            public DialogPeer createDialog(Dialog target) {
514:                return new QtDialogPeer(this , target);
515:            }
516:
517:            /**
518:             * Creates this toolkit's implementation of <code>MenuBar</code> using
519:             * the specified peer interface.
520:             * @param     target the menu bar to be implemented.
521:             * @return    this toolkit's implementation of <code>MenuBar</code>.
522:             * @see       java.awt.MenuBar
523:             * @see       java.awt.peer.MenuBarPeer
524:             * @since     JDK1.0
525:             */
526:            public MenuBarPeer createMenuBar(MenuBar target) {
527:                return new QtMenuBarPeer(target);
528:            }
529:
530:            /**
531:             * Creates this toolkit's implementation of <code>Menu</code> using
532:             * the specified peer interface.
533:             * @param     target the menu to be implemented.
534:             * @return    this toolkit's implementation of <code>Menu</code>.
535:             * @see       java.awt.Menu
536:             * @see       java.awt.peer.MenuPeer
537:             * @since     JDK1.0
538:             */
539:            public MenuPeer createMenu(Menu target) {
540:                return new QtMenuPeer(target);
541:            }
542:
543:            /**
544:             * Creates this toolkit's implementation of <code>PopupMenu</code> using
545:             * the specified peer interface.
546:             * @param     target the popup menu to be implemented.
547:             * @return    this toolkit's implementation of <code>PopupMenu</code>.
548:             * @see       java.awt.PopupMenu
549:             * @see       java.awt.peer.PopupMenuPeer
550:             * @since     JDK1.1
551:             */
552:            public PopupMenuPeer createPopupMenu(PopupMenu target) {
553:                return new QtPopupMenuPeer(target);
554:            }
555:
556:            /**
557:             * Creates this toolkit's implementation of <code>MenuItem</code> using
558:             * the specified peer interface.
559:             * @param     target the menu item to be implemented.
560:             * @return    this toolkit's implementation of <code>MenuItem</code>.
561:             * @see       java.awt.MenuItem
562:             * @see       java.awt.peer.MenuItemPeer
563:             * @since     JDK1.0
564:             */
565:            public MenuItemPeer createMenuItem(MenuItem target) {
566:                return new QtMenuItemPeer(target);
567:            }
568:
569:            /**
570:             * Creates this toolkit's implementation of <code>FileDialog</code> using
571:             * the specified peer interface.
572:             * @param     target the file dialog to be implemented.
573:             * @return    this toolkit's implementation of <code>FileDialog</code>.
574:             * @see       java.awt.FileDialog
575:             * @see       java.awt.peer.FileDialogPeer
576:             * @since     JDK1.0
577:             */
578:            public FileDialogPeer createFileDialog(FileDialog target) {
579:                return new QtFileDialogPeer(this , target);
580:            }
581:
582:            /**
583:             * Creates this toolkit's implementation of <code>CheckboxMenuItem</code> using
584:             * the specified peer interface.
585:             * @param     target the checkbox menu item to be implemented.
586:             * @return    this toolkit's implementation of <code>CheckboxMenuItem</code>.
587:             * @see       java.awt.CheckboxMenuItem
588:             * @see       java.awt.peer.CheckboxMenuItemPeer
589:             * @since     JDK1.0
590:             */
591:            public CheckboxMenuItemPeer createCheckboxMenuItem(
592:                    CheckboxMenuItem target) {
593:                return new QtCheckboxMenuItemPeer(target);
594:            }
595:
596:            /**
597:             * Creates this toolkit's implementation of <code>Font</code> using
598:             * the specified peer interface.
599:             * @param     target the font to be implemented.
600:             * @return    this toolkit's implementation of <code>Font</code>.
601:             * @see       java.awt.Font
602:             * @see       java.awt.peer.FontPeer
603:             * @since     JDK1.0
604:             */
605:            public FontPeer getFontPeer(Font target) {
606:                return QtFontPeer.getFontPeer(target);
607:            }
608:
609:            public Insets getScreenInsets(GraphicsConfiguration gc) {
610:                return new Insets(0, 0, 0, 0);
611:            }
612:
613:            /**
614:             * Fills in the integer array that is supplied as an argument
615:             * with the current system color values.
616:             * <p>
617:             * This method is called by the method <code>updateSystemColors</code>
618:             * in the <code>SystemColor</code> class.
619:             * @param     an integer array.
620:             * @see       java.awt.SystemColor#updateSystemColors
621:             * @since     JDK1.1
622:             */
623:            protected void loadSystemColors(int[] systemColors) {
624:            }
625:
626:            public native int getScreenWidth();
627:
628:            public native int getScreenHeight();
629:
630:            /**
631:             * Returns the screen resolution in dots-per-inch.
632:             * @return    this toolkit's screen resolution, in dots-per-inch.
633:             * @since     JDK1.0
634:             */
635:            public int getScreenResolution() {
636:                return getScreenResolutionNative();
637:            }
638:
639:            protected native int getScreenResolutionNative();
640:
641:            /**
642:             * Determines the color model of this toolkit's screen.
643:             * <p>
644:             * <code>ColorModel</code> is an abstract class that
645:             * encapsulates the ability to translate between the
646:             * pixel values of an image and its red, green, blue,
647:             * and alpha components.
648:             * <p>
649:             * This toolkit method is called by the
650:             * <code>getColorModel</code> method
651:             * of the <code>Component</code> class.
652:             * @return    the color model of this toolkit's screen.
653:             * @see       java.awt.image.ColorModel
654:             * @see       java.awt.Component#getColorModel
655:             * @since     JDK1.0
656:             */
657:            public ColorModel getColorModel() {
658:                if (this .toolkitColorModel == null) {
659:                    this .toolkitColorModel = getColorModelNative();
660:                }
661:
662:                return this .toolkitColorModel;
663:            }
664:
665:            private native ColorModel getColorModelNative();
666:
667:            /**
668:             * Gets the screen metrics of the font.
669:             * @param     font   a font.
670:             * @return    the screen metrics of the specified font in this toolkit.
671:             * @since     JDK1.0
672:             */
673:            public FontMetrics getFontMetrics(Font font) {
674:                return (FontMetrics) QtFontPeer.getFontPeer(font);
675:            }
676:
677:            /**
678:             * Synchronizes this toolkit's graphics state. Some window systems
679:             * may do buffering of graphics events.
680:             * <p>
681:             * This method ensures that the display is up-to-date. It is useful
682:             * for animation.
683:             * @since     JDK1.0
684:             */
685:            public native void sync();
686:
687:            /**
688:             * Prepares an image for rendering.
689:             * <p>
690:             * If the values of the width and height arguments are both
691:             * <code>-1</code>, this method prepares the image for rendering
692:             * on the default screen; otherwise, this method prepares an image
693:             * for rendering on the default screen at the specified width and height.
694:             * <p>
695:             * The image data is downloaded asynchronously in another thread,
696:             * and an appropriately scaled screen representation of the image is
697:             * generated.
698:             * <p>
699:             * This method is called by components <code>prepareImage</code>
700:             * methods.
701:             * <p>
702:             * Information on the flags returned by this method can be found
703:             * with the definition of the <code>ImageObserver</code> interface.
704:
705:             * @param     image      the image for which to prepare a
706:             *                           screen representation.
707:             * @param     width      the width of the desired screen
708:             *                           representation, or <code>-1</code>.
709:             * @param     height     the height of the desired screen
710:             *                           representation, or <code>-1</code>.
711:             * @param     observer   the <code>ImageObserver</code>
712:             *                           object to be notified as the
713:             *                           image is being prepared.
714:             * @return    <code>true</code> if the image has already been
715:             *                 fully prepared; <code>false</code> otherwise.
716:             * @see       java.awt.Component#prepareImage(java.awt.Image,
717:             *                 java.awt.image.ImageObserver)
718:             * @see       java.awt.Component#prepareImage(java.awt.Image,
719:             *                 int, int, java.awt.image.ImageObserver)
720:             * @see       java.awt.image.ImageObserver
721:             * @since     JDK1.0
722:             */
723:            static boolean prepareScrImage(Image img, int w, int h,
724:                    ImageObserver o) {
725:                if (w == 0 || h == 0) {
726:                    return true;
727:                }
728:                QtImage ximg = (QtImage) img;
729:                if (ximg.hasError()) {
730:                    if (o != null) {
731:                        o.imageUpdate(img, ImageObserver.ERROR
732:                                | ImageObserver.ABORT, -1, -1, -1, -1);
733:                    }
734:                    return false;
735:                }
736:                sun.awt.image.ImageRepresentation ir = ximg.getImageRep();
737:                return ir.prepare(o);
738:            }
739:
740:            static int checkScrImage(Image img, int w, int h, ImageObserver o) {
741:
742:                if (!(img instanceof  QtImage)) {
743:                    return ImageObserver.ALLBITS;
744:                }
745:
746:                QtImage ximg = (QtImage) img;
747:                int repbits;
748:                if (w == 0 || h == 0) {
749:                    repbits = ImageObserver.ALLBITS;
750:                } else {
751:                    repbits = ximg.getImageRep().check(o);
752:                }
753:                return ximg.check(o) | repbits;
754:            }
755:
756:            public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
757:                if (img == null)
758:                    throw new NullPointerException("image can't be null");
759:                return prepareScrImage(img, w, h, o);
760:            }
761:
762:            /**
763:             * Indicates the construction status of a specified image that is
764:             * being prepared for display.
765:             * <p>
766:             * If the values of the width and height arguments are both
767:             * <code>-1</code>, this method returns the construction status of
768:             * a screen representation of the specified image in this toolkit.
769:             * Otherwise, this method returns the construction status of a
770:             * scaled representation of the image at the specified width
771:             * and height.
772:             * <p>
773:             * This method does not cause the image to begin loading.
774:             * An application must call <code>prepareImage</code> to force
775:             * the loading of an image.
776:             * <p>
777:             * This method is called by the component's <code>checkImage</code>
778:             * methods.
779:             * <p>
780:             * Information on the flags returned by this method can be found
781:             * with the definition of the <code>ImageObserver</code> interface.
782:             * @param     image   the image whose status is being checked.
783:             * @param     width   the width of the scaled version whose status is
784:             *                 being checked, or <code>-1</code>.
785:             * @param     height  the height of the scaled version whose status
786:             *                 is being checked, or <code>-1</code>.
787:             * @param     observer   the <code>ImageObserver</code> object to be
788:             *                 notified as the image is being prepared.
789:             * @return    the bitwise inclusive <strong>OR</strong> of the
790:             *                 <code>ImageObserver</code> flags for the
791:             *                 image data that is currently available.
792:             * @see       java.awt.Toolkit#prepareImage(java.awt.Image,
793:             *                 int, int, java.awt.image.ImageObserver)
794:             * @see       java.awt.Component#checkImage(java.awt.Image,
795:             *                 java.awt.image.ImageObserver)
796:             * @see       java.awt.Component#checkImage(java.awt.Image,
797:             *                 int, int, java.awt.image.ImageObserver)
798:             * @see       java.awt.image.ImageObserver
799:             * @since     JDK1.0
800:             */
801:            public int checkImage(Image img, int w, int h, ImageObserver o) {
802:                if (img == null)
803:                    throw new NullPointerException("image can't be null");
804:                return checkScrImage(img, w, h, o);
805:            }
806:
807:            /**
808:             * Creates an image with the specified image producer.
809:             * @param     producer the image producer to be used.
810:             * @return    an image with the specified image producer.
811:             * @see       java.awt.Image
812:             * @see       java.awt.image.ImageProducer
813:             * @see       java.awt.Component#createImage(java.awt.image.ImageProducer)
814:             * @since     JDK1.0
815:             */
816:            public Image createImage(ImageProducer producer) {
817:                return new QtImage(producer);
818:            }
819:
820:            /**
821:             * Gets a <code>PrintJob</code> object which is the result
822:             * of initiating a print operation on the toolkit's platform.
823:             * @return    a <code>PrintJob</code> object, or
824:             *                  <code>null</code> if the user
825:             *                  cancelled the print job.
826:             * @see       java.awt.PrintJob
827:             * @since     JDK1.1
828:             */
829:            /*
830:            public PrintJob getPrintJob(Frame frame, String jobtitle,
831:            			Properties props) 
832:            {
833:            throw new UnsupportedOperationException ();
834:            }
835:             */
836:
837:            /**
838:             * Emits an audio beep.
839:             * @since     JDK1.1
840:             */
841:            public native void beep();
842:
843:            public static void postEvent(AWTEvent event) {
844:                // Note that this might cause some problem in the future.
845:                // In jdk's MToolkit, targetToAppContext() is called at a peer level
846:                // with the peer's target as an argument.  AWTEvent's source is not
847:                // always the same as the peer's target.
848:
849:                postEvent(targetToAppContext(event.getSource()), event);
850:            }
851:
852:            public static void postEvent(AppContext appContext, AWTEvent event) {
853:                if (appContext == null) {
854:                    appContext = AppContext.getAppContext();
855:                }
856:
857:                EventQueue theEventQueue = (EventQueue) appContext
858:                        .get(AppContext.EVENT_QUEUE_KEY);
859:
860:                theEventQueue.postEvent(event);
861:                Thread.yield();
862:            }
863:
864:            /**
865:             * Gets an instance of the system clipboard which interfaces
866:             * with clipboard facilities provided by the native platform.
867:             * <p>
868:             * This clipboard enables data transfer between Java programs
869:             * and native applications which use native clipboard facilities.
870:             * @return    an instance of the system clipboard.
871:             * @see       java.awt.datatransfer.Clipboard
872:             * @since     JDK1.1
873:             */
874:            public Clipboard getSystemClipboard() {
875:                SecurityManager security = System.getSecurityManager();
876:                if (security != null) {
877:                    security.checkSystemClipboardAccess();
878:                }
879:                return systemClipboard;
880:            }
881:
882:            /**
883:             * Returns a new input method adapter for native input methods.
884:             */
885:            public InputMethod getInputMethodAdapter() throws AWTException {
886:                throw new UnsupportedOperationException();
887:            }
888:
889:            public native boolean isFrameStateSupported(int state)
890:                    throws HeadlessException;
891:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.