metacitybluecurve.java

来自「java jdk 1.4的源码」· Java 代码 · 共 1,134 行 · 第 1/3 页

JAVA
1,134
字号
/* * @(#)MetacityBluecurve.java	1.5 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package com.sun.java.swing.plaf.gtk;import java.awt.*;import java.awt.geom.*;import java.io.*;import java.net.*;import java.security.*;import java.util.*;import javax.swing.*;import javax.swing.border.*;/** * @version 1.5, 01/23/03 */class MetacityBluecurve extends Metacity {    protected MetacityBluecurve(String themeDir) {	super(themeDir, normalFrameGeometry);    }    // Constants from Bluecurve/metacity-theme-1.xml 2002-05-29 (use same variable names)    /*	<!-- define constants -->	<constant name="ArrowWidth" value="7"/>	<constant name="ArrowHeight" value="5"/>	<constant name="ButtonIPad" value="3"/>	<constant name="ThickLineWidth" value="3"/>	<constant name="IconTitleSpacing" value="2"/>	<constant name="LeftTitleTextPad" value="6"/>	<constant name="IconShadowOffset" value="1"/>    */    private static final int ArrowWidth = 7;    private static final int ArrowHeight = 5;    private static final int ButtonIPad = 3;    private static final int ThickLineWidth = 3;    private static final int IconTitleSpacing = 2;    private static final int LeftTitleTextPad = 6;    private static final int IconShadowOffset = 1;    /*	<frame_geometry name="normal" rounded_top_left="true" rounded_top_right="true" rounded_bottom_left="true" rounded_bottom_right="true">		<distance name="left_width" value="6"/>		<distance name="right_width" value="6"/>		<distance name="bottom_height" value="6"/>		<distance name="left_titlebar_edge" value="0"/>		<distance name="right_titlebar_edge" value="0"/>		<distance name="title_vertical_pad" value="3"/>		<border name="title_border" left="0" right="0" top="1" bottom="0"/>		<border name="button_border" left="0" right="0" top="1" bottom="0"/>		<aspect_ratio name="button" value="0.9"/>	</frame_geometry>    */    private static class NormalFrameGeometry extends FrameGeometry {	NormalFrameGeometry() {	    left_width = 6;	    right_width = 6;	    bottom_height = 6;	    left_titlebar_edge = 0;	    right_titlebar_edge = 0;	    title_vertical_pad = 3;	    title_border = new Insets(1, 0, 0, 0);	    button_border = new Insets(1, 0, 0, 0);	    aspect_ratio = 0.9F;	}    };    /*	<!-- strip borders off the normal geometry -->	<frame_geometry name="normal_maximized" parent="normal" rounded_top_left="false" rounded_top_right="false" rounded_bottom_left="false" rounded_bottom_right="false">		<distance name="left_width" value="0"/>		<distance name="right_width" value="0"/>		<distance name="bottom_height" value="0"/>		<distance name="left_titlebar_edge" value="0"/>		<distance name="right_titlebar_edge" value="0"/>	</frame_geometry>    */    private static class NormalMaximizedFrameGeometry extends NormalFrameGeometry {	NormalMaximizedFrameGeometry() {	    left_width = 0;	    right_width = 0;	    bottom_height = 0;	    left_titlebar_edge = 0;	    right_titlebar_edge = 0;	}    };    private static final FrameGeometry normalFrameGeometry = new NormalFrameGeometry();    private static final FrameGeometry normalMaximizedFrameGeometry = new NormalMaximizedFrameGeometry();    // draw_ops    private void titlebar_bg_unfocused(Graphics g, int width, int height) {	/*	  <gradient type="vertical" x="0" y="0" width="width" height="height">		<color value="shade/gtk:bg[INSENSITIVE]/1.0"/>		<color value="shade/gtk:bg[INSENSITIVE]/0.9"/>	  </gradient>	*/	drawVerticalGradient(g,			     shadeColor(getColor(DISABLED, GTKColorType.BACKGROUND), 1.0F),			     shadeColor(getColor(DISABLED, GTKColorType.BACKGROUND), 0.9F),			     0, 0, width, height);	/*	  <line color="shade/gtk:bg[INSENSITIVE]/0.6" x1="0" y1="height-1" x2="width" y2="height-1"/>	*/	g.setColor(shadeColor(getColor(DISABLED, GTKColorType.BACKGROUND), 0.6F));	g.drawLine(0, height-1, width, height-1);	/*	  <!-- Highlight on top edge -->	  <line color="shade/gtk:bg[INSENSITIVE]/1.2" x1="0" y1="0" x2="width" y2="0"/>	*/	g.setColor(shadeColor(getColor(DISABLED, GTKColorType.BACKGROUND), 1.2F));	g.drawLine(0, 0, width, 0);    }    /*	<!-- Buttons -->    */    private void button_generic_bg_before(Graphics g, int width, int height) {	/*		<!-- gradient from slightly darker than normal to slightly lighter --> 		<gradient type="diagonal" x="0" y="1" width="width" height="height">			<color value="shade/gtk:bg[NORMAL]/1.3"/>			<color value="shade/gtk:bg[NORMAL]/0.9"/>		</gradient>		<gradient type="diagonal" x="1" y="1" width="width-2" height="height-2">			<color value="shade/gtk:bg[NORMAL]/0.9"/>			<color value="shade/gtk:bg[NORMAL]/1.3"/>		</gradient>	*/	drawDiagonalGradient(g,			     shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 1.3F),			     shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 0.9F),			     0, 1, width, height);	drawDiagonalGradient(g,			     shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 0.9F),			     shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 1.3F),			     1, 1, width-2, height-2);    }    private void button_generic_bg_before_unfocused(Graphics g, int width, int height) {	/*		<include name="titlebar_bg_unfocused"/>		<gradient type="vertical" x="0" y="1" width="width" height="height-2" alpha="0.1">			<color value="shade/gtk:bg[NORMAL]/1.5"/>			<color value="shade/gtk:bg[NORMAL]/0.95"/>		</gradient>	*/	titlebar_bg_unfocused(g, width, height);	drawVerticalGradient(g,			     shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 1.5F),			     shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 0.95F),			     0, 1, width, height-2, 0.1F);    }    private void button_generic_bg_after(Graphics g, int width, int height) {	/*		<!-- line on bottom edge -->		<line color="shade/gtk:dark[NORMAL]/0.9" x1="0" y1="height-1" x2="width" y2="height-1"/>	*/	g.setColor(shadeColor(getColor(ENABLED, GTKColorType.DARK), 0.9F));	g.drawLine(0, height-1, width, height-1);    }    private void center_button_bg(Graphics g, int width, int height) {	/*		<include name="button_generic_bg_before"/>		<include name="button_generic_bg_after"/>		<!-- highlight on top edge -->		<line color="shade/gtk:bg[NORMAL]/1.2" x1="0" y1="0" x2="width" y2="0"/>		<!-- dark line to separate from other buttons -->		<line color="gtk:dark[NORMAL]" x1="width-1" y1="0" x2="width-1" y2="height"/>	*/	button_generic_bg_before(g, width, height);	button_generic_bg_after(g, width, height);	g.setColor(shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 1.2F));	g.drawLine(0, 0, width, 0);	g.setColor(getColor(ENABLED, GTKColorType.DARK));	g.drawLine(width-1, 0, width-1, height);    }    private void center_button_bg_unfocused(Graphics g, int width, int height) {	/*		<include name="button_generic_bg_before_unfocused"/>	*/	button_generic_bg_before_unfocused(g, width, height);    }    private void right_corner_outline(Graphics g, int width, int height) {	/*	  <draw_ops name="right_corner_outline">		<!-- fix up the black edging -->		<line color="#000000" x1="width-1" y1="0" x2="width-1" y2="height"/>		<line color="#000000" x1="width-5" y1="0" x2="width-4" y2="0"/>		<line color="#000000" x1="width-3" y1="1" x2="width-2" y2="1"/>		<line color="#000000" x1="width-2" y1="2" x2="width-2" y2="3"/>	  </draw_ops>	*/	g.setColor(Color.black);	// Adjusted because button isn't clipped 	g.drawLine(width-1, 4, width-1, height);	g.drawLine(width-5, 0, width-4, 0);	g.drawLine(width-3, 1, width-3, 1);	g.drawLine(width-2, 2, width-2, 3);    }    private void right_corner_button_bg(Graphics g, int width, int height) {	/*		<include name="button_generic_bg_before"/>		<include name="button_generic_bg_after"/>		<include name="right_corner_outline"/>		<!-- highlight on top edge -->		<line color="shade/gtk:bg[NORMAL]/1.2" x1="0" y1="0" x2="width-6" y2="0"/>		<!-- do some shading around the edges -->		<line color="shade/gtk:bg[NORMAL]/1.1" x1="width-4" y1="1" x2="width-5" y2="1"/>		<line color="shade/gtk:bg[NORMAL]/0.9" x1="width-3" y1="2" x2="width-3" y2="3"/>		<line color="shade/gtk:bg[NORMAL]/0.8" x1="width-2" y1="4" x2="width-2" y2="height-2"/>	*/	button_generic_bg_before(g, width, height);	button_generic_bg_after(g, width, height);	right_corner_outline(g, width, height);	g.setColor(shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 1.2F));	g.drawLine(0, 0, width-6, 0);	g.setColor(shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 1.1F));	g.drawLine(width-4, 1, width-5, 1);	g.setColor(shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 0.9F));	g.drawLine(width-3, 2, width-3, 3);	g.setColor(shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 0.8F));	g.drawLine(width-2, 4, width-2, height-2);    }    private void right_corner_button_bg_unfocused(Graphics g, int width, int height) {	/*		<include name="button_generic_bg_before_unfocused"/>		<include name="right_corner_outline"/>		<!-- highlight on top edge -->		<line color="shade/gtk:bg[INSENSITIVE]/1.2" x1="0" y1="0" x2="width-6" y2="0"/>		<!-- do some shading around the edges -->		<line color="shade/gtk:bg[INSENSITIVE]/1.1" x1="width-4" y1="1" x2="width-5" y2="1"/>		<line color="shade/gtk:bg[INSENSITIVE]/0.9" x1="width-3" y1="2" x2="width-3" y2="3"/>		<line color="shade/gtk:bg[INSENSITIVE]/0.8" x1="width-2" y1="4" x2="width-2" y2="height-2"/>	*/	button_generic_bg_before_unfocused(g, width, height);	right_corner_outline(g, width, height);	g.setColor(shadeColor(getColor(DISABLED, GTKColorType.BACKGROUND), 1.2F));	g.drawLine(0, 0, width-6, 0);	g.setColor(shadeColor(getColor(DISABLED, GTKColorType.BACKGROUND), 1.1F));	g.drawLine(width-4, 1, width-5, 1);	g.setColor(shadeColor(getColor(DISABLED, GTKColorType.BACKGROUND), 0.9F));	g.drawLine(width-3, 2, width-3, 3);	g.setColor(shadeColor(getColor(DISABLED, GTKColorType.BACKGROUND), 0.8F));	g.drawLine(width-2, 4, width-2, height-2);    }    private void left_corner_outline(Graphics g, int width, int height) {	/*	  <draw_ops name="left_corner_outline">		  <!-- fix up the black edging -->		  <line color="#000000" x1="0" y1="0" x2="0" y2="height"/>		  <line color="#000000" x1="1" y1="2" x2="1" y2="3"/>		  <line color="#000000" x1="2" y1="1" x2="2" y2="1"/>		  <line color="#000000" x1="3" y1="0" x2="4" y2="0"/>	  </draw_ops>	*/	g.setColor(Color.black);	// adjusted because button isn't clipped 	g.drawLine(0, 4, 0, height);	g.drawLine(1, 2, 1, 3);	g.drawLine(2, 1, 2, 1);	g.drawLine(3, 0, 4, 0);    }    private void left_corner_button_bg(Graphics g, int width, int height) {	/*		<include name="button_generic_bg_before"/>		<include name="button_generic_bg_after"/>		<include name="left_corner_outline"/>		<!-- highlight on top edge -->		<line color="shade/gtk:bg[NORMAL]/1.2" x1="5" y1="0" x2="width" y2="0"/>		<!-- shading around the edges -->		<line color="shade/gtk:light[NORMAL]/1.2" x1="1" y1="4" x2="1" y2="height-2"/>		<line color="shade/gtk:light[NORMAL]/1.1" x1="3" y1="1" x2="4" y2="1"/>		<line color="shade/gtk:light[NORMAL]/1.1" x1="2" y1="2" x2="2" y2="3"/>	*/	button_generic_bg_before(g, width, height);	button_generic_bg_after(g, width, height);	left_corner_outline(g, width, height);	g.setColor(shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 1.2F));	g.drawLine(5, 0, width, 0);	g.setColor(shadeColor(getColor(ENABLED, GTKColorType.LIGHT), 1.2F));	g.drawLine(1, 4, 1, height-2);	g.setColor(shadeColor(getColor(ENABLED, GTKColorType.LIGHT), 1.1F));	g.drawLine(3, 1, 4, 1);	g.drawLine(2, 2, 2, 3);    }    private void left_corner_button_bg_unfocused(Graphics g, int width, int height) {	/*		<include name="button_generic_bg_before_unfocused"/>		<include name="left_corner_outline"/>		<!-- highlight on top edge -->		<line color="shade/gtk:bg[INSENSITIVE]/1.2" x1="5" y1="0" x2="width" y2="0"/>		<!-- shading around the edges -->		<line color="shade/gtk:light[INSENSITIVE]/1.2" x1="1" y1="4" x2="1" y2="height-2"/>		<line color="shade/gtk:light[INSENSITIVE]/1.1" x1="3" y1="1" x2="4" y2="1"/>		<line color="shade/gtk:light[INSENSITIVE]/1.1" x1="2" y1="2" x2="2" y2="3"/>	*/	button_generic_bg_before_unfocused(g, width, height);	left_corner_outline(g, width, height);	g.setColor(shadeColor(getColor(DISABLED, GTKColorType.BACKGROUND), 1.2F));	g.drawLine(5, 0, width, 0);	g.setColor(shadeColor(getColor(DISABLED, GTKColorType.LIGHT), 1.2F));	g.drawLine(1, 4, 1, height-2);	g.setColor(shadeColor(getColor(DISABLED, GTKColorType.LIGHT), 1.1F));	g.drawLine(3, 1, 4, 1);	g.drawLine(2, 2, 2, 3);    }    private void darken_tint(Graphics g, int width, int height) {	/*		<tint color="shade/gtk:bg[normal]/0.75" alpha="0.5" 			x="0" y="0" width="width" height="height"/>	*/	tintRect(g, 0, 0, width, height,		 shadeColor(getColor(ENABLED, GTKColorType.BACKGROUND), 0.75F),		 0.5F);    }    private void prelight_tint(Graphics g, int width, int height) {	/*		<tint color="gtk:bg[PRELIGHT]" alpha="0.4"			x="1" y="1" width="width-2" height="height-2"/>	*/	tintRect(g, 1, 1, width-2, height-2, getColor(MOUSE_OVER, GTKColorType.BACKGROUND), 0.4F);    }    private void minimize_icon(Graphics g, int width, int height) {	/*		<image filename="minimize.png"			colorize="gtk:fg[NORMAL]"			alpha="0.7"			x="(width - object_width) / 2"			y="(height - object_height) / 2"			width="object_width"			height="object_height"/>	*/	Image object = getImage("minimize", getColor(ENABLED, GTKColorType.FOREGROUND));	drawImage(g, object,		  getColor(ENABLED, GTKColorType.FOREGROUND),		  0.7F,		  (width - object.getWidth(null)) / 2,		  (height - object.getHeight(null)) / 2);    }    private void menu_icon(Graphics g, int width, int height) {	/*		<image filename="menu.png"			colorize="gtk:fg[NORMAL]"

⌨️ 快捷键说明

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