gtknativeengine.java
来自「JAVA 所有包」· Java 代码 · 共 487 行 · 第 1/2 页
JAVA
487 行
return (sb.getOrientation() == JScrollBar.HORIZONTAL) ? widgets[0] : widgets[1]; } return null; } public void paintArrow(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, ArrowType direction, String detail, int x, int y, int w, int h) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_arrow(widget, state, shadowType.ordinal(), detail, x - x0, y - y0, w, h, direction.ordinal()); } public void paintBox(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, String detail, int x, int y, int w, int h) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_box(widget, state, shadowType.ordinal(), detail, x - x0, y - y0, w, h, context.getComponentState()); } public void paintBoxGap(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, String detail, int x, int y, int w, int h, PositionType boxGapType, int tabBegin, int size) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_box_gap(widget, state, shadowType.ordinal(), detail, x - x0, y - y0, w, h, boxGapType.ordinal(), tabBegin, size); } public void paintCheck(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, String detail, int x, int y, int w, int h) { int synthState = context.getComponentState(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_check(widget, synthState, detail, x - x0, y - y0, w, h); } public void paintExpander(Graphics g, SynthContext context, Region id, int state, ExpanderStyle expanderStyle, String detail, int x, int y, int w, int h) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_expander(widget, state, detail, x - x0, y - y0, w, h, expanderStyle.ordinal()); } public void paintExtension(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, String detail, int x, int y, int w, int h, PositionType placement, int tabIndex) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_extension(widget, state, shadowType.ordinal(), detail, x - x0, y - y0, w, h, placement.ordinal()); } public void paintFlatBox(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, String detail, int x, int y, int w, int h, ColorType colorType) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_flat_box(widget, state, shadowType.ordinal(), detail, x - x0, y - y0, w, h, context.getComponent().hasFocus()); } public void paintFocus(Graphics g, SynthContext context, Region id, int state, String detail, int x, int y, int w, int h) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_focus(widget, state, detail, x - x0, y - y0, w, h); } public void paintHandle(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, String detail, int x, int y, int w, int h, Orientation orientation) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_handle(widget, state, shadowType.ordinal(), detail, x - x0, y - y0, w, h, orientation.ordinal()); } public void paintHline(Graphics g, SynthContext context, Region id, int state, String detail, int x, int y, int w, int h) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_hline(widget, state, detail, x - x0, y - y0, w, h); } public void paintOption(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, String detail, int x, int y, int w, int h) { int synthState = context.getComponentState(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_option(widget, synthState, detail, x - x0, y - y0, w, h); } public void paintShadow(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, String detail, int x, int y, int w, int h) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_shadow(widget, state, shadowType.ordinal(), detail, x - x0, y - y0, w, h); } public void paintSlider(Graphics g, SynthContext context, Region id, int state, ShadowType shadowType, String detail, int x, int y, int w, int h, Orientation orientation) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_slider(widget, state, shadowType.ordinal(), detail, x - x0, y - y0, w, h, orientation.ordinal()); } public void paintVline(Graphics g, SynthContext context, Region id, int state, String detail, int x, int y, int w, int h) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_vline(widget, state, detail, x - x0, y - y0, w, h); } public void paintBackground(Graphics g, SynthContext context, Region id, int state, Color color, int x, int y, int w, int h) { state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); int widget = getWidgetType(context.getComponent(), id).ordinal(); native_paint_background(widget, state, x - x0, y - y0, w, h); } private final static ColorModel[] COLOR_MODELS = { // Transparency.OPAQUE new DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000), // Transparency.BITMASK new DirectColorModel(25, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x01000000), // Transparency.TRANSLUCENT ColorModel.getRGBdefault(), }; private final static int[][] BAND_OFFSETS = { { 0x00ff0000, 0x0000ff00, 0x000000ff }, // OPAQUE { 0x00ff0000, 0x0000ff00, 0x000000ff, 0x01000000 }, // BITMASK { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 } // TRANSLUCENT }; /** * Paint a cached image identified by its size and a set of additional * arguments, if there's one. * * @return true if a cached image has been painted, false otherwise */ public boolean paintCachedImage(Graphics g, int x, int y, int w, int h, Object... args) { if (w <= 0 || h <= 0) { return true; } // look for cached image Image img = cache.getImage(getClass(), null, w, h, args); if (img != null) { g.drawImage(img, x, y, null); return true; } return false; } /* * Allocate a native offscreen buffer of the specified size. */ public void startPainting(Graphics g, int x, int y, int w, int h, Object... args) { nativeStartPainting(w, h); x0 = x; y0 = y; w0 = w; h0 = h; graphics = g; cacheArgs = args; } /** * Called to indicate that painting is finished. We create a new * BufferedImage from the offscreen buffer, cache it, and paint it. */ public void finishPainting() { int[] data = new int[w0 * h0]; int transparency = nativeFinishPainting(data, w0, h0); int[] bands = BAND_OFFSETS[transparency - 1]; DataBuffer dataBuffer = new DataBufferInt(data, data.length); WritableRaster raster = Raster.createPackedRaster( dataBuffer, w0, h0, w0, bands, null); // Raster created this way is not accelerated. // We re-enable acceleration here. if (raster instanceof SunWritableRaster) { ((SunWritableRaster)raster).setStolen(false); } ColorModel cm = COLOR_MODELS[transparency - 1]; Image img = new BufferedImage(cm, raster, false, null); cache.setImage(getClass(), null, w0, h0, cacheArgs, img); graphics.drawImage(img, x0, y0, null); } /** * Notify native layer of theme change, and flush cache */ public void themeChanged() { synchronized(sun.awt.UNIXToolkit.GTK_LOCK) { native_switch_theme(); } cache.flush(); } /* GtkSettings enum mirrors that in gtk2_interface.h */ public Object getSetting(Settings property) { synchronized(sun.awt.UNIXToolkit.GTK_LOCK) { return native_get_gtk_setting(property.ordinal()); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?