Java Code Examples for sun.awt.SunToolkit#getHeavyweightComponent()

The following examples show how to use sun.awt.SunToolkit#getHeavyweightComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XGlobalCursorManager.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 2
Source File: XGlobalCursorManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 3
Source File: XGlobalCursorManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 4
Source File: XGlobalCursorManager.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 5
Source File: XGlobalCursorManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 6
Source File: XGlobalCursorManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 7
Source File: XGlobalCursorManager.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 8
Source File: XGlobalCursorManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 9
Source File: XGlobalCursorManager.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 10
Source File: XGlobalCursorManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 11
Source File: XGlobalCursorManager.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 12
Source File: XGlobalCursorManager.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 13
Source File: XGlobalCursorManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
    if (comp == null) {
        return;
    }

    Cursor cur = useCache ? cursor : getCapableCursor(comp);

    Component nc = null;
    if (useCache) {
        synchronized (this) {
            nc = nativeContainer.get();
        }
    } else {
       nc = SunToolkit.getHeavyweightComponent(comp);
    }

    if (nc != null) {
        ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
        if (nc_peer instanceof XComponentPeer) {
            synchronized (this) {
                nativeContainer = new WeakReference<Component>(nc);
            }

            //6431076. A subcomponents (a XTextArea in particular)
            //may want to override the cursor over some of their parts.
            ((XComponentPeer)nc_peer).pSetCursor(cur, false);
            // in case of grab we do for Swing we need to update keep cursor updated
            // (we don't need this in case of AWT menus).  Window Manager consider
            // the grabber as a current window and use its cursor.  So we need to
            // change cursor on the grabber too.
            updateGrabbedCursor(cur);
        }
    }
}
 
Example 14
Source File: GTKPainter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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());
    boolean isHW = SunToolkit.getHeavyweightComponent(
            context.getComponent()) instanceof ModalExclude;
    synchronized (UNIXToolkit.GTK_LOCK) {
        if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, isHW)) {
            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();
        Insets insets = style.getInsets(context, null);
        ENGINE.paintBackground(g, context, id, gtkState,
            style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
            x + insets.left, y + insets.top, w - insets.left - insets.right,
            h - insets.top - insets.bottom);
        BufferedImage img = ENGINE.finishPainting();
        if(!isHW) {
            int border = img.getRGB(0, h / 2);
            if (img != null && border == img.getRGB(w / 2, h / 2)) {
                // fix no menu borders in Adwaita theme
                Graphics g2 = img.getGraphics();
                Color c = new Color(border);
                g2.setColor(new Color(Math.max((int) (c.getRed() * 0.8), 0),
                        Math.max((int) (c.getGreen() * 0.8), 0),
                        Math.max((int) (c.getBlue() * 0.8), 0)));
                g2.drawLine(0, 0, w - 1, 0);
                g2.drawLine(w - 1, 0, w - 1, h - 1);
                g2.drawLine(0, h - 1, 0, 1);
                g2.setColor(c.darker());
                g2.drawLine(w - 1, h - 1, 0, h - 1);
                g2.dispose();
                g.drawImage(img, x, y, null);
            }
        }
    }
}
 
Example 15
Source File: GTKPainter.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
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());
    boolean isHW = SunToolkit.getHeavyweightComponent(
            context.getComponent()) instanceof ModalExclude;
    synchronized (UNIXToolkit.GTK_LOCK) {
        if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, isHW)) {
            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();
        Insets insets = style.getInsets(context, null);
        ENGINE.paintBackground(g, context, id, gtkState,
            style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
            x + insets.left, y + insets.top, w - insets.left - insets.right,
            h - insets.top - insets.bottom);
        BufferedImage img = ENGINE.finishPainting();
        if(!isHW) {
            int border = img.getRGB(0, h / 2);
            if (img != null && border == img.getRGB(w / 2, h / 2)) {
                // fix no menu borders in Adwaita theme
                Graphics g2 = img.getGraphics();
                Color c = new Color(border);
                g2.setColor(new Color(Math.max((int) (c.getRed() * 0.8), 0),
                        Math.max((int) (c.getGreen() * 0.8), 0),
                        Math.max((int) (c.getBlue() * 0.8), 0)));
                g2.drawLine(0, 0, w - 1, 0);
                g2.drawLine(w - 1, 0, w - 1, h - 1);
                g2.drawLine(0, h - 1, 0, 1);
                g2.setColor(c.darker());
                g2.drawLine(w - 1, h - 1, 0, h - 1);
                g2.dispose();
                g.drawImage(img, x, y, null);
            }
        }
    }
}
 
