diff options
Diffstat (limited to 'src/cppcheckplus/menu')
-rw-r--r-- | src/cppcheckplus/menu/MyMenu.java | 71 | ||||
-rw-r--r-- | src/cppcheckplus/menu/MyMenuBar.java | 56 | ||||
-rw-r--r-- | src/cppcheckplus/menu/MyMenuItem.java | 52 | ||||
-rw-r--r-- | src/cppcheckplus/menu/MyRootMenu.java | 62 |
4 files changed, 241 insertions, 0 deletions
diff --git a/src/cppcheckplus/menu/MyMenu.java b/src/cppcheckplus/menu/MyMenu.java new file mode 100644 index 0000000..3570408 --- /dev/null +++ b/src/cppcheckplus/menu/MyMenu.java | |||
@@ -0,0 +1,71 @@ | |||
1 | |||
2 | package cppcheckplus.menu; | ||
3 | |||
4 | import java.awt.Color; | ||
5 | import java.awt.Dimension; | ||
6 | import java.awt.Graphics; | ||
7 | import java.awt.Graphics2D; | ||
8 | import javax.swing.BorderFactory; | ||
9 | import javax.swing.JMenu; | ||
10 | import javax.swing.border.Border; | ||
11 | |||
12 | import cppcheckplus.control.MyContorlUtil; | ||
13 | |||
14 | |||
15 | public class MyMenu extends JMenu | ||
16 | { | ||
17 | private Color backgroundColor; | ||
18 | private Color foregroundColor; | ||
19 | private int borderThickness; | ||
20 | private Border border; | ||
21 | private int preferredHeight; | ||
22 | |||
23 | public MyMenu() | ||
24 | { | ||
25 | backgroundColor = MyContorlUtil.MENUITEM_BACKGROUND; | ||
26 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
27 | borderThickness = 1; | ||
28 | border = BorderFactory.createLineBorder(backgroundColor, borderThickness); | ||
29 | preferredHeight = 25; | ||
30 | init(); | ||
31 | } | ||
32 | |||
33 | public MyMenu(String text) | ||
34 | { | ||
35 | super(text); | ||
36 | backgroundColor = MyContorlUtil.MENUITEM_BACKGROUND; | ||
37 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
38 | borderThickness = 1; | ||
39 | border = BorderFactory.createLineBorder(backgroundColor, borderThickness); | ||
40 | preferredHeight = 25; | ||
41 | init(); | ||
42 | } | ||
43 | |||
44 | private void init() | ||
45 | { | ||
46 | setForeground(foregroundColor); | ||
47 | setFont(MyContorlUtil.FONT_14_BOLD); | ||
48 | setOpaque(true); | ||
49 | setBackground(backgroundColor); | ||
50 | setBorder(border); | ||
51 | } | ||
52 | @Override | ||
53 | protected void paintComponent(Graphics g) | ||
54 | { | ||
55 | if (isSelected()) | ||
56 | { | ||
57 | Graphics2D g2d = (Graphics2D)g; | ||
58 | g2d.setColor(MyContorlUtil.MENUITEM_SELECTED_BACKGROUND); | ||
59 | g2d.fillRect(0, 0, getWidth(), getHeight()); | ||
60 | super.paintComponent(g); | ||
61 | } else | ||
62 | { | ||
63 | super.paintComponent(g); | ||
64 | } | ||
65 | } | ||
66 | @Override | ||
67 | public Dimension getPreferredSize() | ||
68 | { | ||
69 | return new Dimension(super.getPreferredSize().width, preferredHeight); | ||
70 | } | ||
71 | } | ||
diff --git a/src/cppcheckplus/menu/MyMenuBar.java b/src/cppcheckplus/menu/MyMenuBar.java new file mode 100644 index 0000000..7d5d102 --- /dev/null +++ b/src/cppcheckplus/menu/MyMenuBar.java | |||
@@ -0,0 +1,56 @@ | |||
1 | |||
2 | package cppcheckplus.menu; | ||
3 | |||
4 | import java.awt.Dimension; | ||
5 | import java.awt.Graphics; | ||
6 | import java.awt.Graphics2D; | ||
7 | import java.awt.Image; | ||
8 | import java.awt.TexturePaint; | ||
9 | import javax.swing.BorderFactory; | ||
10 | import javax.swing.ImageIcon; | ||
11 | import javax.swing.JMenuBar; | ||
12 | import javax.swing.border.Border; | ||
13 | |||
14 | import cppcheckplus.control.MyContorlUtil; | ||
15 | |||
16 | |||
17 | public class MyMenuBar extends JMenuBar | ||
18 | { | ||
19 | |||
20 | private Image backgroundLeftImage; | ||
21 | private Image backgroundRightImage; | ||
22 | private ImageIcon backgroundImageIcon; | ||
23 | private TexturePaint paint; | ||
24 | private Border border; | ||
25 | |||
26 | public MyMenuBar() | ||
27 | { | ||
28 | backgroundLeftImage = MyContorlUtil.getImage("control/images/menubar_background_left.png"); | ||
29 | backgroundRightImage = MyContorlUtil.getImage("control/images/menubar_background_right.png"); | ||
30 | backgroundImageIcon = MyContorlUtil.getImageIcon("control/images/menubar_background.png"); | ||
31 | paint = MyContorlUtil.createTexturePaint("control/images/menubar_background.png"); | ||
32 | border = BorderFactory.createEmptyBorder(); | ||
33 | init(); | ||
34 | } | ||
35 | private void init() | ||
36 | { | ||
37 | setBorder(border); | ||
38 | } | ||
39 | @Override | ||
40 | protected void paintComponent(Graphics g) | ||
41 | { | ||
42 | super.paintComponent(g); | ||
43 | Graphics2D g2d = (Graphics2D)g; | ||
44 | g2d.setPaint(paint); | ||
45 | g2d.fillRect(0, 0, getWidth(), getHeight()); | ||
46 | g2d.drawImage(backgroundLeftImage, 0, 0, null); | ||
47 | g2d.drawImage(backgroundRightImage, getWidth() - backgroundRightImage.getWidth(null), 0, null); | ||
48 | } | ||
49 | @Override | ||
50 | public Dimension getPreferredSize() | ||
51 | { | ||
52 | return new Dimension(super.getPreferredSize().width, backgroundImageIcon.getIconHeight()); | ||
53 | } | ||
54 | |||
55 | } | ||
56 | |||
diff --git a/src/cppcheckplus/menu/MyMenuItem.java b/src/cppcheckplus/menu/MyMenuItem.java new file mode 100644 index 0000000..6ac46e9 --- /dev/null +++ b/src/cppcheckplus/menu/MyMenuItem.java | |||
@@ -0,0 +1,52 @@ | |||
1 | |||
2 | package cppcheckplus.menu; | ||
3 | |||
4 | import java.awt.Color; | ||
5 | import java.awt.Dimension; | ||
6 | import javax.swing.BorderFactory; | ||
7 | import javax.swing.JMenuItem; | ||
8 | import javax.swing.border.Border; | ||
9 | |||
10 | import cppcheckplus.control.MyContorlUtil; | ||
11 | |||
12 | public class MyMenuItem extends JMenuItem | ||
13 | { | ||
14 | private static final long serialVersionUID = 1L; | ||
15 | private Color backgroundColor; | ||
16 | private Color foregroundColor; | ||
17 | private int borderThickness; | ||
18 | private Border border; | ||
19 | private int preferredHeight; | ||
20 | |||
21 | public MyMenuItem() | ||
22 | { | ||
23 | backgroundColor = MyContorlUtil.MENUITEM_BACKGROUND; | ||
24 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
25 | borderThickness = 1; | ||
26 | border = BorderFactory.createLineBorder(backgroundColor, borderThickness); | ||
27 | preferredHeight = 23; | ||
28 | init(); | ||
29 | } | ||
30 | public MyMenuItem(String text) | ||
31 | { | ||
32 | super(text); | ||
33 | backgroundColor = MyContorlUtil.MENUITEM_BACKGROUND; | ||
34 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
35 | borderThickness = 1; | ||
36 | border = BorderFactory.createLineBorder(backgroundColor, borderThickness); | ||
37 | preferredHeight = 23; | ||
38 | init(); | ||
39 | } | ||
40 | private void init() | ||
41 | { | ||
42 | setForeground(foregroundColor); | ||
43 | setFont(MyContorlUtil.FONT_14_BOLD); | ||
44 | setBackground(backgroundColor); | ||
45 | setBorder(border); | ||
46 | } | ||
47 | @Override | ||
48 | public Dimension getPreferredSize() | ||
49 | { | ||
50 | return new Dimension(super.getPreferredSize().width, preferredHeight); | ||
51 | } | ||
52 | } | ||
diff --git a/src/cppcheckplus/menu/MyRootMenu.java b/src/cppcheckplus/menu/MyRootMenu.java new file mode 100644 index 0000000..b5d442d --- /dev/null +++ b/src/cppcheckplus/menu/MyRootMenu.java | |||
@@ -0,0 +1,62 @@ | |||
1 | |||
2 | |||
3 | package cppcheckplus.menu; | ||
4 | |||
5 | import java.awt.Color; | ||
6 | import java.awt.Graphics; | ||
7 | import java.awt.Graphics2D; | ||
8 | import java.awt.TexturePaint; | ||
9 | |||
10 | import javax.swing.BorderFactory; | ||
11 | import javax.swing.JMenu; | ||
12 | import javax.swing.border.Border; | ||
13 | |||
14 | import cppcheckplus.control.MyContorlUtil; | ||
15 | |||
16 | |||
17 | public class MyRootMenu extends JMenu | ||
18 | { | ||
19 | private Color foregroundColor; | ||
20 | private String selectedBackgroundImageURL; | ||
21 | private TexturePaint paint; | ||
22 | private Border border; | ||
23 | |||
24 | public MyRootMenu() | ||
25 | { | ||
26 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
27 | paint = MyContorlUtil.createTexturePaint("control/images/menubar_background_selected.png"); | ||
28 | border = BorderFactory.createEmptyBorder(0, 5, 0, 4); | ||
29 | init(); | ||
30 | |||
31 | } | ||
32 | |||
33 | public MyRootMenu(String text) | ||
34 | { | ||
35 | super(text); | ||
36 | foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR; | ||
37 | paint = MyContorlUtil.createTexturePaint("control/images/menubar_background_selected.png"); | ||
38 | border = BorderFactory.createEmptyBorder(0, 5, 0, 4); | ||
39 | init(); | ||
40 | } | ||
41 | |||
42 | private void init() | ||
43 | { | ||
44 | setFont(MyContorlUtil.FONT_14_BOLD); | ||
45 | setBorder(border); | ||
46 | setForeground(foregroundColor); | ||
47 | } | ||
48 | |||
49 | protected void paintComponent(Graphics g) | ||
50 | { | ||
51 | if (isSelected()) | ||
52 | { | ||
53 | Graphics2D g2d = (Graphics2D)g; | ||
54 | g2d.setPaint(paint); | ||
55 | g2d.fillRect(0, 0, getWidth(), getHeight()); | ||
56 | super.paintComponent(g); | ||
57 | } else | ||
58 | { | ||
59 | super.paintComponent(g); | ||
60 | } | ||
61 | } | ||
62 | } | ||