756 757 } 758 759 public void endLayout() { 760 if (!paintPending && !paintArea.isEmpty() 761 && !AWTAccessor.getComponentAccessor().getIgnoreRepaint(target)) 762 { 763 // if not waiting for native painting repaint damaged area 764 postEvent(new PaintEvent(target, PaintEvent.PAINT, 765 new Rectangle())); 766 } 767 isLayouting = false; 768 } 769 770 public Color getWinBackground() { 771 return getPeerBackground(); 772 } 773 774 static int[] getRGBvals(Color c) { 775 776 int rgbvals[] = new int[3]; 777 778 rgbvals[0] = c.getRed(); 779 rgbvals[1] = c.getGreen(); 780 rgbvals[2] = c.getBlue(); 781 782 return rgbvals; 783 } 784 785 static final int BACKGROUND_COLOR = 0; 786 static final int HIGHLIGHT_COLOR = 1; 787 static final int SHADOW_COLOR = 2; 788 static final int FOREGROUND_COLOR = 3; 789 790 public Color[] getGUIcolors() { 791 Color c[] = new Color[4]; 792 float backb, highb, shadowb, hue, saturation; 793 c[BACKGROUND_COLOR] = getWinBackground(); 794 if (c[BACKGROUND_COLOR] == null) { 795 c[BACKGROUND_COLOR] = super.getWinBackground(); 796 } 797 if (c[BACKGROUND_COLOR] == null) { 798 c[BACKGROUND_COLOR] = Color.lightGray; 799 } 800 801 int[] rgb = getRGBvals(c[BACKGROUND_COLOR]); 802 803 float[] hsb = Color.RGBtoHSB(rgb[0],rgb[1],rgb[2],null); 804 805 hue = hsb[0]; 806 saturation = hsb[1]; 807 backb = hsb[2]; 808 809 810 /* Calculate Highlight Brightness */ 811 890 /** 891 * Returns an array of Colors similar to getGUIcolors(), but using the 892 * System colors. This is useful if pieces of a Component (such as 893 * the integrated scrollbars of a List) should retain the System color 894 * instead of the background color set by Component.setBackground(). 895 */ 896 static Color[] getSystemColors() { 897 if (systemColors == null) { 898 systemColors = new Color[4]; 899 systemColors[BACKGROUND_COLOR] = SystemColor.window; 900 systemColors[HIGHLIGHT_COLOR] = SystemColor.controlLtHighlight; 901 systemColors[SHADOW_COLOR] = SystemColor.controlShadow; 902 systemColors[FOREGROUND_COLOR] = SystemColor.windowText; 903 } 904 return systemColors; 905 } 906 907 /** 908 * Draw a 3D oval. 909 */ 910 public void draw3DOval(Graphics g, Color colors[], 911 int x, int y, int w, int h, boolean raised) 912 { 913 Color c = g.getColor(); 914 g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]); 915 g.drawArc(x, y, w, h, 45, 180); 916 g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]); 917 g.drawArc(x, y, w, h, 225, 180); 918 g.setColor(c); 919 } 920 921 public void draw3DRect(Graphics g, Color colors[], 922 int x, int y, int width, int height, boolean raised) 923 { 924 Color c = g.getColor(); 925 g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]); 926 g.drawLine(x, y, x, y + height); 927 g.drawLine(x + 1, y, x + width - 1, y); 928 g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]); 929 g.drawLine(x + 1, y + height, x + width, y + height); 930 g.drawLine(x + width, y, x + width, y + height - 1); 931 g.setColor(c); 932 } 933 934 /* 935 * drawXXX() methods are used to print the native components by 936 * rendering the Motif look ourselves. 937 * ToDo(aim): needs to query native motif for more accurate color 938 * information. 939 */ 940 void draw3DOval(Graphics g, Color bg, 941 int x, int y, int w, int h, boolean raised) 957 Color c = g.getColor(); 958 Color shadow = bg.darker(); 959 Color highlight = bg.brighter(); 960 961 g.setColor(raised ? highlight : shadow); 962 g.drawLine(x, y, x, y + height); 963 g.drawLine(x + 1, y, x + width - 1, y); 964 g.setColor(raised ? shadow : highlight); 965 g.drawLine(x + 1, y + height, x + width, y + height); 966 g.drawLine(x + width, y, x + width, y + height - 1); 967 g.setColor(c); 968 } 969 970 void drawScrollbar(Graphics g, Color bg, int thickness, int length, 971 int min, int max, int val, int vis, boolean horizontal) { 972 Color c = g.getColor(); 973 double f = (double)(length - 2*(thickness-1)) / Math.max(1, ((max - min) + vis)); 974 int v1 = thickness + (int)(f * (val - min)); 975 int v2 = (int)(f * vis); 976 int w2 = thickness-4; 977 int tpts_x[] = new int[3]; 978 int tpts_y[] = new int[3]; 979 980 if (length < 3*w2 ) { 981 v1 = v2 = 0; 982 if (length < 2*w2 + 2) { 983 w2 = (length-2)/2; 984 } 985 } else if (v2 < 7) { 986 // enforce a minimum handle size 987 v1 = Math.max(0, v1 - ((7 - v2)>>1)); 988 v2 = 7; 989 } 990 991 int ctr = thickness/2; 992 int sbmin = ctr - w2/2; 993 int sbmax = ctr + w2/2; 994 995 // paint the background slightly darker 996 { 997 Color d = new Color((int) (bg.getRed() * 0.85), 998 (int) (bg.getGreen() * 0.85), | 756 757 } 758 759 public void endLayout() { 760 if (!paintPending && !paintArea.isEmpty() 761 && !AWTAccessor.getComponentAccessor().getIgnoreRepaint(target)) 762 { 763 // if not waiting for native painting repaint damaged area 764 postEvent(new PaintEvent(target, PaintEvent.PAINT, 765 new Rectangle())); 766 } 767 isLayouting = false; 768 } 769 770 public Color getWinBackground() { 771 return getPeerBackground(); 772 } 773 774 static int[] getRGBvals(Color c) { 775 776 int[] rgbvals = new int[3]; 777 778 rgbvals[0] = c.getRed(); 779 rgbvals[1] = c.getGreen(); 780 rgbvals[2] = c.getBlue(); 781 782 return rgbvals; 783 } 784 785 static final int BACKGROUND_COLOR = 0; 786 static final int HIGHLIGHT_COLOR = 1; 787 static final int SHADOW_COLOR = 2; 788 static final int FOREGROUND_COLOR = 3; 789 790 public Color[] getGUIcolors() { 791 Color[] c = new Color[4]; 792 float backb, highb, shadowb, hue, saturation; 793 c[BACKGROUND_COLOR] = getWinBackground(); 794 if (c[BACKGROUND_COLOR] == null) { 795 c[BACKGROUND_COLOR] = super.getWinBackground(); 796 } 797 if (c[BACKGROUND_COLOR] == null) { 798 c[BACKGROUND_COLOR] = Color.lightGray; 799 } 800 801 int[] rgb = getRGBvals(c[BACKGROUND_COLOR]); 802 803 float[] hsb = Color.RGBtoHSB(rgb[0],rgb[1],rgb[2],null); 804 805 hue = hsb[0]; 806 saturation = hsb[1]; 807 backb = hsb[2]; 808 809 810 /* Calculate Highlight Brightness */ 811 890 /** 891 * Returns an array of Colors similar to getGUIcolors(), but using the 892 * System colors. This is useful if pieces of a Component (such as 893 * the integrated scrollbars of a List) should retain the System color 894 * instead of the background color set by Component.setBackground(). 895 */ 896 static Color[] getSystemColors() { 897 if (systemColors == null) { 898 systemColors = new Color[4]; 899 systemColors[BACKGROUND_COLOR] = SystemColor.window; 900 systemColors[HIGHLIGHT_COLOR] = SystemColor.controlLtHighlight; 901 systemColors[SHADOW_COLOR] = SystemColor.controlShadow; 902 systemColors[FOREGROUND_COLOR] = SystemColor.windowText; 903 } 904 return systemColors; 905 } 906 907 /** 908 * Draw a 3D oval. 909 */ 910 public void draw3DOval(Graphics g, Color[] colors, 911 int x, int y, int w, int h, boolean raised) 912 { 913 Color c = g.getColor(); 914 g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]); 915 g.drawArc(x, y, w, h, 45, 180); 916 g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]); 917 g.drawArc(x, y, w, h, 225, 180); 918 g.setColor(c); 919 } 920 921 public void draw3DRect(Graphics g, Color[] colors, 922 int x, int y, int width, int height, boolean raised) 923 { 924 Color c = g.getColor(); 925 g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]); 926 g.drawLine(x, y, x, y + height); 927 g.drawLine(x + 1, y, x + width - 1, y); 928 g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]); 929 g.drawLine(x + 1, y + height, x + width, y + height); 930 g.drawLine(x + width, y, x + width, y + height - 1); 931 g.setColor(c); 932 } 933 934 /* 935 * drawXXX() methods are used to print the native components by 936 * rendering the Motif look ourselves. 937 * ToDo(aim): needs to query native motif for more accurate color 938 * information. 939 */ 940 void draw3DOval(Graphics g, Color bg, 941 int x, int y, int w, int h, boolean raised) 957 Color c = g.getColor(); 958 Color shadow = bg.darker(); 959 Color highlight = bg.brighter(); 960 961 g.setColor(raised ? highlight : shadow); 962 g.drawLine(x, y, x, y + height); 963 g.drawLine(x + 1, y, x + width - 1, y); 964 g.setColor(raised ? shadow : highlight); 965 g.drawLine(x + 1, y + height, x + width, y + height); 966 g.drawLine(x + width, y, x + width, y + height - 1); 967 g.setColor(c); 968 } 969 970 void drawScrollbar(Graphics g, Color bg, int thickness, int length, 971 int min, int max, int val, int vis, boolean horizontal) { 972 Color c = g.getColor(); 973 double f = (double)(length - 2*(thickness-1)) / Math.max(1, ((max - min) + vis)); 974 int v1 = thickness + (int)(f * (val - min)); 975 int v2 = (int)(f * vis); 976 int w2 = thickness-4; 977 int[] tpts_x = new int[3]; 978 int[] tpts_y = new int[3]; 979 980 if (length < 3*w2 ) { 981 v1 = v2 = 0; 982 if (length < 2*w2 + 2) { 983 w2 = (length-2)/2; 984 } 985 } else if (v2 < 7) { 986 // enforce a minimum handle size 987 v1 = Math.max(0, v1 - ((7 - v2)>>1)); 988 v2 = 7; 989 } 990 991 int ctr = thickness/2; 992 int sbmin = ctr - w2/2; 993 int sbmax = ctr + w2/2; 994 995 // paint the background slightly darker 996 { 997 Color d = new Color((int) (bg.getRed() * 0.85), 998 (int) (bg.getGreen() * 0.85), |