gtkpainter.java

来自「Mobile 应用程序使用 Java Micro Edition (Java M」· Java 代码 · 共 1,409 行 · 第 1/4 页

JAVA
1,409
字号
                        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,                        w - 2 * focusSize, h - 2 * focusSize);                if (focused) {                    ENGINE.paintFocus(g, context, id, SynthConstants.ENABLED,                            "trough", x, y, w, h);                }                ENGINE.finishPainting();            }        }    }    public void paintSliderThumbBackground(SynthContext context,            Graphics g, int x, int y, int w, int h, int dir) {        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, dir)) {                Orientation orientation = (dir == JSlider.HORIZONTAL ?                    Orientation.HORIZONTAL : Orientation.VERTICAL);                String detail = (dir == JSlider.HORIZONTAL ?                    "hscale" : "vscale");                ENGINE.startPainting(g, x, y, w, h, id, gtkState, dir);                ENGINE.paintSlider(g, context, id, gtkState,                        ShadowType.OUT, detail, x, y, w, h, orientation);                ENGINE.finishPainting();            }        }    }    //    // SPINNER    //    public void paintSpinnerBackground(SynthContext context,                                        Graphics g,                                        int x, int y, int w, int h) {        // This is handled in paintTextFieldBackground    }    //    // SPLIT_PANE_DIVIDER    //    public void paintSplitPaneDividerBackground(SynthContext context,                                       Graphics g,                                       int x, int y, int w, int h) {        Region id = context.getRegion();        int gtkState = GTKLookAndFeel.synthStateToGTKState(                id, context.getComponentState());        JSplitPane splitPane = (JSplitPane)context.getComponent();        Orientation orientation =                (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT ?                    Orientation.VERTICAL : Orientation.HORIZONTAL);        synchronized (UNIXToolkit.GTK_LOCK) {            if (! ENGINE.paintCachedImage(g, x, y, w, h,                    id, gtkState, orientation)) {                ENGINE.startPainting(g, x, y, w, h, id, gtkState, orientation);                ENGINE.paintHandle(g, context, id, gtkState,                        ShadowType.OUT, "paned", x, y, w, h, orientation);                ENGINE.finishPainting();            }        }    }    public void paintSplitPaneDragDivider(SynthContext context,                                       Graphics g,int x, int y, int w, int h,                                       int orientation) {        paintSplitPaneDividerForeground(context, g, x, y, w, h, orientation);    }    public void paintTabbedPaneContentBackground(SynthContext context,                                      Graphics g, int x, int y, int w, int h) {        JTabbedPane pane = (JTabbedPane)context.getComponent();        int selectedIndex = pane.getSelectedIndex();        PositionType placement = GTKLookAndFeel.SwingOrientationConstantToGTK(                                                        pane.getTabPlacement());        int gapStart = 0;        int gapSize = 0;        if (selectedIndex != -1) {            Rectangle tabBounds = pane.getBoundsAt(selectedIndex);            if (placement == PositionType.TOP ||                placement == PositionType.BOTTOM) {                                gapStart = tabBounds.x - 1;                gapSize = tabBounds.width;            }            else {                gapStart = tabBounds.y - 1;                gapSize = tabBounds.height;            }        }        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, placement, gapStart, gapSize)) {                ENGINE.startPainting(g, x, y, w, h,                        id, gtkState, placement, gapStart, gapSize);                ENGINE.paintBoxGap(g, context, id, gtkState, ShadowType.OUT,                        "notebook", x, y, w, h, placement, gapStart, gapSize);                ENGINE.finishPainting();            }        }    }        public void paintTabbedPaneTabBackground(SynthContext context,                                           Graphics g,                                           int x, int y, int w, int h,                                           int tabIndex) {        Region id = context.getRegion();        int state = context.getComponentState();        int gtkState = ((state & SynthConstants.SELECTED) != 0 ?            SynthConstants.ENABLED : SynthConstants.PRESSED);        JTabbedPane pane = (JTabbedPane)context.getComponent();        int placement = pane.getTabPlacement();        synchronized (UNIXToolkit.GTK_LOCK) {            if (! ENGINE.paintCachedImage(g, x, y, w, h,                    id, gtkState, placement, tabIndex)) {                PositionType side = POSITIONS[placement - 1];                ENGINE.startPainting(g, x, y, w, h,                        id, gtkState, placement, tabIndex);                ENGINE.paintExtension(g, context, id, gtkState,                        ShadowType.OUT, "tab", x, y, w, h, side, tabIndex);                ENGINE.finishPainting();            }        }    }    //    // TEXT_AREA    //    public void paintTextAreaBackground(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);    }    //    // TEXT_FIELD    //    // NOTE: Combobox and Label, Password and FormattedTextField calls this    // too.    private void paintTextBackground(SynthContext context, Graphics g,                                     int x, int y, int w, int h) {        // Text is odd in that it uses the TEXT_BACKGROUND vs BACKGROUND.        JComponent c = context.getComponent();        GTKStyle style = (GTKStyle)context.getStyle();        Region id = context.getRegion();        int state = context.getComponentState();        synchronized (UNIXToolkit.GTK_LOCK) {            if (ENGINE.paintCachedImage(g, x, y, w, h, id, state)) {                return;            }                        int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state);            int focusSize = 0;            boolean interiorFocus = style.getClassSpecificBoolValue(                    context, "interior-focus", true);            if (!interiorFocus && (state & SynthConstants.FOCUSED) != 0) {                focusSize = style.getClassSpecificIntValue(context,                        "focus-line-width",1);                x += focusSize;                y += focusSize;                w -= 2 * focusSize;                h -= 2 * focusSize;            }                            int xThickness = style.getXThickness();            int yThickness = style.getYThickness();                            ENGINE.startPainting(g, x, y, w, h, id, state);            ENGINE.paintShadow(g, context, id, gtkState,                    ShadowType.IN, "entry", x, y, w, h);            ENGINE.paintFlatBox(g, context, id,                                gtkState, ShadowType.NONE, "entry_bg",                                 x + xThickness,                                 y + yThickness,                                 w - (2 * xThickness),                                 h - (2 * yThickness),                                 ColorType.TEXT_BACKGROUND);             if (focusSize > 0) {                x -= focusSize;                y -= focusSize;                w += 2 * focusSize;                h += 2 * focusSize;                ENGINE.paintFocus(g, context, id, gtkState,                        "entry", x, y, w, h);            }            ENGINE.finishPainting();        }    }                private void paintTreeCellEditorBackground(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)) {                ENGINE.startPainting(g, x, y, w, h, id, gtkState);                ENGINE.paintFlatBox(g, context, id, gtkState, ShadowType.NONE,                        "entry_bg", x, y, w, h, ColorType.TEXT_BACKGROUND);                ENGINE.finishPainting();            }        }    }    //    // ROOT_PANE    //    public void paintRootPaneBackground(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.BACKGROUND);    }        //    // TOGGLE_BUTTON    //    public void paintToggleButtonBackground(SynthContext context,                                            Graphics g,                                            int x, int y, int w, int h) {        Region id = context.getRegion();        JToggleButton toggleButton = (JToggleButton)context.getComponent();        boolean paintBG = toggleButton.isContentAreaFilled() &&                          toggleButton.isBorderPainted();        boolean paintFocus = toggleButton.isFocusPainted();        boolean toolButton = (toggleButton.getParent() instanceof JToolBar);        paintButtonBackgroundImpl(context, g, id, "button",                                  x, y, w, h,                                  paintBG, paintFocus, false, toolButton);    }    //    // SCROLL_BAR    //    public void paintScrollBarBackground(SynthContext context,                                          Graphics g,                                          int x, int y, int w,int h) {        Region id = context.getRegion();        boolean focused =                 (context.getComponentState() & SynthConstants.FOCUSED) != 0;        synchronized (UNIXToolkit.GTK_LOCK) {            if (ENGINE.paintCachedImage(g, x, y, w, h, id, focused)) {                return;            }            ENGINE.startPainting(g, x, y, w, h, id, focused);            // Note: the scrollbar insets already include the "trough-border",            // which is needed to position the scrollbar buttons properly.            // But when we render, we need to take the trough border out            // of the equation so that we paint the entire area covered by            // the trough border and the scrollbar content itself.            Insets insets = context.getComponent().getInsets();            GTKStyle style = (GTKStyle)context.getStyle();            int troughBorder =                 style.getClassSpecificIntValue(context, "trough-border", 1);             insets.left   -= troughBorder;             insets.right  -= troughBorder;             insets.top    -= troughBorder;             insets.bottom -= troughBorder;                         ENGINE.paintBox(g, context, id, SynthConstants.PRESSED,                            ShadowType.IN, "trough",                             x + insets.left,                             y + insets.top,                             w - insets.left - insets.right,                             h - insets.top - insets.bottom);                        if (focused) {                ENGINE.paintFocus(g, context, id,                        SynthConstants.ENABLED, "trough", x, y, w, h);            }            ENGINE.finishPainting();        }    }    //    // SCROLL_BAR_THUMB    //    public void paintScrollBarThumbBackground(SynthContext context,            Graphics g, int x, int y, int w, int h, int dir) {        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, dir)) {                ENGINE.startPainting(g, x, y, w, h, id, gtkState, dir);                Orientation orientation = (dir == JScrollBar.HORIZONTAL ?                    Orientation.HORIZONTAL : Orientation.VERTICAL);                ENGINE.paintSlider(g, context, id, gtkState,                        ShadowType.OUT, "slider", x, y, w, h, orientation);                ENGINE.finishPainting();            }        }    }    //    // TOOL_TIP    //    public void paintToolTipBackground(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.paintFlatBox(g, context, id, SynthConstants.ENABLED,                        ShadowType.OUT, "tooltip", x, y, w, h,                        ColorType.BACKGROUND);                ENGINE.finishPainting();            }        }    }    //    // TREE_CELL    //    public void paintTreeCellBackground(SynthContext context, Graphics g,                                        int x, int y, int w, int h) {        Region id = context.getRegion();        int state = context.getComponentState();        int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state);        synchronized (UNIXToolkit.GTK_LOCK) {            if (! ENGINE.paintCachedImage(g, x, y, w, h, id, state)) {                ENGINE.startPainting(g, x, y, w, h, id, state);                // the string arg should alternate based on row being painted,                // but we currently don't pass that in.                ENGINE.paintFlatBox(g, context, id, gtkState, ShadowType.NONE,                        "cell_odd", x, y, w, h, ColorType.TEXT_BACKGROUND);

⌨️ 快捷键说明

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