⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtkengine.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    offset = Math.min(max2, next);                }                if (offset != next && offset < max3) {                    // bottom                    int x2 = w - (offset - max2);                    int temp = Math.min(next - offset, max3 - offset);                    g.fillRect(x2 - temp, h - size, temp, size);                    offset += temp;                }                if (offset != next) {                    int y2 = h - (offset - max3);                    int temp = Math.min(next - offset, max4 - offset);                    g.fillRect(0, y2 - temp, size, temp);                    offset += temp;                }            }            else {                offset = next;            }            index = (index + 1) % pattern.length;        }        g.translate(-x, -y);    }    Color getFocusColor(SynthContext context, int state) {        return ((GTKStyle)context.getStyle()).getGTKColor(               context.getComponent(), context.getRegion(), state,               ColorType.FOREGROUND);    }    public void paintHandle(SynthContext context, Graphics g, int paintState,                            int shadowType, String info, int x, int y,                            int w, int h, int orientation) {        paintBox(context, g, paintState, shadowType, info, x, y, w, h);        g.translate(x, y);        Region region = context.getRegion();        GTKStyle style = (GTKStyle)context.getStyle();        JComponent component = context.getComponent();        Color lightColor = style.getGTKColor(component, region, paintState,                                          GTKColorType.LIGHT);        Color darkColor = style.getGTKColor(component, region, paintState,                                          GTKColorType.DARK);        Color blackColor = style.getGTKColor(component, region, paintState,                                          GTKColorType.BLACK);        int startX;        int startY;        if (info == "paned") {            JSplitPane splitPane = (JSplitPane)component;            int markerLength = 7 * 3 + 6 * 2;  // 7 markers width of 3                                               // + 6 spacers width of 2.            if (orientation == GTKConstants.HORIZONTAL) {                // Components are above/below.                startX = w / 2 - markerLength / 2;                startY = splitPane.getDividerSize() / 2 - 1;            } else {                // Components are left/right                startX = splitPane.getDividerSize() / 2 - 1;                startY = h / 2 - markerLength / 2;            }            for (int i = 0; i < 7; i++) {                // Add length of one marker and spacing.                if (orientation == GTKConstants.HORIZONTAL) {                    startX += 5;                } else {                    startY += 5;                }                g.setColor(lightColor);                g.fillRect(startX, startY, 2, 2);                g.setColor(blackColor);                g.fillRect(startX + 1, startY + 1, 2, 2);                g.setColor(darkColor);                g.fillRect(startX + 1, startY + 1, 1, 1);            }        } else if (info == "handlebox") {            JToolBar tb = (JToolBar)component;            startX = 2;            startY = 2;            if (tb.getOrientation() == JToolBar.HORIZONTAL) {                while (startY < h) {                    g.setColor(darkColor);                    g.fillRect(startX + 1, startY + 1, 2, 2);                    g.fillRect(startX + 4, startY + 2, 2, 2);                    g.setColor(lightColor);                    g.fillRect(startX, startY, 2, 2);                    g.fillRect(startX + 3, startY + 1, 2, 2);                    startY += 3;                }            } else {                boolean toggle = true;                while (startX < w) {                    g.setColor(darkColor);                    g.fillRect(startX + 1, startY + 1, 2, 2);                    g.fillRect(startX + 1, startY + 4, 2, 2);                    g.setColor(lightColor);                    g.fillRect(startX, startY, 2, 2);                    g.fillRect(startX, startY + 3, 2, 2);                    startX += 3;                    if (toggle) {                        startY++;                        toggle = false;                    } else {                        startY--;                        toggle = true;                    }                }            }            // Fix up the shadow.            paintShadow(context, g, paintState, shadowType, info, 0, 0, w, h);        }        g.translate(-x, -y);    }    public void paintOption(SynthContext context, Graphics g, int paintState,                            int shadowType, String info, int x, int y,                            int w, int h) {        g.translate(x, y);        int componentState = context.getComponentState();        int centerY = h / 2 - 1;        JComponent component = context.getComponent();        Region region = context.getRegion();        GTKStyle style = (GTKStyle)context.getStyle();        // If the radio button is being pressed we fill the center with the        // MID gtk color, otherwise we fill it WHITE.  We need to use the state        // from the context since the state passed in may have been modified.        if ((componentState & SynthConstants.PRESSED) == 0) {            g.setColor(style.getGTKColor(component, region, paintState,                                         GTKColorType.WHITE));        } else {            g.setColor(style.getGTKColor(component, region, paintState,                                         GTKColorType.MID));        }        if (region != Region.RADIO_BUTTON_MENU_ITEM) {            // Paint center portion.            g.fillOval(1, 0 , 11, 11);            g.drawLine(13, centerY - 1, 13, centerY + 2);            g.drawLine(12, centerY + 3, 12, centerY + 4);            g.drawLine(11, centerY + 5, 11, centerY + 5);            g.drawLine(9, centerY + 6, 10, centerY + 6);            g.drawLine(5, centerY + 7, 8, centerY + 7);                // Paint dark shadow.            g.setColor(style.getGTKColor(component, region, paintState,                                         GTKColorType.DARK));            g.drawOval(1, 0, 11, 11);                // Paint black shadow.            g.setColor(style.getGTKColor(component, region, paintState,                                         GTKColorType.BLACK));            g.drawLine(5, centerY - 4, 8, centerY - 4);            g.drawLine(9, centerY - 4, 10, centerY - 3);            g.drawLine(3, centerY - 3, 4, centerY - 3);            g.drawLine(3, centerY - 2, 2, centerY - 1);            g.drawLine(2, centerY, 2, centerY + 2);            g.drawLine(2, centerY + 3, 3, centerY + 4);        }        // Fill in center if selected.        if ((componentState & SynthConstants.SELECTED) != 0) {            if (region == Region.RADIO_BUTTON_MENU_ITEM) {                g.setColor(style.getGTKColor(component, region, paintState,                                             GTKColorType.BLACK));            }            g.fillRect(5, centerY, 5, 3);            g.drawLine(6, centerY - 1, 8, centerY - 1);            g.drawLine(6, centerY + 3, 8, centerY + 3);        }        g.translate(-x, -y);    }    public void paintShadow(SynthContext context, Graphics g, int state,                            int shadowType, String info, int x, int y,                            int w, int h) {        if (info == "buttondefault") {            // YES, this appears to be special cased.            g.setColor(((GTKStyle)context.getStyle()).getGTKColor(                           context.getComponent(), context.getRegion(),                           state, GTKColorType.BLACK));            g.drawRect(x, y, w - 1, h - 1);            return;        }        GTKStyle style = (GTKStyle)context.getStyle();        JComponent c = context.getComponent();        Region region = context.getRegion();        int xThickness = style.getXThickness();        int yThickness = style.getYThickness();        if (info == "trough" ||                (info == "spinbutton" && c instanceof JButton)) {            // YES, this appears to be special cased.            xThickness = yThickness = 1;        }        if (xThickness < 0 && yThickness < 0) {            // nothing to paint.            return;        }        Color upperLeft = null, innerLeft = null, bottomRight = null,              innerRight = null;        switch (shadowType) {        case GTKConstants.SHADOW_IN:            if (info == "spinbutton" && c instanceof JButton) {                upperLeft = style.getGTKColor(c, region, state,                        GTKColorType.DARK);                innerRight = upperLeft;                bottomRight = style.getGTKColor(c, region, state,                        GTKColorType.BLACK);            } else {                upperLeft = style.getGTKColor(c, region, state,                        GTKColorType.DARK);                innerLeft = style.getGTKColor(c, region, state,                        GTKColorType.BLACK);                bottomRight = style.getGTKColor(c, region, state,                        GTKColorType.LIGHT);                innerRight = style.getGTKColor(c, region, state,                        GTKColorType.BACKGROUND);            }            break;        case GTKConstants.SHADOW_OUT:            upperLeft = style.getGTKColor(c, region, state,GTKColorType.LIGHT);            innerLeft = style.getGTKColor(c, region, state,                                          GTKColorType.BACKGROUND);            bottomRight = style.getGTKColor(c, region, state,                                            GTKColorType.BLACK);            innerRight = style.getGTKColor(c, region, state,GTKColorType.DARK);            break;        default:            assert true : "Unknown shadow type!";        }        if (info == "spinbutton" && c instanceof JButton) {            _paintSpinButtonShadow(g, x, y, w, h, xThickness, yThickness,                    upperLeft, innerLeft, bottomRight, innerRight);        } else {            _paintShadow(g,  x, y, w, h, xThickness, yThickness,                    upperLeft, innerLeft, bottomRight, innerRight);        }    }    void _paintShadow(Graphics g, int x, int y, int w, int h,                 int xThickness, int yThickness, Color upperLeft,                 Color innerLeft, Color bottomRight, Color innerRight) {        g.translate(x, y);        // left/top        g.setColor(upperLeft);        if (xThickness > 0) {            g.drawLine(0, 0, 0, h - 1);        }        if (yThickness > 0) {            g.drawLine(1, 0, w - 1, 0);        }        // Inner left/top        if (xThickness > 1 || yThickness > 1) {            g.setColor(innerLeft);            if (xThickness > 1) {                g.drawLine(1, 1, 1, h - 2);            }            if (yThickness > 1) {                g.drawLine(2, 1, w - 2, 1);            }        }        // Bottom/right        g.setColor(bottomRight);        if (xThickness > 0) {            g.drawLine(w - 1, 1, w - 1, h - 1);        }        if (yThickness > 0) {            g.drawLine(1, h - 1, w - 2, h - 1);        }        // Inner bottom/right        if (xThickness > 1 || yThickness > 1) {            g.setColor(innerRight);            if (xThickness > 1) {                g.drawLine(w - 2, 2, w - 2, h - 2);            }            if (yThickness > 1) {                g.drawLine(2, h - 2, w - 3, h - 2);            }        }        g.translate(-x, -y);    }    void _paintSpinButtonShadow(Graphics g, int x, int y,                 int w, int h, int xThickness, int yThickness, Color upperLeft,                 Color innerLeft, Color bottomRight, Color innerRight) {        g.translate(x, y);        // top        g.setColor(upperLeft);        g.drawLine(0, 0, w - 1, 0);        // bottom        g.setColor(innerRight);        g.drawLine(0, h - 1, w - 1, h - 1);        // left/right        g.setColor(bottomRight);        g.drawLine(0, 0, 0, h - 1);        g.drawLine(w - 1, 0, w - 1, h - 1);        g.translate(-x, -y);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -