gtkcomponentpeer.java
来自「Mac OS X 10.4.9 for x86 Source Code gcc」· Java 代码 · 共 631 行 · 第 1/2 页
JAVA
631 行
ke.getKeyCode (), ke.getKeyLocation ()); break; } } public boolean isFocusTraversable () { return true; } public Dimension minimumSize () { int dim[] = new int[2]; gtkWidgetGetPreferredDimensions (dim); return new Dimension (dim[0], dim[1]); } public void paint (Graphics g) { } public Dimension preferredSize () { int dim[] = new int[2]; gtkWidgetGetPreferredDimensions (dim); return new Dimension (dim[0], dim[1]); } public boolean prepareImage (Image image, int width, int height, ImageObserver observer) { GtkImage i = (GtkImage) image; if (i.isLoaded ()) return true; class PrepareImage extends Thread { GtkImage image; ImageObserver observer; PrepareImage (GtkImage image, ImageObserver observer) { this.image = image; image.setObserver (observer); } public void run () { image.source.startProduction (image); } } new PrepareImage (i, observer).start (); return false; } public void print (Graphics g) { throw new RuntimeException (); } public void repaint (long tm, int x, int y, int width, int height) { if (x == 0 && y == 0 && width == 0 && height == 0) return; q().postEvent (new PaintEvent (awtComponent, PaintEvent.UPDATE, new Rectangle (x, y, width, height))); } public void requestFocus () { gtkWidgetRequestFocus(); postFocusEvent(FocusEvent.FOCUS_GAINED, false); } public void reshape (int x, int y, int width, int height) { setBounds (x, y, width, height); } public void setBackground (Color c) { gtkWidgetSetBackground (c.getRed(), c.getGreen(), c.getBlue()); } native void setNativeBounds (int x, int y, int width, int height); public void setBounds (int x, int y, int width, int height) { Component parent = awtComponent.getParent (); // Heavyweight components that are children of one or more // lightweight containers have to be handled specially. Because // calls to GLightweightPeer.setBounds do nothing, GTK has no // knowledge of the lightweight containers' positions. So we have // to add the offsets manually when placing a heavyweight // component within a lightweight container. The lightweight // container may itself be in a lightweight container and so on, // so we need to continue adding offsets until we reach a // container whose position GTK knows -- that is, the first // non-lightweight. boolean lightweightChild = false; Insets i; while (parent.isLightweight ()) { lightweightChild = true; i = ((Container) parent).getInsets (); x += parent.getX () + i.left; y += parent.getY () + i.top; parent = parent.getParent (); } // We only need to convert from Java to GTK coordinates if we're // placing a heavyweight component in a Window. if (parent instanceof Window && !lightweightChild) { Insets insets = ((Window) parent).getInsets (); GtkWindowPeer peer = (GtkWindowPeer) parent.getPeer (); int menuBarHeight = 0; if (peer instanceof GtkFramePeer) menuBarHeight = ((GtkFramePeer) peer).getMenuBarHeight (); // Convert from Java coordinates to GTK coordinates. setNativeBounds (x - insets.left, y - insets.top + menuBarHeight, width, height); } else setNativeBounds (x, y, width, height); } void setCursor () { setCursor (awtComponent.getCursor ()); } public void setCursor (Cursor cursor) { gtkWidgetSetCursor (cursor.getType ()); } public void setEnabled (boolean b) { gtkWidgetSetSensitive (b); } public void setFont (Font f) { // FIXME: This should really affect the widget tree below me. // Currently this is only handled if the call is made directly on // a text widget, which implements setFont() itself. gtkWidgetModifyFont(f.getName(), f.getStyle(), f.getSize()); } public void setForeground (Color c) { gtkWidgetSetForeground (c.getRed(), c.getGreen(), c.getBlue()); } public Color getForeground () { int rgb[] = gtkWidgetGetForeground (); return new Color (rgb[0], rgb[1], rgb[2]); } public Color getBackground () { int rgb[] = gtkWidgetGetBackground (); return new Color (rgb[0], rgb[1], rgb[2]); } public void setVisible (boolean b) { if (b) show (); else hide (); } public native void hide (); public native void show (); protected void postMouseEvent(int id, long when, int mods, int x, int y, int clickCount, boolean popupTrigger) { q().postEvent(new MouseEvent(awtComponent, id, when, mods, x, y, clickCount, popupTrigger)); } protected void postExposeEvent (int x, int y, int width, int height) { if (!isInRepaint) q().postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT, new Rectangle (x, y, width, height))); } protected void postKeyEvent (int id, long when, int mods, int keyCode, char keyChar, int keyLocation) { KeyEvent keyEvent = new KeyEvent (awtComponent, id, when, mods, keyCode, keyChar, keyLocation); // Also post a KEY_TYPED event if keyEvent is a key press that // doesn't represent an action or modifier key. if (keyEvent.getID () == KeyEvent.KEY_PRESSED && (!keyEvent.isActionKey () && keyCode != KeyEvent.VK_SHIFT && keyCode != KeyEvent.VK_CONTROL && keyCode != KeyEvent.VK_ALT)) { synchronized (q) { q().postEvent (keyEvent); q().postEvent (new KeyEvent (awtComponent, KeyEvent.KEY_TYPED, when, mods, KeyEvent.VK_UNDEFINED, keyChar, keyLocation)); } } else q().postEvent (keyEvent); } protected void postFocusEvent (int id, boolean temporary) { q().postEvent (new FocusEvent (awtComponent, id, temporary)); } protected void postItemEvent (Object item, int stateChange) { q().postEvent (new ItemEvent ((ItemSelectable)awtComponent, ItemEvent.ITEM_STATE_CHANGED, item, stateChange)); } public GraphicsConfiguration getGraphicsConfiguration () { // FIXME: just a stub for now. return null; } public void setEventMask (long mask) { // FIXME: just a stub for now. } public boolean isFocusable () { return false; } public boolean requestFocus (Component source, boolean b1, boolean b2, long x) { return false; } public boolean isObscured () { return false; } public boolean canDetermineObscurity () { return false; } public void coalescePaintEvent (PaintEvent e) { } public void updateCursorImmediately () { } public VolatileImage createVolatileImage (int width, int height) { return null; } public boolean handlesWheelScrolling () { return false; } public void createBuffers (int x, BufferCapabilities capabilities) throws java.awt.AWTException { } public Image getBackBuffer () { return null; } public void flip (BufferCapabilities.FlipContents contents) { } public void destroyBuffers () { }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?