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

📄 gtkpainter.java

📁 JAVA 所有包
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    y -= totalFocusSize;                    w += 2 * totalFocusSize;                    h += 2 * totalFocusSize;                }                ENGINE.paintFocus(g, context, id, gtkState, detail, x, y, w, h);            }            ENGINE.finishPainting();        }    }    //    // ARROW_BUTTON    //    public void paintArrowButtonForeground(SynthContext context, Graphics g,                                           int x, int y, int w, int h,                                           int direction) {        Region id = context.getRegion();        Component c = context.getComponent();        String name = c.getName();        ArrowType arrowType = null;        switch (direction) {            case SwingConstants.NORTH:                arrowType = ArrowType.UP; break;            case SwingConstants.SOUTH:                arrowType = ArrowType.DOWN; break;            case SwingConstants.EAST:                arrowType = ArrowType.RIGHT; break;            case SwingConstants.WEST:                arrowType = ArrowType.LEFT; break;        }        String detail = "arrow";        if (name == "ScrollBar.button") {            if (arrowType == ArrowType.UP || arrowType == ArrowType.DOWN) {                detail = "vscrollbar";            } else {                detail = "hscrollbar";            }            id = Region.SCROLL_BAR;        } else if (name == "Spinner.nextButton" ||                   name == "Spinner.previousButton") {            detail = "spinbutton";        } else if (name == "ComboBox.arrowButton") {            id = Region.COMBO_BOX;        } else {            assert false;        }                int gtkState = GTKLookAndFeel.synthStateToGTKState(                id, context.getComponentState());        ShadowType shadowType = (gtkState == SynthConstants.PRESSED ?            ShadowType.IN : ShadowType.OUT);        synchronized (UNIXToolkit.GTK_LOCK) {            if (ENGINE.paintCachedImage(g, x, y, w, h,                    gtkState, name, direction)) {                return;            }            ENGINE.startPainting(g, x, y, w, h, gtkState, name, direction);            ENGINE.paintArrow(g, context, id, gtkState,                    shadowType, arrowType, detail, x, y, w, h);            ENGINE.finishPainting();        }    }    public void paintArrowButtonBackground(SynthContext context,            Graphics g, int x, int y, int w, int h) {        Region id = context.getRegion();        AbstractButton button = (AbstractButton)context.getComponent();        boolean paintBG = button.isContentAreaFilled() &&                          button.isBorderPainted();        boolean focusPainted = button.isFocusPainted();        String name = button.getName();        String detail = "button";        if (name == "ScrollBar.button") {            Component parent = button.getParent();            if (parent instanceof JScrollBar) {                if (((JScrollBar)parent).getOrientation() ==                        SwingConstants.HORIZONTAL) {                    detail = "hscrollbar";                } else {                    detail = "vscrollbar";                }                id = Region.SCROLL_BAR;            }        } else if (name == "Spinner.previousButton") {            detail = "spinbutton_down";        } else if (name == "Spinner.nextButton") {            detail = "spinbutton_up";        } else if (name == "ComboBox.arrowButton") {            id = Region.BUTTON;        }        paintButtonBackgroundImpl(context, g, id, detail, x, y, w, h,                paintBG, focusPainted, false, false);    }    //    // LIST    //    public void paintListBackground(SynthContext context, Graphics g,                                    int x, int y, int w, int h) {        // Does not call into ENGINE for better performance        fillArea(context, g, x, y, w, h, GTKColorType.TEXT_BACKGROUND);    }        public void paintMenuBarBackground(SynthContext context, Graphics g,                                       int x, int y, int w, int h) {        Region id = context.getRegion();        synchronized (UNIXToolkit.GTK_LOCK) {            if (ENGINE.paintCachedImage(g, x, y, w, h, id)) {                return;            }            GTKStyle style = (GTKStyle)context.getStyle();            int shadow = style.getClassSpecificIntValue(                    context, "shadow-type", 2);            ShadowType shadowType = SHADOWS[shadow];            int gtkState = GTKLookAndFeel.synthStateToGTKState(                    id, context.getComponentState());            ENGINE.startPainting(g, x, y, w, h, id);            ENGINE.paintBox(g, context, id, gtkState,                shadowType, "menubar", x, y, w, h);            ENGINE.finishPainting();        }    }    //    // MENU    //    public void paintMenuBackground(SynthContext context,                                     Graphics g,                                     int x, int y, int w, int h) {        paintMenuItemBackground(context, g, x, y, w, h);    }    // This is called for both MENU and MENU_ITEM    public void paintMenuItemBackground(SynthContext context,                                     Graphics g,                                     int x, int y, int w, int h) {        int gtkState = GTKLookAndFeel.synthStateToGTKState(                context.getRegion(), context.getComponentState());        if (gtkState == SynthConstants.MOUSE_OVER) {            Region id = Region.MENU_ITEM;            synchronized (UNIXToolkit.GTK_LOCK) {                if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) {                    ShadowType shadow = (GTKLookAndFeel.is2_2() ?                        ShadowType.NONE : ShadowType.OUT);                    ENGINE.startPainting(g, x, y, w, h, id);                    ENGINE.paintBox(g, context, id, gtkState, shadow,                            "menuitem", x, y, w, h);                    ENGINE.finishPainting();                }            }        }    }    public void paintPopupMenuBackground(SynthContext context, Graphics g,                                        int x, int y, int w, int h) {        Region id = context.getRegion();        int gtkState = GTKLookAndFeel.synthStateToGTKState(                id, context.getComponentState());        synchronized (UNIXToolkit.GTK_LOCK) {            if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState)) {                return;            }            ENGINE.startPainting(g, x, y, w, h, id, gtkState);            ENGINE.paintBox(g, context, id, gtkState,                    ShadowType.OUT, "menu", x, y, w, h);            GTKStyle style = (GTKStyle)context.getStyle();            int xThickness = style.getXThickness();            int yThickness = style.getYThickness();            ENGINE.paintBackground(g, context, id, gtkState,                    style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),                    x + xThickness, y + yThickness,                    w - xThickness - xThickness, h - yThickness - yThickness);            ENGINE.finishPainting();        }    }    public void paintProgressBarBackground(SynthContext context,                                            Graphics g,                                            int x, int y, int w, int h) {        Region id = context.getRegion();        synchronized (UNIXToolkit.GTK_LOCK) {            if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) {                ENGINE.startPainting(g, x, y, w, h, id);                ENGINE.paintBox(g, context, id, SynthConstants.ENABLED,                        ShadowType.IN, "trough", x, y, w, h);                ENGINE.finishPainting();            }        }    }    public void paintProgressBarForeground(SynthContext context, Graphics g,                                            int x, int y, int w, int h,                                            int orientation) {        Region id = context.getRegion();        synchronized (UNIXToolkit.GTK_LOCK) {            if (! ENGINE.paintCachedImage(g, x, y, w, h, id, "fg")) {                ENGINE.startPainting(g, x, y, w, h, id, "fg");                ENGINE.paintBox(g, context, id, SynthConstants.MOUSE_OVER,                        ShadowType.OUT, "bar", x, y, w, h);                ENGINE.finishPainting();            }        }    }    public void paintViewportBorder(SynthContext context, Graphics g,                                           int x, int y, int w, int h) {        Region id = context.getRegion();        synchronized (UNIXToolkit.GTK_LOCK) {            if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) {                ENGINE.startPainting(g, x, y, w, h, id);                ENGINE.paintShadow(g, context, id, SynthConstants.ENABLED,                        ShadowType.IN, "scrolled_window", x, y, w, h);                ENGINE.finishPainting();            }        }    }    public void paintScrollPaneBorder(SynthContext context, Graphics g,                                           int x, int y, int w, int h) {        paintViewportBorder(context, g, x, y, w, h);    }    public void paintSeparatorBackground(SynthContext context,                                          Graphics g,                                          int x, int y, int w, int h,                                         int orientation) {        Region id = context.getRegion();        int state = context.getComponentState();        JComponent c = context.getComponent();        /*         * Note: In theory, the style's x/y thickness values would determine         * the width of the separator content.  In practice, however, some         * engines will render a line that is wider than the corresponding         * thickness value.  For example, ubuntulooks reports x/y thickness         * values of 1 for separators, but always renders a 2-pixel wide line.         * As a result of all this, we need to be careful not to restrict         * the w/h values below too much, so that the full thickness of the         * rendered line will be captured by our image caching code.         */        String detail;        if (c instanceof JToolBar.Separator) {            /*             * GTK renders toolbar separators differently in that an             * artificial padding is added to each end of the separator.             * The value of 0.2f below is derived from the source code of             * gtktoolbar.c in the current version of GTK+ (2.8.20 at the             * time of this writing).  Specifically, the relevant values are:             *     SPACE_LINE_DIVISION 10.0             *     SPACE_LINE_START     2.0             *     SPACE_LINE_END       8.0             * These are used to determine the distance from the top (or left)             * edge of the toolbar to the other edge.  So for example, the             * starting/top point of a vertical separator is 2/10 of the             * height of a horizontal toolbar away from the top edge, which             * is how we arrive at 0.2f below.  Likewise, the ending/bottom             * point is 8/10 of the height away from the top edge, or in other             * words, it is 2/10 away from the bottom edge, which is again             * how we arrive at the 0.2f value below.             *             * The separator is also centered horizontally or vertically,             * depending on its orientation.  This was determined empirically             * and by examining the code referenced above.             */            detail = "toolbar";            float pct = 0.2f;            JToolBar.Separator sep = (JToolBar.Separator)c;            Dimension size = sep.getSeparatorSize();            GTKStyle style = (GTKStyle)context.getStyle();            if (orientation == JSeparator.HORIZONTAL) {                x += (int)(w * pct);                w -= (int)(w * pct * 2);                y += (size.height - style.getYThickness()) / 2;            } else {                y += (int)(h * pct);                h -= (int)(h * pct * 2);                x += (size.width - style.getXThickness()) / 2;            }        } else {            // For regular/menu separators, we simply subtract out the insets.            detail = "separator";            Insets insets = c.getInsets();            x += insets.left;            y += insets.top;            if (orientation == JSeparator.HORIZONTAL) {                w -= (insets.left + insets.right);            } else {                h -= (insets.top + insets.bottom);            }        }        synchronized (UNIXToolkit.GTK_LOCK) {            if (! ENGINE.paintCachedImage(g, x, y, w, h, id,                                          state, detail, orientation)) {                ENGINE.startPainting(g, x, y, w, h, id,                                     state, detail, orientation);                if (orientation == JSeparator.HORIZONTAL) {                    ENGINE.paintHline(g, context, id, state,                                      detail, x, y, w, h);                } else {                    ENGINE.paintVline(g, context, id, state,                                      detail, x, y, w, h);                }                ENGINE.finishPainting();            }        }    }    public void paintSliderTrackBackground(SynthContext context,                                       Graphics g,                                       int x, int y, int w,int h) {        Region id = context.getRegion();        int state = context.getComponentState();        // For focused sliders, we paint focus rect outside the bounds passed.        // Need to adjust for that.        boolean focused = ((state & SynthConstants.FOCUSED) != 0);        int focusSize = 0;        if (focused) {            GTKStyle style = (GTKStyle)context.getStyle();            focusSize = style.getClassSpecificIntValue(                                context, "focus-line-width", 1) +                        style.getClassSpecificIntValue(                                context, "focus-padding", 1);            x -= focusSize;            y -= focusSize;            w += focusSize * 2;            h += focusSize * 2;        }        synchronized (UNIXToolkit.GTK_LOCK) {            if (! ENGINE.paintCachedImage(g, x, y, w, h, id, state)) {                ENGINE.startPainting(g, x, y, w, h, id, state);                int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state);                ENGINE.paintBox(g, context, id, gtkState, ShadowType.IN,                        "trough", x + focusSize, y + focusSize,

⌨️ 快捷键说明

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