2
* Copyright (c) 2002 and later by MH Software-Entwicklung. All Rights Reserved.
4
* JTattoo is multiple licensed. If your are an open source developer you can use
5
* it under the terms and conditions of the GNU General Public License version 2.0
6
* or later as published by the Free Software Foundation.
10
* If you pay for a license you will become a registered user who could use the
11
* software under the terms and conditions of the GNU Lesser General Public License
12
* version 2.0 or later with classpath exception as published by the Free Software
16
* see: classpath-exception.txt
18
* Registered users could also use JTattoo under the terms and conditions of the
19
* Apache License, Version 2.0 as published by the Apache Software Foundation.
21
* see: APACHE-LICENSE-2.0.txt
24
package com.jtattoo.plaf.smart;
26
import com.jtattoo.plaf.*;
28
import javax.swing.JDialog;
29
import javax.swing.JRootPane;
32
* @author Michael Hagen
34
public class SmartTitlePane extends BaseTitlePane {
36
public SmartTitlePane(JRootPane root, BaseRootPaneUI ui) {
40
public void createButtons() {
41
iconifyButton = new BaseTitleButton(iconifyAction, ICONIFY, iconifyIcon, 1.0f);
42
maxButton = new BaseTitleButton(restoreAction, MAXIMIZE, maximizeIcon, 1.0f);
43
closeButton = new BaseTitleButton(closeAction, CLOSE, closeIcon, 1.0f);
46
public void paintBorder(Graphics g) {
48
g.setColor(AbstractLookAndFeel.getTheme().getFrameColor());
50
g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getTheme().getFrameColor(), 40));
52
g.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
55
public void paintBackground(Graphics g) {
56
Graphics2D g2D = (Graphics2D) g;
57
int width = getWidth();
58
int height = getHeight();
59
Color backColor = null;
60
Color frameColor = null;
61
if (JTattooUtilities.isActive(this)) {
62
backColor = AbstractLookAndFeel.getTheme().getWindowTitleColors()[10];
63
frameColor = AbstractLookAndFeel.getTheme().getFrameColor();
64
JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getWindowTitleColors(), 0, 0, width, height);
66
backColor = AbstractLookAndFeel.getTheme().getWindowInactiveTitleColors()[10];
67
frameColor = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getFrameColor(), 40);
68
JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getWindowInactiveTitleColors(), 0, 0, width, height);
72
if (menuBar != null) {
73
iconWidth = menuBar.getWidth() + 5;
77
String frameTitle = getTitle();
78
if (frameTitle != null) {
81
FontMetrics fm = g.getFontMetrics();
82
titleWidth = fm.stringWidth(JTattooUtilities.getClippedText(getTitle(), fm, getWidth() - iconWidth - buttonsWidth - 15)) + 10;
83
if (getWindow() instanceof JDialog) {
84
Image image = getFrameIconImage();
86
titleWidth += getHeight();
93
boolean leftToRight = isLeftToRight();
94
int xOffset = leftToRight ? iconWidth + 10 + titleWidth : width - 10 - iconWidth - titleWidth;
97
dw = width - buttonsWidth - xOffset - 10;
100
dw = xOffset - buttonsWidth - 10;
101
dx = buttonsWidth + 10;
105
if (!AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn() && !AbstractLookAndFeel.getTheme().isCenterWindowTitleOn() && (dw > 0)) {
106
Composite composite = g2D.getComposite();
107
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
108
g2D.setComposite(alpha);
113
Color c1 = ColorHelper.brighter(backColor, dc1);
115
while ((dy + 5) < height) {
116
c2 = ColorHelper.darker(backColor, dc2);
119
g.drawLine(dx, dy, dx + dw, dy);
122
g.drawLine(dx, dy, dx + dw, dy);
125
g2D.setComposite(composite);
127
g.setColor(frameColor);
128
g.drawLine(0, height - 1, width, height - 1);
131
public void paintText(Graphics g, int x, int y, String title) {
132
x += paintIcon(g, x, y);
134
Color titleColor = AbstractLookAndFeel.getWindowTitleForegroundColor();
135
if (ColorHelper.getGrayValue(titleColor) > 164) {
136
g.setColor(Color.black);
137
JTattooUtilities.drawString(rootPane, g, title, x + 1, y + 1);
139
g.setColor(titleColor);
140
JTattooUtilities.drawString(rootPane, g, title, x, y);
142
g.setColor(AbstractLookAndFeel.getWindowInactiveTitleForegroundColor());
143
JTattooUtilities.drawString(rootPane, g, title, x, y);