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

📄 gtkengine.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        }        g.translate(-x, -y);    }    public void paintCheck(SynthContext context, Graphics g, int state,                           int shadowType, String info, int x, int y,                           int w, int h) {        int componentState = context.getComponentState();        JComponent component = context.getComponent();        Region r = context.getRegion();        GTKStyle style = (GTKStyle)context.getStyle();        if ("checkbutton" == info) {            if ((componentState & SynthConstants.PRESSED) == 0) {                paintBox(context, g, SynthConstants.ENABLED,                        GTKConstants.SHADOW_IN, info, x, y, w, h);                g.setColor(style.getGTKColor(component, r, state,                        GTKColorType.WHITE));            } else {                paintBox(context, g, SynthConstants.PRESSED,                        GTKConstants.SHADOW_IN, info, x, y, w, h);                g.setColor(style.getGTKColor(component, r, state,                        GTKColorType.BACKGROUND));            }        }        g.translate(x, y);        int centerY = h / 2 - 1;        if ("checkbutton" == info) {            g.fillRect(2, 2, w - 4, h - 4);        }        // Paint check mark in center if selected.        if ((componentState & SynthConstants.SELECTED) != 0) {            g.setColor(                style.getGTKColor(component, r, state, GTKColorType.BLACK));            g.drawLine(3, centerY + 2, 4, centerY + 2);            g.drawLine(5, centerY + 3, 6, centerY + 3);            g.drawLine(6, centerY + 2, 6, centerY + 4);            g.drawLine(7, centerY + 1, 7, centerY);            g.drawLine(7, centerY, 8, centerY);            g.drawLine(8, centerY, 8, centerY - 1);            g.drawLine(8, centerY - 1, 9, centerY - 1);            g.drawLine(9, centerY - 1, 9, centerY - 2);            if ((componentState & SynthConstants.PRESSED) != 0) {                g.setColor(style.getGTKColor(component, r,                    SynthConstants.PRESSED, GTKColorType.DARK));            } else {                g.setColor(style.getGTKColor(component, r,                    SynthConstants.ENABLED, GTKColorType.DARK));            }            g.drawLine(3, centerY + 1, 4, centerY + 1);            g.drawLine(4, centerY + 3, 4, centerY + 3);            g.drawLine(5, centerY + 2, 5, centerY + 2);            g.drawLine(6, centerY + 1, 6, centerY + 1);            g.drawLine(7, centerY + 2, 7, centerY + 2);            g.drawLine(10, centerY - 2, 10, centerY - 2);        }        g.translate(-x, -y);    }    public void paintExtension(SynthContext context, Graphics g, int state,                               int shadowType, String info, int x, int y,                               int w, int h, int placement) {        _paintExtension(context, g, state, shadowType, x, y, w, h, placement,                        GTKColorType.LIGHT, GTKColorType.BACKGROUND,                        GTKColorType.BLACK, GTKColorType.DARK, false);    }    void _paintExtension(SynthContext context, Graphics g, int state,                    int shadowType, int x, int y,                    int w, int h, int placement, ColorType upperLeftType,                    ColorType backgroundType, ColorType bottomRightType,                    ColorType innerRightType, boolean paintWhite) {        GTKStyle style = (GTKStyle)context.getStyle();        TabContext tabContext = (TabContext)context;        JComponent c = context.getComponent();        Region region = context.getRegion();        int xThickness = style.getXThickness();        int yThickness = style.getYThickness();        if (xThickness < 0 && yThickness < 0) {            // nothing to paint.            return;        }        Color upperLeft =            style.getGTKColor(c, region, state, upperLeftType);        Color background =            style.getGTKColor(c, region, state, backgroundType);        Color bottomRight =            style.getGTKColor(c, region, state, bottomRightType);        Color innerRight =            style.getGTKColor(c, region, state, innerRightType);        Color white = style.getGTKColor(c, region, state, GTKColorType.WHITE);                int tabIndex = tabContext.getTabIndex();        int selectedIndex = ((JTabbedPane)c).getSelectedIndex();        g.translate(x, y);        // NOTE: placement refers to the size of the extension, so that        // BOTTOM corresponds to a TabbedPane with the tabs placed at the top.        if (placement == GTKConstants.BOTTOM) {            // Fill the background.            paintBackground(context, g, state, background, 0, 1, w, h);            if (tabIndex == selectedIndex || tabIndex == 0) {                g.setColor(upperLeft);                g.drawLine(0, 1, 0, h - 1);                g.drawLine(1, 0, w - 2, 0);                if (paintWhite) {                    g.setColor(white);                    g.drawLine(1, 1, 1, h - 1);                    g.drawLine(1, 1, w - 3, 1);                }            } else {                g.setColor(upperLeft);                g.drawLine(0, 0, w - 2, 0);                if (paintWhite) {                    g.setColor(white);                    g.drawLine(0, 1, w - 3, 1);                }            }            if ((tabIndex + 1) != selectedIndex) {                g.setColor(innerRight);                g.drawLine(w - 2, 2, w - 2, h - 1);                g.setColor(bottomRight);                g.drawLine(w - 1, 1, w - 1, h - 1);            }                    } else if (placement == GTKConstants.TOP) {            // Fill the background.            paintBackground(context, g, state, background, 0, 0, w, h - 1);            if (tabIndex == selectedIndex || tabIndex == 0) {                g.setColor(upperLeft);                g.drawLine(0, 0, 0, h - 2);                g.setColor(bottomRight);                g.drawLine(1, h - 1, w - 2, h - 1);                g.setColor(innerRight);                g.drawLine(2, h - 2, w - 2, h - 2);                if (paintWhite) {                    g.setColor(white);                    g.drawLine(1, 0, 1, h - 2);                }            } else {                g.setColor(bottomRight);                g.drawLine(0, h - 1, w - 2, h - 1);                g.setColor(innerRight);                g.drawLine(0, h - 2, w - 2, h - 2);                if (paintWhite) {                    g.setColor(white);                    g.drawLine(0, 0, 0, h - 2);                }            }            if ((tabIndex + 1) != selectedIndex) {                g.setColor(bottomRight);                g.drawLine(w - 1, 0, w - 1, h - 2);                g.setColor(innerRight);                g.drawLine(w - 2, 0, w - 2, h - 2);            }        } else if (placement == GTKConstants.RIGHT) {            // Fill the background.            paintBackground(context, g, state, background, 1, 0, w, h);            if (tabIndex == selectedIndex || tabIndex == 0) {                g.setColor(upperLeft);                 g.drawLine(1, 0, w - 1, 0);                g.drawLine(0, 1, 0, h - 2);                if (paintWhite) {                    g.setColor(white);                    g.drawLine(1, 1, w, 1);                    g.drawLine(1, 1, 1, h - 3);                }            } else {                g.setColor(upperLeft);                 g.drawLine(0, 0, 0, h - 2);                if (paintWhite) {                    g.setColor(white);                    g.drawLine(1, 1, 1, h - 3);                }            }            if ((tabIndex + 1) != selectedIndex) {                g.setColor(bottomRight);                g.drawLine(1, h - 1, w - 1, h - 1);                g.setColor(innerRight);                g.drawLine(2, h - 2, w - 1, h - 2);            }        } else if (placement == GTKConstants.LEFT) {            // Fill the background.            paintBackground(context, g, state, background, 0, 0, w - 1, h);            if (tabIndex == selectedIndex || tabIndex == 0) {                g.setColor(upperLeft);                g.drawLine(0, 0, w - 2, 0);                g.setColor(bottomRight);                g.drawLine(w - 1, 1, w - 1, h - 2);                g.setColor(innerRight);                g.drawLine(w - 2, 2, w - 2, h - 2);                if (paintWhite) {                    g.setColor(white);                    g.drawLine(0, 1, w - 2, 1);                    g.drawLine(w - 2, 1, w - 2, h - 3);                }            } else {                g.setColor(bottomRight);                g.drawLine(w - 1, 0, w - 1, h - 2);                g.setColor(innerRight);                g.drawLine(w - 2, 0, w - 2, h - 2);                if (paintWhite) {                    g.setColor(white);                    g.drawLine(w - 2, 1, w - 2, h - 3);                }            }            if ((tabIndex + 1) != selectedIndex) {                g.setColor(bottomRight);                g.drawLine(0, h - 1, w - 2, h - 1);                g.setColor(innerRight);                g.drawLine(0, h - 2, w - 2, h - 2);            }        }        g.translate(-x, -y);    }    void paintFlatBoxNormal(SynthContext context, Graphics g, int state,                             String key, int x, int y, int w, int h) {        g.setColor(((GTKStyle)context.getStyle()).getGTKColor(                context.getComponent(), context.getRegion(), state,                GTKColorType.BACKGROUND));        paintFlatBox(context, g, state, key, x, y, w, h);    }    void paintFlatBoxText(SynthContext context, Graphics g, int state,                             String key, int x, int y, int w, int h) {        g.setColor(((GTKStyle)context.getStyle()).getGTKColor(                context.getComponent(), context.getRegion(), state,                GTKColorType.TEXT_BACKGROUND));        paintFlatBox(context, g, state, key, x, y, w, h);    }    // NOTE: this assumes you have set the right color before calling this    public void paintFlatBox(SynthContext context, Graphics g, int state,                             String key, int x, int y, int w, int h) {        GTKStyle style = (GTKStyle)context.getStyle();        if (key == "cell_odd") {            g.fillRect(x, y, w, h);        }        else {            paintBackground(context, g, state, g.getColor(), x, y, w, h);        }        if (key == "tooltip") {            g.setColor(Color.BLACK);            g.drawRect(x, y, w - 1, h - 1);        }    }    public void paintFocus(SynthContext context, Graphics g, int state,                           String key, int x, int y, int w, int h) {        GTKStyle style = (GTKStyle)context.getStyle();        int[] pattern = (int[])style.getClassSpecificValue(                                     context, "focus-line-pattern");        int size = style.getClassSpecificIntValue(context,                                                  "focus-line-width", 1);        if (pattern == null) {            pattern = DEFAULT_FOCUS_PATTERN;        }        if (size <= 0) {            return;        }        g.setColor(getFocusColor(context, state));        _paintFocus(g, x, y, w, h, pattern, size);    }    void _paintFocus(Graphics g, int x, int y, int w, int h, int[] pattern,                     int size) {        g.translate(x, y);        // PENDING: This will need to be optimized        int initial = size / 2;        int offset = initial;        int index = 0;        int max1 = w - size;        int max2 = max1 + h - size;        int max3 = max2 + w - size;        int max4 = max3 + h;        while (offset < max4) {            int next = offset + pattern[index];            if (index % 2 == 0) {                if (offset < max1) {                    // top                    g.fillRect(offset, 0, Math.min(next, w) - offset, size);                    offset = Math.min(next, max1);                }                if (offset != next && offset < max2) {                    // right                    g.fillRect(w - size, offset - max1, size,                               Math.min(max2, next) - offset);

⌨️ 快捷键说明

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