Example 16
Source File: GTKPainter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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());
    boolean isHW = SunToolkit.getHeavyweightComponent(
            context.getComponent()) instanceof ModalExclude;
    synchronized (UNIXToolkit.GTK_LOCK) {
        if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, isHW)) {
            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);
        BufferedImage img = ENGINE.finishPainting();
        if(!isHW) {
            int border = img.getRGB(0, h / 2);
            if (img != null && border == img.getRGB(w / 2, h / 2)) {
                // fix no menu borders in Adwaita theme
                Graphics g2 = img.getGraphics();
                Color c = new Color(border);
                g2.setColor(new Color(Math.max((int) (c.getRed() * 0.8), 0),
                        Math.max((int) (c.getGreen() * 0.8), 0),
                        Math.max((int) (c.getBlue() * 0.8), 0)));
                g2.drawLine(0, 0, w - 1, 0);
                g2.drawLine(w - 1, 0, w - 1, h - 1);
                g2.drawLine(0, h - 1, 0, 1);
                g2.setColor(c.darker());
                g2.drawLine(w - 1, h - 1, 0, h - 1);
                g2.dispose();
                g.drawImage(img, x, y, null);
            }
        }
    }
}
 
Example 17
Source File: GTKPainter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
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());
    boolean isHW = SunToolkit.getHeavyweightComponent(
            context.getComponent()) instanceof ModalExclude;
    synchronized (UNIXToolkit.GTK_LOCK) {
        if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, isHW)) {
            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);
        BufferedImage img = ENGINE.finishPainting();
        if(!isHW) {
            int border = img.getRGB(0, h / 2);
            if (img != null && border == img.getRGB(w / 2, h / 2)) {
                // fix no menu borders in Adwaita theme
                Graphics g2 = img.getGraphics();
                Color c = new Color(border);
                g2.setColor(new Color(Math.max((int) (c.getRed() * 0.8), 0),
                        Math.max((int) (c.getGreen() * 0.8), 0),
                        Math.max((int) (c.getBlue() * 0.8), 0)));
                g2.drawLine(0, 0, w - 1, 0);
                g2.drawLine(w - 1, 0, w - 1, h - 1);
                g2.drawLine(0, h - 1, 0, 1);
                g2.setColor(c.darker());
                g2.drawLine(w - 1, h - 1, 0, h - 1);
                g2.dispose();
                g.drawImage(img, x, y, null);
            }
        }
    }
}
 
Example 18
Source File: GTKPainter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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());
    boolean isHW = SunToolkit.getHeavyweightComponent(
            context.getComponent()) instanceof ModalExclude;
    synchronized (UNIXToolkit.GTK_LOCK) {
        if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, isHW)) {
            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);
        BufferedImage img = ENGINE.finishPainting();
        if(!isHW) {
            int border = img.getRGB(0, h / 2);
            if (img != null && border == img.getRGB(w / 2, h / 2)) {
                // fix no menu borders in Adwaita theme
                Graphics g2 = img.getGraphics();
                Color c = new Color(border);
                g2.setColor(new Color(Math.max((int) (c.getRed() * 0.8), 0),
                        Math.max((int) (c.getGreen() * 0.8), 0),
                        Math.max((int) (c.getBlue() * 0.8), 0)));
                g2.drawLine(0, 0, w - 1, 0);
                g2.drawLine(w - 1, 0, w - 1, h - 1);
                g2.drawLine(0, h - 1, 0, 1);
                g2.setColor(c.darker());
                g2.drawLine(w - 1, h - 1, 0, h - 1);
                g2.dispose();
                g.drawImage(img, x, y, null);
            }
        }
    }
}
 
Example 19
Source File: GTKPainter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
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());
    boolean isHW = SunToolkit.getHeavyweightComponent(
            context.getComponent()) instanceof ModalExclude;
    synchronized (UNIXToolkit.GTK_LOCK) {
        if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, isHW)) {
            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);
        BufferedImage img = ENGINE.finishPainting();
        if(!isHW) {
            int border = img.getRGB(0, h / 2);
            if (img != null && border == img.getRGB(w / 2, h / 2)) {
                // fix no menu borders in Adwaita theme
                Graphics g2 = img.getGraphics();
                Color c = new Color(border);
                g2.setColor(new Color(Math.max((int) (c.getRed() * 0.8), 0),
                        Math.max((int) (c.getGreen() * 0.8), 0),
                        Math.max((int) (c.getBlue() * 0.8), 0)));
                g2.drawLine(0, 0, w - 1, 0);
                g2.drawLine(w - 1, 0, w - 1, h - 1);
                g2.drawLine(0, h - 1, 0, 1);
                g2.setColor(c.darker());
                g2.drawLine(w - 1, h - 1, 0, h - 1);
                g2.dispose();
                g.drawImage(img, x, y, null);
            }
        }
    }
}