toolkit.java
来自「java virtual machince kaffe」· Java 代码 · 共 912 行 · 第 1/2 页
JAVA
912 行
native static synchronized void graFillPolygon ( Pointer grData, int[] xPoints, int[] yPoints, int nPoints );native static synchronized void graFillRect ( Pointer grData, int x, int y, int width, int height );native static synchronized void graFillRoundRect ( Pointer grData, int x, int y, int width, int height, int arcWidth, int arcHeight );native static synchronized void graFreeGraphics ( Pointer grData );native static synchronized Pointer graInitGraphics ( Pointer grData, Pointer tgtData, int tgtType, int xOffset, int yOffset, int xClip, int yClip, int wClip, int hClip, Pointer fontData, int fgClr, int bgClr, boolean blank );native static synchronized void graSetBackColor ( Pointer grData, int pixelValue );native static synchronized void graSetClip ( Pointer grData, int xClip, int yClip, int wClip, int hClip );native static synchronized void graSetColor ( Pointer grData, int pixelValue );native static synchronized void graSetFont ( Pointer grData, Pointer fontData );native static synchronized void graSetOffset ( Pointer grData, int xOffset, int yOffset );native static synchronized void graSetPaintMode ( Pointer grData );native static synchronized void graSetVisible ( Pointer grData, boolean isVisible );native static synchronized void graSetXORMode ( Pointer grData, int xClr );native static synchronized void imgComplete ( Pointer imgData, int status );native static synchronized Pointer imgCreateFromData( byte[] buf, int offset, int len);native static synchronized Pointer imgCreateFromFile( String gifPath);native static synchronized Pointer imgCreateImage( int w, int h);native static synchronized Pointer imgCreateScaledImage( Pointer imgData, int w, int h);native static synchronized Pointer imgCreateScreenImage( int w, int h);native static synchronized void imgFreeImage ( Pointer imgData );native static synchronized int imgGetHeight( Pointer imgData);native static synchronized int imgGetLatency ( Pointer imgData );native static synchronized Pointer imgGetNextFrame ( Pointer imgData );native static synchronized int imgGetWidth( Pointer imgData);native static synchronized boolean imgIsMultiFrame( Pointer imgData);native static synchronized void imgProduceImage( ImageNativeProducer prod, Pointer imgData);native static synchronized Pointer imgSetFrame( Pointer imgData, int frame);native static synchronized void imgSetIdxPels( Pointer imgData, int x, int y, int w, int h, int[] rgbs, byte[] pels, int trans, int off, int scans);native static synchronized void imgSetRGBPels( Pointer imgData, int x, int y, int w, int h, int[] rgbs, int off, int scans);static synchronized void initToolkit () { // this is called when the native layer has been initialized, and it is safe // to query native settings / rely on native functionality screenSize = new Dimension( tlkGetScreenWidth(), tlkGetScreenHeight()); resolution = tlkGetResolution(); // we do this here to keep the getDefaultToolkit() method as simple // as possible (since it might be called frequently). This is a // deviation from the normal Singleton (which initializes the singleton // instance upon request) singleton = new Toolkit(); eventQueue = new EventQueue();/** if ( Defaults.ConsoleClass != null ){ // since we have to defer the ConsoleWindow until the native Toolkit is propperly // initialized, it seems to be a good idea to defuse any output to the standard streams // (which might cause SEGFAULTS on some systems (e.g. DOS) System.setOut( new PrintStream( NullOutputStream.singleton)); System.setErr( System.out); }**/ if ( (flags & NATIVE_DISPATCHER_LOOP) != 0 ) { // let the world know we are ready to take over, native-wise Toolkit.class.notify(); }}protected void loadSystemColors ( int[] sysColors ) { clrSetSystemColors( sysColors);}public boolean prepareImage ( Image image, int width, int height, ImageObserver observer ) { return (Image.loadImage( image, width, height, observer));}static void redirectStreams () { try { LogClient lv = (LogClient) Class.forName( Defaults.ConsoleClass).newInstance(); LogStream ls = new LogStream( 30, lv); lv.enable(); System.setOut( new PrintStream( ls) ); System.setErr( System.out); System.out.println( "Java console enabled"); } catch ( Exception x ) { System.err.println( "unable to redirect out, err"); x.printStackTrace(); }}static synchronized void startDispatch () { if ( eventThread == null ) { eventThread = new EventDispatchThread( eventQueue); eventThread.start(); // we defer the Console creation / output redirection up to this point, since we otherwise // might get all sort of trouble because of a incompletely initialized native layer / Toolkit if ( Defaults.ConsoleClass != null ) redirectStreams(); } if ( ((flags & NEEDS_FLUSH) != 0) && (flushThread == null) ){ flushThread = new FlushThread( Defaults.GraFlushRate); flushThread.start(); }}static synchronized void stopDispatch () { if ( eventThread != null ) { eventThread.stopDispatching(); eventThread = null; } if ( flushThread != null ){ flushThread.stopFlushing(); flushThread = null; }}public void sync () { tlkSync();}static void terminate () { if ( clipboard != null ) clipboard.dispose(); stopDispatch(); tlkTerminate();} /* taken from GNU Classpath */ public DragGestureRecognizer createDragGestureRecognizer(Class recognizer, DragSource ds, Component comp, int actions, DragGestureListener l) { return null; } /** * Adds an AWTEventListener to this toolkit. This listener is informed about * all events that pass the eventqueue that match the specified * <code>evenMask</code>. The <code>eventMask</code> is an ORed combination * of event masks as defined in {@link AWTEvent}. * * If a security manager is installed, it is asked first if an * <code>AWTPermission("listenToAllAWTEvents")</code> is allowed. * This may result in a <code>SecurityException</code> beeing thrown. * * It is not recommended to use this kind of notification for normal * applications. It is intended solely for the purpose of debugging and to * support special facilities. * * @param listener the listener to add * @param eventMask the event mask of event types which the listener is * interested in * * @since 1.2 * * @throws SecurityException if there is a <code>SecurityManager</code> that * doesn't grant * <code>AWTPermission("listenToAllAWTEvents")</code> * * @see #getAWTEventListeners() * @see #getAWTEventListeners(long) * @see #removeAWTEventListener(AWTEventListener) */ public void addAWTEventListener(AWTEventListener listener, long eventMask) { // First we must check the security permissions. SecurityManager s = System.getSecurityManager(); if (s != null) s.checkPermission(new AWTPermission("listenToAllAWTEvents")); // Go through the list and check if the requested listener is already // registered. boolean found = false; for (int i = 0; i < awtEventListeners.length; ++i) { AWTEventListenerProxy proxy = awtEventListeners[i]; if (proxy.getListener() == listener) { found = true; // Modify the proxies event mask to include the new event mask. AWTEventListenerProxy newProxy = new AWTEventListenerProxy(proxy.getEventMask() | eventMask, listener); awtEventListeners[i] = newProxy; break; } } // If that listener was not found, then add it. if (! found) { AWTEventListenerProxy proxy = new AWTEventListenerProxy(eventMask, listener); AWTEventListenerProxy[] newArray = new AWTEventListenerProxy[awtEventListeners.length + 1]; System.arraycopy(awtEventListeners, 0, newArray, 0, awtEventListeners.length); newArray[newArray.length - 1] = proxy; awtEventListeners = newArray; } } /** * Removes an AWT event listener from this toolkit. This listener is no * longer informed of any event types it was registered in. * * If a security manager is installed, it is asked first if an * <code>AWTPermission("listenToAllAWTEvents")</code> is allowed. * This may result in a <code>SecurityException</code> beeing thrown. * * It is not recommended to use this kind of notification for normal * applications. It is intended solely for the purpose of debugging and to * support special facilities. * * @param listener the listener to remove * * @throws SecurityException if there is a <code>SecurityManager</code> that * doesn't grant * <code>AWTPermission("listenToAllAWTEvents")</code> * * @since 1.2 * * @see #addAWTEventListener(AWTEventListener, long) * @see #getAWTEventListeners() * @see #getAWTEventListeners(long) */ public void removeAWTEventListener(AWTEventListener listener) { // First we must check the security permissions. SecurityManager s = System.getSecurityManager(); if (s != null) s.checkPermission(new AWTPermission("listenToAllAWTEvents")); // Find the index of the listener. int index = -1; for (int i = 0; i < awtEventListeners.length; ++i) { AWTEventListenerProxy proxy = awtEventListeners[i]; if (proxy.getListener() == listener) { index = i; break; } } // Copy over the arrays and leave out the removed element. if (index != -1) { AWTEventListenerProxy[] newArray = new AWTEventListenerProxy[awtEventListeners.length - 1]; if (index > 0) System.arraycopy(awtEventListeners, 0, newArray, 0, index); if (index < awtEventListeners.length - 1) System.arraycopy(awtEventListeners, index + 1, newArray, index, awtEventListeners.length - index - 1); awtEventListeners = newArray; } } /** * Returns all registered AWT event listeners. This method returns a copy of * the listener array, so that application cannot trash the listener list. * * If a security manager is installed, it is asked first if an * <code>AWTPermission("listenToAllAWTEvents")</code> is allowed. * This may result in a <code>SecurityException</code> beeing thrown. * * It is not recommended to use this kind of notification for normal * applications. It is intended solely for the purpose of debugging and to * support special facilities. * * @return all registered AWT event listeners * * @throws SecurityException if there is a <code>SecurityManager</code> that * doesn't grant * <code>AWTPermission("listenToAllAWTEvents")</code> * * @since 1.4 * * @see #addAWTEventListener(AWTEventListener, long) * @see #removeAWTEventListener(AWTEventListener) * @see #getAWTEventListeners(long) */ public AWTEventListener[] getAWTEventListeners() { // First we must check the security permissions. SecurityManager s = System.getSecurityManager(); if (s != null) s.checkPermission(new AWTPermission("listenToAllAWTEvents")); // Create a copy of the array. AWTEventListener[] copy = new AWTEventListener[awtEventListeners.length]; System.arraycopy(awtEventListeners, 0, copy, 0, awtEventListeners.length); return copy; } /** * Returns all registered AWT event listeners that listen for events with * the specified <code>eventMask</code>. This method returns a copy of * the listener array, so that application cannot trash the listener list. * * If a security manager is installed, it is asked first if an * <code>AWTPermission("listenToAllAWTEvents")</code> is allowed. * This may result in a <code>SecurityException</code> beeing thrown. * * It is not recommended to use this kind of notification for normal * applications. It is intended solely for the purpose of debugging and to * support special facilities. * * @param mask the event mask * * @throws SecurityException if there is a <code>SecurityManager</code> that * doesn't grant * <code>AWTPermission("listenToAllAWTEvents")</code> * * * @since 1.4 * * @see #addAWTEventListener(AWTEventListener, long) * @see #removeAWTEventListener(AWTEventListener) * @see #getAWTEventListeners() */ public AWTEventListener[] getAWTEventListeners(long mask) { // First we must check the security permissions. SecurityManager s = System.getSecurityManager(); if (s != null) s.checkPermission(new AWTPermission("listenToAllAWTEvents")); // Create a copy of the array with only the requested listeners in it. ArrayList l = new ArrayList(awtEventListeners.length); for (int i = 0; i < awtEventListeners.length; ++i) { if ((awtEventListeners[i].getEventMask() & mask) != 0) l.add(awtEventListeners[i]); } return (AWTEventListener[] ) l.toArray(new AWTEventListener[l.size()]); } /** * Dispatches events to listeners registered to this Toolkit. This is called * by {@link Component#dispatchEventImpl(AWTEvent)} in order to dispatch * events globally. * * @param ev the event to dispatch */ void globalDispatchEvent(AWTEvent ev) { // We do not use the accessor methods here because they create new // arrays each time. We must be very efficient, so we access this directly. for (int i = 0; i < awtEventListeners.length; ++i) { AWTEventListenerProxy proxy = awtEventListeners[i]; if ((proxy.getEventMask() & AWTEvent.eventIdToMask(ev.getID())) != 0) proxy.eventDispatched(ev); } }native static synchronized void tlkBeep ();native static synchronized void tlkDisplayBanner ( String banner );native static synchronized void tlkFlush ();native static synchronized int tlkGetResolution ();native static synchronized int tlkGetScreenHeight ();native static synchronized int tlkGetScreenWidth ();native static boolean tlkInit ( String displayName );native static synchronized int tlkProperties();native static synchronized void tlkSync ();native static synchronized void tlkTerminate ();native static synchronized String tlkVersion ();native static synchronized Pointer wndCreateDialog ( Pointer ownerData, String title, int x, int y, int width, int height, int cursorType, int bgColor, boolean isResizable );native static synchronized Pointer wndCreateFrame ( String title, int x, int y, int width, int height, int cursorType, int bgColor, boolean isResizable );native static synchronized Pointer wndCreateWindow ( Pointer ownerData, int x, int y, int width, int height, int cursorType, int bgColor );native static synchronized void wndDestroyWindow ( Pointer wndData );native static synchronized void wndRepaint ( Pointer wndData, int x, int y, int width, int height );native static synchronized void wndRequestFocus ( Pointer wndData );native static synchronized void wndSetBounds ( Pointer wndData, int x, int y, int width, int height, boolean isResizable );native static synchronized void wndSetCursor ( Pointer wndData, int cursorType );native static synchronized int wndSetDialogInsets ( int top, int left, int bottom, int right);native static synchronized int wndSetFrameInsets ( int top, int left, int bottom, int right);native static synchronized void wndSetIcon ( Pointer wndData, Pointer iconData );native static synchronized void wndSetResizable ( Pointer wndData, boolean isResizable, int x, int y, int width, int height );native static synchronized void wndSetTitle ( Pointer wndData, String title );native static synchronized void wndSetVisible ( Pointer wndData, boolean showIt );native static synchronized void wndToBack ( Pointer wndData );native static synchronized void wndToFront ( Pointer wndData );}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?