~ubuntu-branches/ubuntu/utopic/drmips/utopic-backports

« back to all changes in this revision

Viewing changes to src/pc/DrMIPS/src/com/jtattoo/plaf/mint/MintIcons.java

  • Committer: Package Import Robot
  • Author(s): Bruno Nova
  • Date: 2014-09-27 12:24:17 UTC
  • Revision ID: package-import@ubuntu.com-20140927122417-2gadkwt9k0u7j4zu
Tags: upstream-1.2.3
Import upstream version 1.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* Copyright (c) 2002 and later by MH Software-Entwicklung. All Rights Reserved.
 
3
*  
 
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.
 
7
*  
 
8
* see: gpl-2.0.txt
 
9
 
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
 
13
* Foundation.
 
14
 
15
* see: lgpl-2.0.txt
 
16
* see: classpath-exception.txt
 
17
 
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.
 
20
*  
 
21
* see: APACHE-LICENSE-2.0.txt
 
22
*/
 
23
 
 
24
package com.jtattoo.plaf.mint;
 
25
 
 
26
import com.jtattoo.plaf.*;
 
27
import java.awt.*;
 
28
import java.awt.geom.Area;
 
29
import java.awt.geom.RoundRectangle2D;
 
30
import javax.swing.Icon;
 
31
import javax.swing.JButton;
 
32
 
 
33
/**
 
34
 * @author Michael Hagen
 
35
 */
 
36
public class MintIcons extends BaseIcons {
 
37
 
 
38
    public static Icon getIconIcon() {
 
39
        if (iconIcon == null) {
 
40
            if (AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn()) {
 
41
                iconIcon = new MacIconIcon();
 
42
            } else {
 
43
                iconIcon = new TitleButtonIcon(TitleButtonIcon.ICON_ICON_TYP);
 
44
            }
 
45
        }
 
46
        return iconIcon;
 
47
    }
 
48
 
 
49
    public static Icon getMinIcon() {
 
50
        if (minIcon == null) {
 
51
            if (AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn()) {
 
52
                minIcon = new MacMinIcon();
 
53
            } else {
 
54
                minIcon = new TitleButtonIcon(TitleButtonIcon.MIN_ICON_TYP);
 
55
            }
 
56
        }
 
57
        return minIcon;
 
58
    }
 
59
 
 
60
    public static Icon getMaxIcon() {
 
61
        if (maxIcon == null) {
 
62
            if (AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn()) {
 
63
                maxIcon = new MacMaxIcon();
 
64
            } else {
 
65
                maxIcon = new TitleButtonIcon(TitleButtonIcon.MAX_ICON_TYP);
 
66
            }
 
67
        }
 
68
        return maxIcon;
 
69
    }
 
70
 
 
71
    public static Icon getCloseIcon() {
 
72
        if (closeIcon == null) {
 
73
            if (AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn()) {
 
74
                closeIcon = new MacCloseIcon();
 
75
            } else {
 
76
                closeIcon = new TitleButtonIcon(TitleButtonIcon.CLOSE_ICON_TYP);
 
77
            }
 
78
        }
 
79
        return closeIcon;
 
80
    }
 
81
 
 
82
//------------------------------------------------------------------------------    
 
83
    private static class TitleButtonIcon implements Icon {
 
84
 
 
85
        private static Color closerColorLight = new Color(241, 172, 154);
 
86
        private static Color closerColorDark = new Color(224, 56, 2);
 
87
        public static final int ICON_ICON_TYP = 0;
 
88
        public static final int MIN_ICON_TYP = 1;
 
89
        public static final int MAX_ICON_TYP = 2;
 
90
        public static final int CLOSE_ICON_TYP = 3;
 
91
        private int iconTyp = ICON_ICON_TYP;
 
92
 
 
93
        public TitleButtonIcon(int typ) {
 
94
            iconTyp = typ;
 
95
        }
 
96
 
 
97
        public int getIconHeight() {
 
98
            return 20;
 
99
        }
 
100
 
 
101
        public int getIconWidth() {
 
102
            return 20;
 
103
        }
 
104
 
 
105
        public void paintIcon(Component c, Graphics g, int x, int y) {
 
106
            int w = c.getWidth();
 
107
            int h = c.getHeight();
 
108
 
 
109
            JButton b = (JButton) c;
 
110
            Graphics2D g2D = (Graphics2D) g;
 
111
 
 
112
            boolean isActive = JTattooUtilities.isActive(b);
 
113
            boolean isPressed = b.getModel().isPressed();
 
114
            boolean isArmed = b.getModel().isArmed();
 
115
            boolean isRollover = b.getModel().isRollover();
 
116
 
 
117
            Color cHi = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getWindowTitleColorLight(), 40);
 
118
            Color cLo = ColorHelper.darker(AbstractLookAndFeel.getTheme().getWindowTitleColorDark(), 10);
 
119
            if (iconTyp == CLOSE_ICON_TYP) {
 
120
                cHi = closerColorLight;
 
121
                cLo = closerColorDark;
 
122
            }
 
123
 
 
124
            Color fcHi = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getWindowTitleColorDark(), 80);
 
125
            Color fcLo = ColorHelper.darker(AbstractLookAndFeel.getTheme().getWindowTitleColorDark(), 40);
 
126
 
 
127
            if (!isActive) {
 
128
                cHi = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorLight(), 40);
 
129
                cLo = ColorHelper.darker(AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorDark(), 10);
 
130
                fcHi = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorLight(), 60);
 
