~ubuntu-branches/ubuntu/vivid/drmips/vivid-backports

« back to all changes in this revision

Viewing changes to src/pc/DrMIPS/src/com/jtattoo/plaf/hifi/HiFiComboBoxUI.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.hifi;
 
25
 
 
26
import com.jtattoo.plaf.BaseComboBoxUI;
 
27
import com.jtattoo.plaf.NoFocusButton;
 
28
import java.awt.*;
 
29
import javax.swing.JButton;
 
30
import javax.swing.JComponent;
 
31
import javax.swing.border.AbstractBorder;
 
32
import javax.swing.plaf.ComponentUI;
 
33
 
 
34
/**
 
35
 * @author Michael Hagen
 
36
 */
 
37
public class HiFiComboBoxUI extends BaseComboBoxUI {
 
38
 
 
39
    public static ComponentUI createUI(JComponent c) {
 
40
        return new HiFiComboBoxUI();
 
41
    }
 
42
 
 
43
    public JButton createArrowButton() {
 
44
        JButton button = new NoFocusButton(HiFiIcons.getComboBoxIcon());
 
45
        button.setBorder(new ArrowButtonBorder());
 
46
        return button;
 
47
    }
 
48
 
 
49
    protected void setButtonBorder() {
 
50
    }
 
51
 
 
52
//--------------------------------------------------------------------------------------------------    
 
53
    static class ArrowButtonBorder extends AbstractBorder {
 
54
 
 
55
        private static final Insets insets = new Insets(1, 3, 1, 2);
 
56
        private static final Color frameLoColor = new Color(120, 120, 120);
 
57
        private static final Color frameLowerColor = new Color(104, 104, 104);
 
58
        private static final Color frameLowerLoColor = new Color(64, 64, 64);
 
59
        private static final Color frameLowestColor = new Color(32, 32, 32);
 
60
 
 
61
        public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
 
62
            Graphics2D g2D = (Graphics2D) g;
 
63
            g.translate(x, y);
 
64
 
 
65
            g.setColor(frameLoColor);
 
66
            g.drawLine(1, 0, w - 1, 0);
 
67
            g.drawLine(1, 1, 1, h - 2);
 
68
            g.setColor(frameLowerColor);
 
69
            g.drawLine(w - 1, 1, w - 1, h - 2);
 
70
            g.drawLine(2, h - 1, w - 2, h - 1);
 
71
 
 
72
            Composite composite = g2D.getComposite();
 
73
            AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
 
74
            g2D.setComposite(alpha);
 
75
            g.setColor(frameLowestColor);
 
76
            g.drawLine(2, 1, w - 2, 1);
 
77
            g.drawLine(2, 2, 2, h - 3);
 
78
            g.setColor(frameLowerLoColor);
 
79
            g.drawLine(0, 0, 0, h);
 
80
            g2D.setComposite(composite);
 
81
 
 
82
            g.translate(-x, -y);
 
83
        }
 
84
 
 
85
        public Insets getBorderInsets(Component c) {
 
86
            return new Insets(insets.top, insets.left, insets.bottom, insets.right);
 
87
        }
 
88
 
 
89
        public Insets getBorderInsets(Component c, Insets borderInsets) {
 
90
            borderInsets.left = insets.left;
 
91
            borderInsets.top = insets.top;
 
92
            borderInsets.right = insets.right;
 
93
            borderInsets.bottom = insets.bottom;
 
94
            return borderInsets;
 
95
        }
 
96
 
 
97
    }
 
98
}