< prev index next >

src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 24,43 **** --- 24,46 ---- */ package com.sun.java.swing.plaf.gtk; import sun.awt.UNIXToolkit; + import sun.awt.ModalExclude; + import sun.awt.SunToolkit; import javax.swing.plaf.synth.*; import java.awt.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.*; import com.sun.java.swing.plaf.gtk.GTKConstants.ArrowType; import com.sun.java.swing.plaf.gtk.GTKConstants.ExpanderStyle; import com.sun.java.swing.plaf.gtk.GTKConstants.Orientation; import com.sun.java.swing.plaf.gtk.GTKConstants.PositionType; import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType; + import java.awt.image.BufferedImage; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * @author Joshua Outwater
*** 565,576 **** 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); --- 568,581 ---- 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);
*** 580,590 **** 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, --- 585,613 ---- 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); ! } ! } } } public void paintProgressBarBackground(SynthContext context, Graphics g,
*** 697,706 **** --- 720,740 ---- if (orientation == JSeparator.HORIZONTAL) { w -= (insets.left + insets.right); } else { h -= (insets.top + insets.bottom); } + if (GTKLookAndFeel.is3()) { + if (id == Region.POPUP_MENU_SEPARATOR) { + detail = "menuitem"; + h -= (insets.top + insets.bottom); + } else { + detail = "separator"; + } + } else { + detail = orientation == JSeparator.HORIZONTAL ? + "hseparator" : "vseparator"; + } } synchronized (UNIXToolkit.GTK_LOCK) { if (! ENGINE.paintCachedImage(g, x, y, w, h, id, state, detail, orientation)) {
*** 741,750 **** --- 775,793 ---- } // The ubuntulooks engine paints slider troughs differently depending // on the current slider value and its component orientation. JSlider slider = (JSlider)context.getComponent(); + if (GTKLookAndFeel.is3()) { + if (slider.getOrientation() == JSlider.VERTICAL) { + y += 1; + h -= 2; + } else { + x += 1; + w -= 2; + } + } double value = slider.getValue(); double min = slider.getMinimum(); double max = slider.getMaximum(); double visible = 20; // not used for sliders; any value will work
*** 774,792 **** 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(); } } } --- 817,837 ---- 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()); + boolean hasFocus = GTKLookAndFeel.is3() && + ((context.getComponentState() & SynthConstants.FOCUSED) != 0); synchronized (UNIXToolkit.GTK_LOCK) { ! if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, dir, hasFocus)) { 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, hasFocus); ENGINE.finishPainting(); } } }
*** 961,997 **** 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 && (state & SynthConstants.FOCUSED) != 0) { if (!interiorFocus) { x -= focusSize; y -= focusSize; w += 2 * focusSize; h += 2 * focusSize; } else { if (containerParent instanceof JComboBox) { x += (focusSize + 2); ! y += (focusSize + 1); ! w -= (2 * focusSize + 1); ! h -= (2 * focusSize + 2); } else { ! x += focusSize; ! y += focusSize; ! w -= 2 * focusSize; ! h -= 2 * focusSize; } } ENGINE.paintFocus(g, context, id, gtkState, "entry", x, y, w, h); } --- 1006,1048 ---- int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); ENGINE.startPainting(g, x, y, w, h, id, state); + if (GTKLookAndFeel.is3()) { + ENGINE.paintBackground(g, context, id, gtkState, null, + x, y, w, h); + } ENGINE.paintShadow(g, context, id, gtkState, ShadowType.IN, "entry", x, y, w, h); + if (!GTKLookAndFeel.is3()) { 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 && (state & SynthConstants.FOCUSED) != 0) { if (!interiorFocus) { x -= focusSize; y -= focusSize; w += 2 * focusSize; h += 2 * focusSize; } else { if (containerParent instanceof JComboBox) { x += (focusSize + 2); ! y += focusSize + (GTKLookAndFeel.is3() ? 3 : 1); ! w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 1); ! h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 6 : 2); } else { ! x += focusSize + (GTKLookAndFeel.is3() ? 2 : 0); ! y += focusSize + (GTKLookAndFeel.is3() ? 2 :0 ); ! w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0); ! h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0); } } ENGINE.paintFocus(g, context, id, gtkState, "entry", x, y, w, h); }
*** 1137,1147 **** dir, value, visible, rtl); Orientation orientation = (dir == JScrollBar.HORIZONTAL ? Orientation.HORIZONTAL : Orientation.VERTICAL); ENGINE.setRangeValue(context, id, value, min, max, visible); ENGINE.paintSlider(g, context, id, gtkState, ! ShadowType.OUT, "slider", x, y, w, h, orientation); ENGINE.finishPainting(); } } } --- 1188,1198 ---- dir, value, visible, rtl); Orientation orientation = (dir == JScrollBar.HORIZONTAL ? Orientation.HORIZONTAL : Orientation.VERTICAL); ENGINE.setRangeValue(context, id, value, min, max, visible); ENGINE.paintSlider(g, context, id, gtkState, ! ShadowType.OUT, "slider", x, y, w, h, orientation, false); ENGINE.finishPainting(); } } }
*** 1293,1310 **** public void paintTreeExpandedIcon(SynthContext context, Graphics g, int state, int x, int y, int w, int h) { ENGINE.paintExpander(g, context, Region.TREE, GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state), ! ExpanderStyle.EXPANDED, "treeview", x, y, w, h); } public void paintTreeCollapsedIcon(SynthContext context, Graphics g, int state, int x, int y, int w, int h) { ENGINE.paintExpander(g, context, Region.TREE, GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state), ! ExpanderStyle.COLLAPSED, "treeview", x, y, w, h); } public void paintCheckBoxIcon(SynthContext context, Graphics g, int state, int x, int y, int w, int h) { GTKStyle style = (GTKStyle)context.getStyle(); --- 1344,1361 ---- public void paintTreeExpandedIcon(SynthContext context, Graphics g, int state, int x, int y, int w, int h) { ENGINE.paintExpander(g, context, Region.TREE, GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state), ! ExpanderStyle.EXPANDED, "expander", x, y, w, h); } public void paintTreeCollapsedIcon(SynthContext context, Graphics g, int state, int x, int y, int w, int h) { ENGINE.paintExpander(g, context, Region.TREE, GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state), ! ExpanderStyle.COLLAPSED, "expander", x, y, w, h); } public void paintCheckBoxIcon(SynthContext context, Graphics g, int state, int x, int y, int w, int h) { GTKStyle style = (GTKStyle)context.getStyle();
*** 1335,1346 **** context.getRegion(), state); ShadowType shadow = ShadowType.OUT; if (gtkState == SynthConstants.MOUSE_OVER) { shadow = ShadowType.IN; } ENGINE.paintArrow(g, context, Region.MENU_ITEM, gtkState, shadow, ! dir, "menuitem", x + 3, y + 3, 7, 7); } public void paintCheckBoxMenuItemCheckIcon(SynthContext context, Graphics g, int state, int x, int y, int w, int h) { --- 1386,1402 ---- context.getRegion(), state); ShadowType shadow = ShadowType.OUT; if (gtkState == SynthConstants.MOUSE_OVER) { shadow = ShadowType.IN; } + if (!GTKLookAndFeel.is3()) { + x += 3; + y += 3; + w = h = 7; + } ENGINE.paintArrow(g, context, Region.MENU_ITEM, gtkState, shadow, ! dir, "menuitem", x, y, w, h); } public void paintCheckBoxMenuItemCheckIcon(SynthContext context, Graphics g, int state, int x, int y, int w, int h) {
< prev index next >