131
                fcLo = ColorHelper.darker(AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorDark(), 10);
 
132
            }
 
133
            if (isPressed && isArmed) {
 
134
                Color cTemp = ColorHelper.darker(cLo, 10);
 
135
                cLo = ColorHelper.darker(cHi, 10);
 
136
                cHi = cTemp;
 
137
            } else if (isRollover) {
 
138
                cHi = ColorHelper.brighter(cHi, 30);
 
139
                cLo = ColorHelper.brighter(cLo, 30);
 
140
            }
 
141
 
 
142
            Shape savedClip = g.getClip();
 
143
            Area area = new Area(new RoundRectangle2D.Double(1, 1, w - 1, h - 1, 3, 3));
 
144
            g2D.setClip(area);
 
145
 
 
146
            g2D.setPaint(new GradientPaint(0, 0, fcLo, w, h, fcHi));
 
147
            g.fillRect(1, 1, w - 1, h - 1);
 
148
 
 
149
            g2D.setPaint(new GradientPaint(0, 0, ColorHelper.brighter(cHi, 80), w, h, ColorHelper.darker(cLo, 30)));
 
150
            g.fillRect(2, 2, w - 3, h - 3);
 
151
 
 
152
            g2D.setPaint(new GradientPaint(0, 0, cHi, w, h, cLo));
 
153
            g.fillRect(3, 3, w - 5, h - 5);
 
154
 
 
155
            g2D.setClip(savedClip);
 
156
 
 
157
            cHi = Color.white;
 
158
            cLo = ColorHelper.darker(cLo, 30);
 
159
            Icon icon = null;
 
160
            if (iconTyp == ICON_ICON_TYP) {
 
161
                icon = new BaseIcons.IconSymbol(cHi, cLo, null);
 
162
            } else if (iconTyp == MIN_ICON_TYP) {
 
163
                icon = new BaseIcons.MinSymbol(cHi, cLo, null);
 
164
            } else if (iconTyp == MAX_ICON_TYP) {
 
165
                icon = new BaseIcons.MaxSymbol(cHi, cLo, null);
 
166
            } else if (iconTyp == CLOSE_ICON_TYP) {
 
167
                icon = new BaseIcons.CloseSymbol(cHi, cLo, null);
 
168
            }
 
169
            if (icon != null) {
 
170
                icon.paintIcon(c, g, 0, 0);
 
171
            }
 
172
        }
 
173
    }
 
174
}