metacitycrux.java
来自「java jdk 1.4的源码」· Java 代码 · 共 852 行 · 第 1/3 页
JAVA
852 行
/* * @(#)MetacityCrux.java 1.7 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.io.*;import java.net.*;import java.security.*;import java.util.*;import javax.swing.*;import javax.swing.border.*;/** * @version 1.7, 01/23/03 */class MetacityCrux extends Metacity { protected MetacityCrux(String themeDir) { super(themeDir, normalFrameGeometry); } // Constants from Metacity 2.4.1 Crux/metacity-theme-1.xml (use same variable names) /* <constant name="IconTitleSpacing" value="2"/> <!-- Space between menu button and title --> <constant name="CenterTitlePieceWidth" value="48"/> <!-- Width of center title piece --> <constant name="ButtonWidth" value="16"/> <!-- Button width --> */ private static final int IconTitleSpacing = 2; private static final int CenterTitlePieceWidth = 48; private static final int ButtonWidth = 16; /* <frame_geometry name="normal"> <distance name="left_width" value="5"/> <distance name="right_width" value="6"/> <distance name="bottom_height" value="6"/> <distance name="left_titlebar_edge" value="5"/> <distance name="right_titlebar_edge" value="6"/> <aspect_ratio name="button" value="1.0"/> <distance name="title_vertical_pad" value="0"/> <border name="title_border" left="0" right="0" top="3" bottom="3"/> <border name="button_border" left="0" right="0" top="3" bottom="3"/> </frame_geometry> */ private static class NormalFrameGeometry extends FrameGeometry { NormalFrameGeometry() { left_width = 5; right_width = 6; bottom_height = 6; left_titlebar_edge = 5; right_titlebar_edge = 6; aspect_ratio = 1.0F; title_vertical_pad = 0; title_border = new Insets(3, 0, 3, 0); button_border = new Insets(3, 0, 3, 0); } }; private static final FrameGeometry normalFrameGeometry = new NormalFrameGeometry(); // draw_ops // <!-- Buttons --> private void active_button(Graphics g, int width, int height) { /* <image filename="active-button.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("active-button"), 0, 0, width, height, null); } private void active_button_pressed(Graphics g, int width, int height) { /* <image filename="active-button-pressed.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("active-button-pressed"), 0, 0, width, height, null); } private void active_button_prelight(Graphics g, int width, int height) { /* <image filename="active-button-prelight.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("active-button-prelight"), 0, 0, width, height, null); } private void inactive_button(Graphics g, int width, int height) { /* <image filename="inactive-button.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("inactive-button"), 0, 0, width, height, null); } private void inactive_button_pressed(Graphics g, int width, int height) { /* <image filename="inactive-button-pressed.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("inactive-button-pressed"), 0, 0, width, height, null); } private void inactive_button_prelight(Graphics g, int width, int height) { /* <image filename="inactive-button-prelight.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("inactive-button-prelight"), 0, 0, width, height, null); } void paintButtonBackground(SynthContext context, Graphics g, int x, int y, int w,int h) { this.context = context; JButton button = (JButton)context.getComponent(); String buttonName = button.getName(); int buttonState = context.getComponentState(); JComponent titlePane = (JComponent)button.getParent(); Container titlePaneParent = titlePane.getParent(); JInternalFrame frame; if (titlePaneParent instanceof JInternalFrame) { frame = (JInternalFrame)titlePaneParent; } else if (titlePaneParent instanceof JInternalFrame.JDesktopIcon) { frame = ((JInternalFrame.JDesktopIcon)titlePaneParent).getInternalFrame(); } else { return; } boolean active = frame.isSelected(); setFrameGeometry(titlePane, normalFrameGeometry); if (!active) { if (buttonName.equals("InternalFrameTitlePane.menuButton")) { if ((buttonState & SynthConstants.PRESSED) != 0) { /* <image filename="inactive-menu-button-pressed.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("inactive-menu-button-pressed"), x, y, w, h, null); } else if ((buttonState & SynthConstants.MOUSE_OVER) != 0) { /* <image filename="inactive-menu-button-prelight.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("inactive-menu-button-prelight"), x, y, w, h, null); } else { /* <image filename="inactive-menu-button.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("inactive-menu-button"), x, y, w, h, null); } } else if (buttonName.equals("InternalFrameTitlePane.iconifyButton")) { if ((buttonState & SynthConstants.PRESSED) != 0) { /* <include name="inactive_button_pressed"/> <image filename="inactive-minimize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ inactive_button_pressed(g, w, h); g.drawImage(getImage("inactive-minimize-button"), x+2, y+2, w-4, h-4, null); } else if ((buttonState & SynthConstants.MOUSE_OVER) != 0) { /* <include name="inactive_button_prelight"/> <image filename="inactive-minimize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ inactive_button_prelight(g, w, h); g.drawImage(getImage("inactive-minimize-button"), x+2, y+2, w-4, h-4, null); } else { /* <include name="inactive_button"/> <image filename="inactive-minimize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ inactive_button(g, w, h); g.drawImage(getImage("inactive-minimize-button"), x+2, y+2, w-4, h-4, null); } } else if (buttonName.equals("InternalFrameTitlePane.maximizeButton")) { if ((buttonState & SynthConstants.PRESSED) != 0) { /* <include name="inactive_button_pressed"/> <image filename="inactive-maximize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ inactive_button_pressed(g, w, h); g.drawImage(getImage("inactive-maximize-button"), x+2, y+2, w-4, h-4, null); } else if ((buttonState & SynthConstants.MOUSE_OVER) != 0) { /* <include name="inactive_button_prelight"/> <image filename="inactive-maximize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ inactive_button_prelight(g, w, h); g.drawImage(getImage("inactive-maximize-button"), x+2, y+2, w-4, h-4, null); } else { /* <include name="inactive_button"/> <image filename="inactive-maximize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ inactive_button(g, w, h); g.drawImage(getImage("inactive-maximize-button"), x+2, y+2, w-4, h-4, null); } } else if (buttonName.equals("InternalFrameTitlePane.closeButton")) { if ((buttonState & SynthConstants.PRESSED) != 0) { /* <include name="inactive_button_pressed"/> <image filename="inactive-close-button.png" x="2" y="2" width="width-4" height="height-4"/> */ inactive_button_pressed(g, w, h); g.drawImage(getImage("inactive-close-button"), x+2, y+2, w-4, h-4, null); } else if ((buttonState & SynthConstants.MOUSE_OVER) != 0) { /* <include name="inactive_button_prelight"/> <image filename="inactive-close-button.png" x="2" y="2" width="width-4" height="height-4"/> */ inactive_button_prelight(g, w, h); g.drawImage(getImage("inactive-close-button"), x+2, y+2, w-4, h-4, null); } else { /* <include name="inactive_button"/> <image filename="inactive-close-button.png" x="2" y="2" width="width-4" height="height-4"/> */ inactive_button(g, w, h); g.drawImage(getImage("inactive-close-button"), x+2, y+2, w-4, h-4, null); } } } else { if (buttonName.equals("InternalFrameTitlePane.menuButton")) { if ((buttonState & SynthConstants.PRESSED) != 0) { /* <image colorize="gtk:bg[SELECTED]" filename="active-menu-button-pressed.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("active-menu-button-pressed", getColor(SELECTED, GTKColorType.BACKGROUND)), x, y, w, h, null); } else if ((buttonState & SynthConstants.MOUSE_OVER) != 0) { /* <image colorize="gtk:bg[SELECTED]" filename="active-menu-button-prelight.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("active-menu-button-prelight", getColor(SELECTED, GTKColorType.BACKGROUND)), x, y, w, h, null); } else { /* <image colorize="gtk:bg[SELECTED]" filename="active-menu-button.png" x="0" y="0" width="width" height="height"/> */ g.drawImage(getImage("active-menu-button", getColor(SELECTED, GTKColorType.BACKGROUND)), x, y, w, h, null); } } else if (buttonName.equals("InternalFrameTitlePane.iconifyButton")) { if ((buttonState & SynthConstants.PRESSED) != 0) { /* <include name="active_button_pressed"/> <image filename="active-minimize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ active_button_pressed(g, w, h); g.drawImage(getImage("active-minimize-button"), x+2, y+2, w-4, h-4, null); } else if ((buttonState & SynthConstants.MOUSE_OVER) != 0) { /* <include name="active_button_prelight"/> <image filename="active-minimize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ active_button_prelight(g, w, h); g.drawImage(getImage("active-minimize-button"), x+2, y+2, w-4, h-4, null); } else { /* <include name="active_button"/> <image filename="active-minimize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ active_button(g, w, h); g.drawImage(getImage("active-minimize-button"), x+2, y+2, w-4, h-4, null); } } else if (buttonName.equals("InternalFrameTitlePane.maximizeButton")) { if ((buttonState & SynthConstants.PRESSED) != 0) { /* <include name="active_button_pressed"/> <image filename="active-maximize-button.png" x="2" y="2" width="width-4" height="height-4"/> */ active_button_pressed(g, w, h); g.drawImage(getImage("active-maximize-button"), x+2, y+2, w-4, h-4, null); } else if ((buttonState & SynthConstants.MOUSE_OVER) != 0) { /* <include name="active_button_prelight"/>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?