diff options
Diffstat (limited to 'src/cppcheckplus/control')
-rw-r--r-- | src/cppcheckplus/control/MyContentPanel.java | 16 | ||||
-rw-r--r-- | src/cppcheckplus/control/MyHeader.java | 341 | ||||
-rw-r--r-- | src/cppcheckplus/control/MyList.java | 104 | ||||
-rw-r--r-- | src/cppcheckplus/control/MyListRenderer.java | 222 | ||||
-rw-r--r-- | src/cppcheckplus/control/MyListSplitListener.java | 71 | ||||
-rw-r--r-- | src/cppcheckplus/control/MySeparator.java | 58 | ||||
-rw-r--r-- | src/cppcheckplus/control/MyTextField.java | 93 | ||||
-rw-r--r-- | src/cppcheckplus/control/MyToolbarButton.java | 131 | ||||
-rw-r--r-- | src/cppcheckplus/control/UIFrame.java | 10 | ||||
-rw-r--r-- | src/cppcheckplus/control/XChartletFullScreenListenter.java | 6 |
10 files changed, 489 insertions, 563 deletions
diff --git a/src/cppcheckplus/control/MyContentPanel.java b/src/cppcheckplus/control/MyContentPanel.java index 63d792a..f676cc8 100644 --- a/src/cppcheckplus/control/MyContentPanel.java +++ b/src/cppcheckplus/control/MyContentPanel.java | |||
@@ -1,16 +1,12 @@ | |||
1 | |||
2 | package cppcheckplus.control; | 1 | package cppcheckplus.control; |
3 | 2 | ||
4 | import java.awt.BorderLayout; | 3 | import java.awt.BorderLayout; |
5 | |||
6 | import javax.swing.JPanel; | 4 | import javax.swing.JPanel; |
7 | 5 | ||
8 | public class MyContentPanel extends JPanel | 6 | public class MyContentPanel extends JPanel { |
9 | { | 7 | public MyContentPanel() { |
10 | public MyContentPanel() | 8 | super(); |
11 | { | 9 | setLayout(new BorderLayout()); |
12 | super(); | 10 | setBackground(MyContorlUtil.CONTENT_PANE_BACKGROUND); |
13 | setLayout(new BorderLayout()); | 11 | } |
14 | setBackground(MyContorlUtil.CONTENT_PANE_BACKGROUND); | ||
15 | } | ||
16 | } | 12 | } |
diff --git a/src/cppcheckplus/control/MyHeader.java b/src/cppcheckplus/control/MyHeader.java index 1b71704..2cd11b8 100644 --- a/src/cppcheckplus/control/MyHeader.java +++ b/src/cppcheckplus/control/MyHeader.java | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | package cppcheckplus.control; | 1 | package cppcheckplus.control; |
3 | 2 | ||
4 | import java.awt.BorderLayout; | 3 | import java.awt.BorderLayout; |
@@ -13,7 +12,6 @@ import java.awt.TexturePaint; | |||
13 | import java.awt.event.MouseAdapter; | 12 | import java.awt.event.MouseAdapter; |
14 | import java.awt.event.MouseEvent; | 13 | import java.awt.event.MouseEvent; |
15 | import java.awt.event.MouseListener; | 14 | import java.awt.event.MouseListener; |
16 | |||
17 | import javax.swing.BorderFactory; | 15 | import javax.swing.BorderFactory; |
18 | import javax.swing.ImageIcon; | 16 | import javax.swing.ImageIcon; |
19 | import javax.swing.JComponent; | 17 | import javax.swing.JComponent; |
@@ -22,180 +20,167 @@ import javax.swing.JPanel; | |||
22 | import javax.swing.border.Border; | 20 | import javax.swing.border.Border; |
23 | 21 | ||
24 | 22 | ||
25 | 23 | public class MyHeader extends JPanel { | |
26 | public class MyHeader extends JPanel | 24 | public static final ImageIcon RIGHT_ARROW_ICON = |
27 | { | 25 | MyContorlUtil.getImageIcon("control/images/shrink_handler_right.png"); |
28 | public static final ImageIcon RIGHT_ARROW_ICON = MyContorlUtil.getImageIcon("control/images/shrink_handler_right.png"); | 26 | public static final ImageIcon LEFT_ARROW_ICON = |
29 | public static final ImageIcon LEFT_ARROW_ICON = MyContorlUtil.getImageIcon("control/images/shrink_handler_left.png"); | 27 | MyContorlUtil.getImageIcon("control/images/shrink_handler_left.png"); |
30 | private Color titleColor; | 28 | private Color titleColor; |
31 | private boolean shrinked; | 29 | private boolean shrinked; |
32 | private ImageIcon backgroundImageIcon; | 30 | private ImageIcon backgroundImageIcon; |
33 | private Image backgroundLeftImage; | 31 | private Image backgroundLeftImage; |
34 | private Image backgroundRightImage; | 32 | private Image backgroundRightImage; |
35 | private TexturePaint paint; | 33 | private TexturePaint paint; |
36 | private int preferredHeight; | 34 | private int preferredHeight; |
37 | private JLabel lbResizeHandler; | 35 | private JLabel lbResizeHandler; |
38 | private JLabel lbShrinkHandler; | 36 | private JLabel lbShrinkHandler; |
39 | private JLabel lbTitle; | 37 | private JLabel lbTitle; |
40 | private int normalPreferredWidth; | 38 | private int normalPreferredWidth; |
41 | private MyListSplitListener splitListener; | 39 | private MyListSplitListener splitListener; |
42 | private MouseListener shrinkListener; | 40 | private MouseListener shrinkListener; |
43 | 41 | ||
44 | public MyHeader() | 42 | public MyHeader() { |
45 | { | 43 | super(); |
46 | super(); | 44 | titleColor = new Color(215, 215, 216); |
47 | titleColor = new Color(215, 215, 216); | 45 | shrinked = false; |
48 | shrinked = false; | 46 | backgroundImageIcon = |
49 | backgroundImageIcon = MyContorlUtil.getImageIcon("control/images/header_background.png"); | 47 | MyContorlUtil.getImageIcon("control/images/header_background.png"); |
50 | backgroundLeftImage = MyContorlUtil.getImage("control/images/header_background_left.png"); | 48 | backgroundLeftImage = |
51 | backgroundRightImage = MyContorlUtil.getImage("control/images/header_background_right.png"); | 49 | MyContorlUtil.getImage("control/images/header_background_left.png"); |
52 | paint = MyContorlUtil.createTexturePaint("control/images/header_background.png"); | 50 | backgroundRightImage = MyContorlUtil.getImage( |
53 | preferredHeight = backgroundImageIcon.getIconHeight(); | 51 | "control/images/header_background_right.png"); |
54 | lbResizeHandler = new JLabel(MyContorlUtil.getImageIcon("control/images/resize_handler.png")); | 52 | paint = MyContorlUtil.createTexturePaint( |
55 | lbShrinkHandler = new JLabel(getShrinkIcon(shrinked)); | 53 | "control/images/header_background.png"); |
56 | lbTitle = new JLabel(); | 54 | preferredHeight = backgroundImageIcon.getIconHeight(); |
57 | normalPreferredWidth = 0; | 55 | lbResizeHandler = new JLabel( |
58 | splitListener = createSplitListener(); | 56 | MyContorlUtil.getImageIcon("control/images/resize_handler.png")); |
59 | shrinkListener = new MouseAdapter() { | 57 | lbShrinkHandler = new JLabel(getShrinkIcon(shrinked)); |
60 | public void mouseClicked(MouseEvent e) | 58 | lbTitle = new JLabel(); |
61 | { | 59 | normalPreferredWidth = 0; |
62 | changeShrink(); | 60 | splitListener = createSplitListener(); |
63 | } | 61 | shrinkListener = new MouseAdapter() { |
64 | }; | 62 | public void mouseClicked(MouseEvent e) { |
65 | init(); | 63 | changeShrink(); |
66 | } | 64 | } |
67 | 65 | }; | |
68 | protected MyListSplitListener createSplitListener() | 66 | init(); |
69 | { | 67 | } |
70 | return new MyListSplitListener(this); | 68 | |
71 | } | 69 | protected MyListSplitListener createSplitListener() { |
72 | 70 | return new MyListSplitListener(this); | |
73 | protected Border createBorder() | 71 | } |
74 | { | 72 | |
75 | return BorderFactory.createEmptyBorder(4, 7, 0, 0); | 73 | protected Border createBorder() { |
76 | } | 74 | return BorderFactory.createEmptyBorder(4, 7, 0, 0); |
77 | 75 | } | |
78 | private void init() | 76 | |
79 | { | 77 | private void init() { |
80 | setBorder(createBorder()); | 78 | setBorder(createBorder()); |
81 | setOpaque(false); | 79 | setOpaque(false); |
82 | setLayout(new BorderLayout()); | 80 | setLayout(new BorderLayout()); |
83 | add(lbResizeHandler, getResizeHandlerLayoutConstraint()); | 81 | add(lbResizeHandler, getResizeHandlerLayoutConstraint()); |
84 | add(lbShrinkHandler, getShrinkHandlerLayoutConstraint()); | 82 | add(lbShrinkHandler, getShrinkHandlerLayoutConstraint()); |
85 | JComponent centerComponent = getCenterComponent(); | 83 | JComponent centerComponent = getCenterComponent(); |
86 | if (centerComponent != null) | 84 | if (centerComponent != null) { |
87 | add(centerComponent, "Center"); | 85 | add(centerComponent, "Center"); |
88 | lbResizeHandler.addMouseMotionListener(splitListener); | 86 | } |
89 | lbResizeHandler.addMouseListener(splitListener); | 87 | lbResizeHandler.addMouseMotionListener(splitListener); |
90 | lbShrinkHandler.addMouseListener(shrinkListener); | 88 | lbResizeHandler.addMouseListener(splitListener); |
91 | lbTitle.setFont(MyContorlUtil.FONT_14_BOLD); | 89 | lbShrinkHandler.addMouseListener(shrinkListener); |
92 | lbTitle.setForeground(titleColor); | 90 | lbTitle.setFont(MyContorlUtil.FONT_14_BOLD); |
93 | lbTitle.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0)); | 91 | lbTitle.setForeground(titleColor); |
94 | updateCursor(); | 92 | lbTitle.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0)); |
95 | lbShrinkHandler.setBorder(BorderFactory.createEmptyBorder(0, 8, 2, 5)); | 93 | updateCursor(); |
96 | } | 94 | lbShrinkHandler.setBorder(BorderFactory.createEmptyBorder(0, 8, 2, 5)); |
97 | 95 | } | |
98 | protected JComponent getCenterComponent() | 96 | |
99 | { | 97 | protected JComponent getCenterComponent() { |
100 | return lbTitle; | 98 | return lbTitle; |
101 | } | 99 | } |
102 | 100 | ||
103 | protected Object getResizeHandlerLayoutConstraint() | 101 | protected Object getResizeHandlerLayoutConstraint() { |
104 | { | 102 | return "West"; |
105 | return "West"; | 103 | } |
106 | } | 104 | |
107 | 105 | protected Object getShrinkHandlerLayoutConstraint() { | |
108 | protected Object getShrinkHandlerLayoutConstraint() | 106 | return "East"; |
109 | { | 107 | } |
110 | return "East"; | 108 | |
111 | } | 109 | protected void paintComponent(Graphics g) { |
112 | 110 | Graphics2D g2d = (Graphics2D) g; | |
113 | protected void paintComponent(Graphics g) | 111 | g2d.setPaint(paint); |
114 | { | 112 | g2d.fillRect(0, 0, getWidth(), getHeight()); |
115 | Graphics2D g2d = (Graphics2D)g; | 113 | g2d.drawImage(backgroundLeftImage, 0, 0, null); |
116 | g2d.setPaint(paint); | 114 | int x = getWidth() - backgroundRightImage.getWidth(null); |
117 | g2d.fillRect(0, 0, getWidth(), getHeight()); | 115 | int y = 0; |
118 | g2d.drawImage(backgroundLeftImage, 0, 0, null); | 116 | g2d.drawImage(backgroundRightImage, x, y, null); |
119 | int x = getWidth() - backgroundRightImage.getWidth(null); | 117 | } |
120 | int y = 0; | 118 | |
121 | g2d.drawImage(backgroundRightImage, x, y, null); | 119 | public Dimension getPreferredSize() { |
122 | } | 120 | return new Dimension(super.getPreferredSize().width, preferredHeight); |
123 | 121 | } | |
124 | public Dimension getPreferredSize() | 122 | |
125 | { | 123 | public void revalidateParent() { |
126 | return new Dimension(super.getPreferredSize().width, preferredHeight); | 124 | if (getParent() instanceof JComponent) { |
127 | } | 125 | ((JComponent) getParent()).revalidate(); |
128 | 126 | } | |
129 | public void revalidateParent() | 127 | } |
130 | { | 128 | |
131 | if (getParent() instanceof JComponent) | 129 | public void changeShrink() { |
132 | ((JComponent)getParent()).revalidate(); | 130 | setShrink(!isShrinked()); |
133 | } | 131 | } |
134 | 132 | ||
135 | public void changeShrink() | 133 | public void setShrink(boolean shrinked) { |
136 | { | 134 | if (shrinked != this.shrinked) { |
137 | setShrink(!isShrinked()); | 135 | Container parent = getParent(); |
138 | } | 136 | Dimension size = parent.getPreferredSize(); |
139 | 137 | if (shrinked) { | |
140 | public void setShrink(boolean shrinked) | 138 | normalPreferredWidth = size.width; |
141 | { | 139 | size = new Dimension(getShrinkedWidth(), size.height); |
142 | if (shrinked != this.shrinked) | 140 | } else { |
143 | { | 141 | int width = normalPreferredWidth; |
144 | Container parent = getParent(); | 142 | int height = parent.getPreferredSize().height; |
145 | Dimension size = parent.getPreferredSize(); | 143 | size = new Dimension(width, height); |
146 | if (shrinked) | 144 | } |
147 | { | 145 | parent.setPreferredSize(size); |
148 | normalPreferredWidth = size.width; | 146 | lbShrinkHandler.setIcon(getShrinkIcon(shrinked)); |
149 | size = new Dimension(getShrinkedWidth(), size.height); | 147 | revalidateParent(); |
150 | } else | 148 | this.shrinked = shrinked; |
151 | { | 149 | updateCursor(); |
152 | int width = normalPreferredWidth; | 150 | lbTitle.setVisible(!shrinked); |
153 | int height = parent.getPreferredSize().height; | 151 | lbResizeHandler.setVisible(!shrinked); |
154 | size = new Dimension(width, height); | 152 | } |
155 | } | 153 | } |
156 | parent.setPreferredSize(size); | 154 | |
157 | lbShrinkHandler.setIcon(getShrinkIcon(shrinked)); | 155 | protected ImageIcon getShrinkIcon(boolean shrinked) { |
158 | revalidateParent(); | 156 | if (shrinked) { |
159 | this.shrinked = shrinked; | 157 | return LEFT_ARROW_ICON; |
160 | updateCursor(); | 158 | } else { |
161 | lbTitle.setVisible(!shrinked); | 159 | return RIGHT_ARROW_ICON; |
162 | lbResizeHandler.setVisible(!shrinked); | 160 | } |
163 | } | 161 | } |
164 | } | 162 | |
165 | 163 | private void updateCursor() { | |
166 | protected ImageIcon getShrinkIcon(boolean shrinked) | 164 | if (shrinked) { |
167 | { | 165 | lbResizeHandler.setCursor(Cursor.getDefaultCursor()); |
168 | if (shrinked) | 166 | } else { |
169 | return LEFT_ARROW_ICON; | 167 | lbResizeHandler.setCursor(Cursor.getPredefinedCursor(10)); |
170 | else | 168 | } |
171 | return RIGHT_ARROW_ICON; | 169 | } |
172 | } | 170 | |
173 | 171 | public boolean isShrinked() { | |
174 | private void updateCursor() | 172 | return shrinked; |
175 | { | 173 | } |
176 | if (shrinked) | 174 | |
177 | lbResizeHandler.setCursor(Cursor.getDefaultCursor()); | 175 | public String getTitle() { |
178 | else | 176 | return lbTitle.getText(); |
179 | lbResizeHandler.setCursor(Cursor.getPredefinedCursor(10)); | 177 | } |
180 | } | 178 | |
181 | 179 | public void setTitle(String title) { | |
182 | public boolean isShrinked() | 180 | lbTitle.setText(title); |
183 | { | 181 | } |
184 | return shrinked; | 182 | |
185 | } | 183 | protected int getShrinkedWidth() { |
186 | 184 | return 37; | |
187 | public void setTitle(String title) | 185 | } |
188 | { | ||
189 | lbTitle.setText(title); | ||
190 | } | ||
191 | |||
192 | public String getTitle() | ||
193 | { | ||
194 | return lbTitle.getText(); | ||
195 | } | ||
196 | |||
197 | protected int getShrinkedWidth() | ||
198 | { | ||
199 | return 37; | ||
200 | } | ||
201 | } | 186 | } |
diff --git a/src/cppcheckplus/control/MyList.java b/src/cppcheckplus/control/MyList.java index 2a577ff..084ee74 100644 --- a/src/cppcheckplus/control/MyList.java +++ b/src/cppcheckplus/control/MyList.java | |||
@@ -1,68 +1,58 @@ | |||
1 | |||
2 | package cppcheckplus.control; | 1 | package cppcheckplus.control; |
3 | 2 | ||
3 | import cppcheckplus.shortcut.MyShortcutItem; | ||
4 | import cppcheckplus.shortcut.MyShortcutItemClickListenter; | ||
4 | import java.awt.event.MouseEvent; | 5 | import java.awt.event.MouseEvent; |
5 | |||
6 | import javax.swing.JList; | 6 | import javax.swing.JList; |
7 | import javax.swing.event.MouseInputAdapter; | 7 | import javax.swing.event.MouseInputAdapter; |
8 | import javax.swing.event.MouseInputListener; | 8 | import javax.swing.event.MouseInputListener; |
9 | 9 | ||
10 | import cppcheckplus.shortcut.MyShortcutItem; | ||
11 | import cppcheckplus.shortcut.MyShortcutItemClickListenter; | ||
12 | 10 | ||
11 | public class MyList extends JList { | ||
12 | private MyShortcutItemClickListenter clickListenter; | ||
13 | |||
14 | public MyList() { | ||
15 | init(); | ||
16 | } | ||
17 | |||
18 | public void setListenter(MyShortcutItemClickListenter itemClickListenter) { | ||
19 | this.clickListenter = itemClickListenter; | ||
20 | MouseInputListener listener = new MouseInputAdapter() { | ||
21 | //通过Move设置Item为selected,从而触发渲染器处理,实现高亮 | ||
22 | @Override | ||
23 | public void mouseMoved(MouseEvent e) { | ||
24 | int moveIndex = locationToIndex(e.getPoint()); | ||
25 | setSelectedIndex(moveIndex); | ||
26 | } | ||
27 | |||
28 | //移动出去之后,清除选中,从而触发渲染器 | ||
29 | @Override | ||
30 | public void mouseExited(MouseEvent e) { | ||
31 | getSelectionModel().clearSelection(); | ||
32 | } | ||
13 | 33 | ||
14 | public class MyList extends JList | 34 | @Override |
15 | { | 35 | public void mouseClicked(MouseEvent e) { |
16 | private MyShortcutItemClickListenter clickListenter; | 36 | //因为该JList是单选模式,所以取第一个选择的就可以了 |
17 | 37 | Object selObj = getSelectedValue(); | |
18 | public MyList() | 38 | if (selObj != null) { |
19 | { | 39 | MyShortcutItem item = (MyShortcutItem) selObj; |
20 | init(); | 40 | if (!item.isGroup()) { |
21 | } | 41 | clickListenter.ItemClick(item.getActionCommand()); |
22 | public void setListenter(MyShortcutItemClickListenter itemClickListenter) | 42 | } |
23 | { | 43 | } |
24 | this.clickListenter = itemClickListenter; | 44 | //itemClick.ItemClick(actionCommand) |
25 | MouseInputListener listener = new MouseInputAdapter() | 45 | } |
26 | { | 46 | }; |
27 | //通过Move设置Item为selected,从而触发渲染器处理,实现高亮 | 47 | addMouseMotionListener(listener); |
28 | @Override | 48 | addMouseListener(listener); |
29 | public void mouseMoved(MouseEvent e) | 49 | } |
30 | { | ||
31 | int moveIndex = locationToIndex(e.getPoint()); | ||
32 | setSelectedIndex(moveIndex); | ||
33 | } | ||
34 | //移动出去之后,清除选中,从而触发渲染器 | ||
35 | @Override | ||
36 | public void mouseExited(MouseEvent e) | ||
37 | { | ||
38 | getSelectionModel().clearSelection(); | ||
39 | } | ||
40 | 50 | ||
41 | @Override | 51 | private void init() { |
42 | public void mouseClicked(MouseEvent e) | 52 | setFont(MyContorlUtil.FONT_12_BOLD); |
43 | { | 53 | setForeground(MyContorlUtil.DEFAULT_TEXT_COLOR); |
44 | //因为该JList是单选模式,所以取第一个选择的就可以了 | 54 | setBackground(MyContorlUtil.LIST_BACKGROUND); |
45 | Object selObj = getSelectedValue(); | 55 | setCellRenderer(new MyListRenderer(this)); |
46 | if(selObj != null) | 56 | setSelectionMode(0); |
47 | { | 57 | } |
48 | MyShortcutItem item = (MyShortcutItem)selObj; | ||
49 | if(!item.isGroup()) | ||
50 | { | ||
51 | clickListenter.ItemClick(item.getActionCommand()); | ||
52 | } | ||
53 | } | ||
54 | //itemClick.ItemClick(actionCommand) | ||
55 | } | ||
56 | }; | ||
57 | addMouseMotionListener(listener); | ||
58 | addMouseListener(listener); | ||
59 | } | ||
60 | private void init() | ||
61 | { | ||
62 | setFont(MyContorlUtil.FONT_12_BOLD); | ||
63 | setForeground(MyContorlUtil.DEFAULT_TEXT_COLOR); | ||
64 | setBackground(MyContorlUtil.LIST_BACKGROUND); | ||
65 | setCellRenderer(new MyListRenderer(this)); | ||
66 | setSelectionMode(0); | ||
67 | } | ||
68 | } | 58 | } |
diff --git a/src/cppcheckplus/control/MyListRenderer.java b/src/cppcheckplus/control/MyListRenderer.java index 1495378..b407227 100644 --- a/src/cppcheckplus/control/MyListRenderer.java +++ b/src/cppcheckplus/control/MyListRenderer.java | |||
@@ -1,12 +1,12 @@ | |||
1 | |||
2 | package cppcheckplus.control; | 1 | package cppcheckplus.control; |
3 | 2 | ||
3 | import cppcheckplus.shortcut.MyShortcutItem; | ||
4 | import cppcheckplus.shortcut.MyShortcutPanel; | ||
4 | import java.awt.BorderLayout; | 5 | import java.awt.BorderLayout; |
5 | import java.awt.Color; | 6 | import java.awt.Color; |
6 | import java.awt.Component; | 7 | import java.awt.Component; |
7 | import java.awt.Dimension; | 8 | import java.awt.Dimension; |
8 | import java.awt.Font; | 9 | import java.awt.Font; |
9 | |||
10 | import javax.swing.BorderFactory; | 10 | import javax.swing.BorderFactory; |
11 | import javax.swing.DefaultListCellRenderer; | 11 | import javax.swing.DefaultListCellRenderer; |
12 | import javax.swing.JLabel; | 12 | import javax.swing.JLabel; |
@@ -14,125 +14,111 @@ import javax.swing.JList; | |||
14 | import javax.swing.JPanel; | 14 | import javax.swing.JPanel; |
15 | import javax.swing.OverlayLayout; | 15 | import javax.swing.OverlayLayout; |
16 | 16 | ||
17 | import cppcheckplus.shortcut.MyShortcutItem; | ||
18 | import cppcheckplus.shortcut.MyShortcutPanel; | ||
19 | |||
20 | //快捷菜单 | 17 | //快捷菜单 |
21 | public class MyListRenderer extends DefaultListCellRenderer | 18 | public class MyListRenderer extends DefaultListCellRenderer { |
22 | { | 19 | private JPanel itemRender; |
23 | private JPanel itemRender; | 20 | private int separatorHeight = 30; |
24 | private int separatorHeight = 30; | 21 | //每组List的分割Group |
25 | //每组List的分割Group | 22 | private JPanel separatorPanel; |
26 | private JPanel separatorPanel; | 23 | private JLabel separatorLabel; |
27 | private JLabel separatorLabel; | 24 | private MySeparator separator; |
28 | private MySeparator separator; | 25 | private Color itemTextColor; |
29 | private Color itemTextColor; | 26 | private Color separatorTextColor; |
30 | private Color separatorTextColor; | 27 | private Color itemSelectedBackground; |
31 | private Color itemSelectedBackground; | 28 | private Color itemSelectedBorder; |
32 | private Color itemSelectedBorder; | 29 | private Font separatorFont; |
33 | private Font separatorFont; | 30 | |
34 | 31 | public MyListRenderer(MyList list) { | |
35 | public MyListRenderer(MyList list) | 32 | super(); |
36 | { | 33 | itemRender = new JPanel(new BorderLayout()); |
37 | super(); | 34 | separatorPanel = new JPanel() { |
38 | itemRender = new JPanel(new BorderLayout()); | 35 | |
39 | separatorPanel = new JPanel() { | 36 | public Dimension getPreferredSize() { |
37 | Dimension size = super.getPreferredSize(); | ||
38 | return new Dimension(size.width, separatorHeight); | ||
39 | } | ||
40 | |||
41 | }; | ||
42 | //分割Group的样式 | ||
43 | separatorLabel = new JLabel(); | ||
44 | separator = new MySeparator(0); | ||
45 | separatorTextColor = Color.white; | ||
46 | separatorFont = MyContorlUtil.FONT_12_BOLD; | ||
47 | |||
48 | itemTextColor = MyContorlUtil.LIST_TEXT_COLOR; | ||
49 | itemSelectedBackground = new Color(199, 198, 200); | ||
50 | itemSelectedBorder = new Color(163, 163, 163); | ||
51 | itemRender.setOpaque(false); | ||
52 | itemRender.add(this, "Center"); | ||
53 | separatorPanel.setLayout(new OverlayLayout(separatorPanel)); | ||
54 | JPanel separatorHelpPane = new JPanel(new BorderLayout()); | ||
55 | separatorHelpPane.setBorder( | ||
56 | BorderFactory.createEmptyBorder(12, 0, 0, 0)); | ||
57 | separatorHelpPane.add(separator); | ||
58 | separatorHelpPane.setOpaque(false); | ||
59 | separatorPanel.setOpaque(false); | ||
60 | separatorLabel.setOpaque(true); | ||
61 | separatorLabel.setBackground(MyContorlUtil.LIST_BACKGROUND); | ||
62 | separatorLabel.setForeground(separatorTextColor); | ||
63 | separatorLabel.setFont(separatorFont); | ||
64 | separatorLabel.setVerticalAlignment(1); | ||
65 | separatorLabel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); | ||
66 | JPanel labelHelpPane = new JPanel(new BorderLayout()); | ||
67 | labelHelpPane.setBorder(BorderFactory.createEmptyBorder(6, 15, 0, 0)); | ||
68 | labelHelpPane.add(separatorLabel, "West"); | ||
69 | labelHelpPane.setOpaque(false); | ||
70 | separatorPanel.add(labelHelpPane); | ||
71 | separatorPanel.add(separatorHelpPane); | ||
72 | } | ||
40 | 73 | ||
41 | public Dimension getPreferredSize() | 74 | public Component getListCellRendererComponent(JList list, Object value, |
42 | { | 75 | int index, boolean isSelected, |
43 | Dimension size = super.getPreferredSize(); | 76 | boolean cellHasFocus) { |
44 | return new Dimension(size.width, separatorHeight); | 77 | MyShortcutItem shortcutItem = (MyShortcutItem) value; |
45 | } | 78 | //Group的渲染 |
79 | if (shortcutItem.isGroup()) { | ||
80 | String groupName = shortcutItem.getText(); | ||
81 | separatorLabel.setText(groupName); | ||
82 | separatorPanel.setToolTipText(groupName); | ||
83 | if (list.getParent() instanceof MyShortcutPanel) { | ||
84 | MyShortcutPanel pane = (MyShortcutPanel) list.getParent(); | ||
85 | if (pane.isShrinked()) { | ||
86 | separatorLabel.setText(" "); | ||
87 | separatorLabel.setOpaque(false); | ||
88 | } else { | ||
89 | separatorLabel.setOpaque(true); | ||
90 | } | ||
91 | } | ||
92 | return separatorPanel; | ||
93 | } | ||
94 | //普通Item的渲染 | ||
95 | else { | ||
96 | setText(shortcutItem.getText()); | ||
97 | setBackground(MyContorlUtil.LIST_BACKGROUND); | ||
98 | setToolTipText(shortcutItem.getToolTip()); | ||
99 | setIcon(shortcutItem.getIcon()); | ||
100 | } | ||
46 | 101 | ||
47 | }; | 102 | //判断List的父容器是否是快捷菜单面板,如果是,需要考虑收缩展开的处理 |
48 | //分割Group的样式 | 103 | if (list.getParent() instanceof MyShortcutPanel) { |
49 | separatorLabel = new JLabel(); | 104 | MyShortcutPanel pane = (MyShortcutPanel) list.getParent(); |
50 | separator = new MySeparator(0); | 105 | if (pane.isShrinked()) { |
51 | separatorTextColor = Color.white; | 106 | setBorder(BorderFactory.createEmptyBorder(2, 7, 1, 2)); |
52 | separatorFont = MyContorlUtil.FONT_12_BOLD; | 107 | setText(""); |
53 | 108 | } else { | |
54 | itemTextColor = MyContorlUtil.LIST_TEXT_COLOR; | 109 | setBorder(BorderFactory.createEmptyBorder(2, 20, 1, 2)); |
55 | itemSelectedBackground = new Color(199, 198, 200); | 110 | } |
56 | itemSelectedBorder = new Color(163, 163, 163); | 111 | } |
57 | itemRender.setOpaque(false); | 112 | if (isSelected) { |
58 | itemRender.add(this, "Center"); | 113 | setBackground(itemSelectedBackground); |
59 | separatorPanel.setLayout(new OverlayLayout(separatorPanel)); | 114 | itemRender.setBorder( |
60 | JPanel separatorHelpPane = new JPanel(new BorderLayout()); | 115 | BorderFactory.createLineBorder(itemSelectedBorder)); |
61 | separatorHelpPane.setBorder(BorderFactory.createEmptyBorder(12, 0, 0, 0)); | 116 | } else { |
62 | separatorHelpPane.add(separator); | 117 | itemRender.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); |
63 | separatorHelpPane.setOpaque(false); | 118 | } |
64 | separatorPanel.setOpaque(false); | 119 | setForeground(itemTextColor); |
65 | separatorLabel.setOpaque(true); | ||
66 | separatorLabel.setBackground(MyContorlUtil.LIST_BACKGROUND); | ||
67 | separatorLabel.setForeground(separatorTextColor); | ||
68 | separatorLabel.setFont(separatorFont); | ||
69 | separatorLabel.setVerticalAlignment(1); | ||
70 | separatorLabel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); | ||
71 | JPanel labelHelpPane = new JPanel(new BorderLayout()); | ||
72 | labelHelpPane.setBorder(BorderFactory.createEmptyBorder(6, 15, 0, 0)); | ||
73 | labelHelpPane.add(separatorLabel, "West"); | ||
74 | labelHelpPane.setOpaque(false); | ||
75 | separatorPanel.add(labelHelpPane); | ||
76 | separatorPanel.add(separatorHelpPane); | ||
77 | } | ||
78 | 120 | ||
79 | public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) | 121 | return itemRender; |
80 | { | 122 | } |
81 | MyShortcutItem shortcutItem = (MyShortcutItem)value; | ||
82 | //Group的渲染 | ||
83 | if(shortcutItem.isGroup()) | ||
84 | { | ||
85 | String groupName = shortcutItem.getText(); | ||
86 | separatorLabel.setText(groupName); | ||
87 | separatorPanel.setToolTipText(groupName); | ||
88 | if (list.getParent() instanceof MyShortcutPanel) | ||
89 | { | ||
90 | MyShortcutPanel pane = (MyShortcutPanel)list.getParent(); | ||
91 | if (pane.isShrinked()) | ||
92 | { | ||
93 | separatorLabel.setText(" "); | ||
94 | separatorLabel.setOpaque(false); | ||
95 | } else | ||
96 | { | ||
97 | separatorLabel.setOpaque(true); | ||
98 | } | ||
99 | } | ||
100 | return separatorPanel; | ||
101 | } | ||
102 | //普通Item的渲染 | ||
103 | else | ||
104 | { | ||
105 | setText(shortcutItem.getText()); | ||
106 | setBackground(MyContorlUtil.LIST_BACKGROUND); | ||
107 | setToolTipText(shortcutItem.getToolTip()); | ||
108 | setIcon(shortcutItem.getIcon()); | ||
109 | } | ||
110 | |||
111 | //判断List的父容器是否是快捷菜单面板,如果是,需要考虑收缩展开的处理 | ||
112 | if (list.getParent() instanceof MyShortcutPanel) | ||
113 | { | ||
114 | MyShortcutPanel pane = (MyShortcutPanel)list.getParent(); | ||
115 | if (pane.isShrinked()) | ||
116 | { | ||
117 | setBorder(BorderFactory.createEmptyBorder(2, 7, 1, 2)); | ||
118 | setText(""); | ||
119 | } else | ||
120 | { | ||
121 | setBorder(BorderFactory.createEmptyBorder(2, 20, 1, 2)); | ||
122 | } | ||
123 | } | ||
124 | if (isSelected) | ||
125 | { | ||
126 | setBackground(itemSelectedBackground); | ||
127 | itemRender.setBorder(BorderFactory.createLineBorder(itemSelectedBorder)); | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | itemRender.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); | ||
132 | } | ||
133 | setForeground(itemTextColor); | ||
134 | |||
135 | return itemRender; | ||
136 | } | ||
137 | 123 | ||
138 | } | 124 | } |
diff --git a/src/cppcheckplus/control/MyListSplitListener.java b/src/cppcheckplus/control/MyListSplitListener.java index 4ee8fea..b594f98 100644 --- a/src/cppcheckplus/control/MyListSplitListener.java +++ b/src/cppcheckplus/control/MyListSplitListener.java | |||
@@ -1,50 +1,43 @@ | |||
1 | |||
2 | package cppcheckplus.control; | 1 | package cppcheckplus.control; |
3 | 2 | ||
4 | import java.awt.Dimension; | 3 | import java.awt.Dimension; |
5 | import java.awt.Point; | 4 | import java.awt.Point; |
6 | import java.awt.event.MouseEvent; | 5 | import java.awt.event.MouseEvent; |
7 | |||
8 | import javax.swing.JComponent; | 6 | import javax.swing.JComponent; |
9 | import javax.swing.event.MouseInputAdapter; | 7 | import javax.swing.event.MouseInputAdapter; |
10 | 8 | ||
11 | 9 | ||
12 | public class MyListSplitListener extends MouseInputAdapter | 10 | public class MyListSplitListener extends MouseInputAdapter { |
13 | { | 11 | protected Point lastPoint; |
14 | protected Point lastPoint; | 12 | protected MyHeader header; |
15 | protected MyHeader header; | 13 | |
16 | 14 | public MyListSplitListener(MyHeader header) { | |
17 | public MyListSplitListener(MyHeader header) | 15 | lastPoint = null; |
18 | { | 16 | this.header = null; |
19 | lastPoint = null; | 17 | this.header = header; |
20 | this.header = null; | 18 | } |
21 | this.header = header; | 19 | |
22 | } | 20 | public void mousePressed(MouseEvent e) { |
23 | 21 | if (!header.isShrinked()) { | |
24 | public void mousePressed(MouseEvent e) | 22 | lastPoint = e.getPoint(); |
25 | { | 23 | } |
26 | if (!header.isShrinked()) | 24 | } |
27 | lastPoint = e.getPoint(); | 25 | |
28 | } | 26 | public void mouseReleased(MouseEvent e) { |
29 | 27 | lastPoint = null; | |
30 | public void mouseReleased(MouseEvent e) | 28 | } |
31 | { | 29 | |
32 | lastPoint = null; | 30 | public void mouseDragged(MouseEvent e) { |
33 | } | 31 | if (!header.isShrinked() && lastPoint != null) { |
34 | 32 | JComponent parent = (JComponent) header.getParent(); | |
35 | public void mouseDragged(MouseEvent e) | 33 | Dimension size = parent.getPreferredSize(); |
36 | { | 34 | Point thisPoint = e.getPoint(); |
37 | if (!header.isShrinked() && lastPoint != null) | 35 | int xMovement = thisPoint.x - lastPoint.x; |
38 | { | 36 | size.width -= xMovement; |
39 | JComponent parent = (JComponent)header.getParent(); | 37 | size.width = Math.max(size.width, 37); |
40 | Dimension size = parent.getPreferredSize(); | 38 | parent.setPreferredSize(size); |
41 | Point thisPoint = e.getPoint(); | 39 | header.revalidateParent(); |
42 | int xMovement = thisPoint.x - lastPoint.x; | 40 | } |
43 | size.width -= xMovement; | 41 | } |
44 | size.width = Math.max(size.width, 37); | ||
45 | parent.setPreferredSize(size); | ||
46 | header.revalidateParent(); | ||
47 | } | ||
48 | } | ||
49 | 42 | ||
50 | } | 43 | } |
diff --git a/src/cppcheckplus/control/MySeparator.java b/src/cppcheckplus/control/MySeparator.java index f5ba4ad..a7769d7 100644 --- a/src/cppcheckplus/control/MySeparator.java +++ b/src/cppcheckplus/control/MySeparator.java | |||
@@ -1,40 +1,38 @@ | |||
1 | |||
2 | package cppcheckplus.control; | 1 | package cppcheckplus.control; |
3 | 2 | ||
4 | import java.awt.Graphics; | 3 | import java.awt.Graphics; |
5 | import java.awt.Graphics2D; | 4 | import java.awt.Graphics2D; |
6 | import java.awt.Image; | 5 | import java.awt.Image; |
7 | import java.awt.TexturePaint; | 6 | import java.awt.TexturePaint; |
8 | |||
9 | import javax.swing.JSeparator; | 7 | import javax.swing.JSeparator; |
10 | 8 | ||
11 | 9 | ||
12 | public class MySeparator extends JSeparator | 10 | public class MySeparator extends JSeparator { |
13 | { | 11 | private Image image; |
14 | private Image image; | 12 | private TexturePaint paint; |
15 | private TexturePaint paint; | 13 | |
16 | 14 | public MySeparator() { | |
17 | public MySeparator() | 15 | image = |
18 | { | 16 | MyContorlUtil.getImage("control/images/separator_background.png"); |
19 | image = MyContorlUtil.getImage("control/images/separator_background.png"); | 17 | paint = MyContorlUtil.createTexturePaint( |
20 | paint = MyContorlUtil.createTexturePaint("control/images/separator_background.png"); | 18 | "control/images/separator_background.png"); |
21 | } | 19 | } |
22 | 20 | ||
23 | public MySeparator(int direction) | 21 | public MySeparator(int direction) { |
24 | { | 22 | super(direction); |
25 | super(direction); | 23 | image = |
26 | image = MyContorlUtil.getImage("control/images/separator_background.png"); | 24 | MyContorlUtil.getImage("control/images/separator_background.png"); |
27 | paint = MyContorlUtil.createTexturePaint("control/images/separator_background.png"); | 25 | paint = MyContorlUtil.createTexturePaint( |
28 | } | 26 | "control/images/separator_background.png"); |
29 | 27 | } | |
30 | public void paintComponent(Graphics g) | 28 | |
31 | { | 29 | public void paintComponent(Graphics g) { |
32 | Graphics2D g2d = (Graphics2D)g; | 30 | Graphics2D g2d = (Graphics2D) g; |
33 | g2d.setPaint(paint); | 31 | g2d.setPaint(paint); |
34 | int x = 0; | 32 | int x = 0; |
35 | int y = 0; | 33 | int y = 0; |
36 | int width = getWidth(); | 34 | int width = getWidth(); |
37 | int height = image.getHeight(null); | 35 | int height = image.getHeight(null); |
38 | g2d.fillRect(x, y, width, height); | 36 | g2d.fillRect(x, y, width, height); |
39 | } | 37 | } |
40 | } | 38 | } |
diff --git a/src/cppcheckplus/control/MyTextField.java b/src/cppcheckplus/control/MyTextField.java index d0ed080..1edae1e 100644 --- a/src/cppcheckplus/control/MyTextField.java +++ b/src/cppcheckplus/control/MyTextField.java | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | package cppcheckplus.control; | 1 | package cppcheckplus.control; |
3 | 2 | ||
4 | import java.awt.Dimension; | 3 | import java.awt.Dimension; |
@@ -6,7 +5,6 @@ import java.awt.Graphics; | |||
6 | import java.awt.Graphics2D; | 5 | import java.awt.Graphics2D; |
7 | import java.awt.Image; | 6 | import java.awt.Image; |
8 | import java.awt.TexturePaint; | 7 | import java.awt.TexturePaint; |
9 | |||
10 | import javax.swing.BorderFactory; | 8 | import javax.swing.BorderFactory; |
11 | import javax.swing.ImageIcon; | 9 | import javax.swing.ImageIcon; |
12 | import javax.swing.JTextField; | 10 | import javax.swing.JTextField; |
@@ -14,49 +12,50 @@ import javax.swing.border.Border; | |||
14 | import javax.swing.plaf.metal.MetalTextFieldUI; | 12 | import javax.swing.plaf.metal.MetalTextFieldUI; |
15 | 13 | ||
16 | 14 | ||
17 | public class MyTextField extends JTextField | 15 | public class MyTextField extends JTextField { |
18 | { | 16 | private Image backgroundLeftImage; |
19 | private Image backgroundLeftImage; | 17 | private Image backgroundRightImage; |
20 | private Image backgroundRightImage; | 18 | private ImageIcon backgroundImageIcon; |
21 | private ImageIcon backgroundImageIcon; | 19 | private TexturePaint paint; |
22 | private TexturePaint paint; | 20 | private Border border; |
23 | private Border border; | 21 | |
24 | 22 | public MyTextField() { | |
25 | public MyTextField() | 23 | backgroundLeftImage = MyContorlUtil.getImage( |
26 | { | 24 | "control/images/textfield_background_left.png"); |
27 | backgroundLeftImage = MyContorlUtil.getImage("control/images/textfield_background_left.png"); | 25 | backgroundRightImage = MyContorlUtil.getImage( |
28 | backgroundRightImage = MyContorlUtil.getImage("control/images/textfield_background_right.png"); | 26 | "control/images/textfield_background_right.png"); |
29 | backgroundImageIcon = MyContorlUtil.getImageIcon("control/images/textfield_background.png"); | 27 | backgroundImageIcon = MyContorlUtil.getImageIcon( |
30 | paint = MyContorlUtil.createTexturePaint("control/images/textfield_background.png"); | 28 | "control/images/textfield_background.png"); |
31 | border = BorderFactory.createEmptyBorder(1, 3, 1, 3); | 29 | paint = MyContorlUtil.createTexturePaint( |
32 | init(); | 30 | "control/images/textfield_background.png"); |
33 | } | 31 | border = BorderFactory.createEmptyBorder(1, 3, 1, 3); |
34 | public MyTextField(String text) | 32 | init(); |
35 | { | 33 | } |
36 | this(); | 34 | |
37 | setText(text); | 35 | public MyTextField(String text) { |
38 | } | 36 | this(); |
39 | 37 | setText(text); | |
40 | private void init() | 38 | } |
41 | { | 39 | |
42 | setBorder(border); | 40 | private void init() { |
43 | setUI(new MetalTextFieldUI() { | 41 | setBorder(border); |
44 | 42 | setUI(new MetalTextFieldUI() { | |
45 | protected void paintBackground(Graphics g) | 43 | |
46 | { | 44 | protected void paintBackground(Graphics g) { |
47 | Graphics2D g2d = (Graphics2D)g; | 45 | Graphics2D g2d = (Graphics2D) g; |
48 | g2d.setPaint(paint); | 46 | g2d.setPaint(paint); |
49 | g2d.fillRect(0, 0, getWidth(), getHeight()); | 47 | g2d.fillRect(0, 0, getWidth(), getHeight()); |
50 | g2d.drawImage(backgroundLeftImage, 0, 0, null); | 48 | g2d.drawImage(backgroundLeftImage, 0, 0, null); |
51 | g2d.drawImage(backgroundRightImage, getWidth() - backgroundRightImage.getWidth(null), 0, null); | 49 | g2d.drawImage(backgroundRightImage, |
52 | } | 50 | getWidth() - backgroundRightImage.getWidth(null), 0, null); |
53 | 51 | } | |
54 | }); | 52 | |
55 | } | 53 | }); |
56 | 54 | } | |
57 | public Dimension getPreferredSize() | 55 | |
58 | { | 56 | public Dimension getPreferredSize() { |
59 | return new Dimension(super.getPreferredSize().width, backgroundImageIcon.getIconHeight()); | 57 | return new Dimension(super.getPreferredSize().width, |
60 | } | 58 | backgroundImageIcon.getIconHeight()); |
61 | 59 | } | |
60 | |||
62 | } | 61 | } |
diff --git a/src/cppcheckplus/control/MyToolbarButton.java b/src/cppcheckplus/control/MyToolbarButton.java index e709296..dff78cd 100644 --- a/src/cppcheckplus/control/MyToolbarButton.java +++ b/src/cppcheckplus/control/MyToolbarButton.java | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | package cppcheckplus.control; | 1 | package cppcheckplus.control; |
3 | 2 | ||
4 | import java.awt.Color; | 3 | import java.awt.Color; |
@@ -8,89 +7,77 @@ import java.awt.Graphics; | |||
8 | import java.awt.Insets; | 7 | import java.awt.Insets; |
9 | import java.awt.event.MouseAdapter; | 8 | import java.awt.event.MouseAdapter; |
10 | import java.awt.event.MouseEvent; | 9 | import java.awt.event.MouseEvent; |
11 | |||
12 | import javax.swing.BorderFactory; | 10 | import javax.swing.BorderFactory; |
13 | import javax.swing.Icon; | 11 | import javax.swing.Icon; |
14 | import javax.swing.JButton; | 12 | import javax.swing.JButton; |
15 | import javax.swing.border.Border; | 13 | import javax.swing.border.Border; |
16 | 14 | ||
17 | public class MyToolbarButton extends JButton | 15 | public class MyToolbarButton extends JButton { |
18 | { | 16 | private int buttonSize; |
19 | private int buttonSize; | 17 | private Color roverBorderColor; |
20 | private Color roverBorderColor; | 18 | private Border roverBorder; |
21 | private Border roverBorder; | 19 | private Border emptyBorder; |
22 | private Border emptyBorder; | ||
23 | 20 | ||
24 | public MyToolbarButton() | 21 | public MyToolbarButton() { |
25 | { | 22 | super(); |
26 | super(); | 23 | buttonSize = 20; |
27 | buttonSize = 20; | 24 | roverBorderColor = MyContorlUtil.BUTTON_ROVER_COLOR; |
28 | roverBorderColor = MyContorlUtil.BUTTON_ROVER_COLOR; | 25 | roverBorder = new Border() { |
29 | roverBorder = new Border() { | ||
30 | 26 | ||
31 | public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) | 27 | public void paintBorder(Component c, Graphics g, int x, int y, |
32 | { | 28 | int width, int height) { |
33 | g.setColor(roverBorderColor); | 29 | g.setColor(roverBorderColor); |
34 | g.drawRect(x, y, width - 1, height - 1); | 30 | g.drawRect(x, y, width - 1, height - 1); |
35 | } | 31 | } |
36 | 32 | ||
37 | public Insets getBorderInsets(Component c) | 33 | public Insets getBorderInsets(Component c) { |
38 | { | 34 | return new Insets(1, 1, 1, 1); |
39 | return new Insets(1, 1, 1, 1); | 35 | } |
40 | } | ||
41 | 36 | ||
42 | public boolean isBorderOpaque() | 37 | public boolean isBorderOpaque() { |
43 | { | 38 | return true; |
44 | return true; | 39 | } |
45 | } | 40 | }; |
46 | }; | 41 | emptyBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1); |
47 | emptyBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1); | 42 | init(); |
48 | init(); | 43 | } |
49 | } | ||
50 | 44 | ||
51 | private void init() | 45 | private void init() { |
52 | { | 46 | setVerticalAlignment(0); |
53 | setVerticalAlignment(0); | 47 | setFont(MyContorlUtil.FONT_12_BOLD); |
54 | setFont(MyContorlUtil.FONT_12_BOLD); | 48 | setOpaque(false); |
55 | setOpaque(false); | 49 | setBorder(emptyBorder); |
56 | setBorder(emptyBorder); | 50 | setContentAreaFilled(false); |
57 | setContentAreaFilled(false); | 51 | setFocusPainted(false); |
58 | setFocusPainted(false); | 52 | addMouseListener(new MouseAdapter() { |
59 | addMouseListener(new MouseAdapter() { | 53 | public void mouseEntered(MouseEvent e) { |
60 | public void mouseEntered(MouseEvent e) | 54 | setBorder(roverBorder); |
61 | { | 55 | } |
62 | setBorder(roverBorder); | ||
63 | } | ||
64 | 56 | ||
65 | public void mouseExited(MouseEvent e) | 57 | public void mouseExited(MouseEvent e) { |
66 | { | 58 | setBorder(emptyBorder); |
67 | setBorder(emptyBorder); | 59 | } |
68 | } | 60 | }); |
69 | }); | 61 | } |
70 | } | ||
71 | 62 | ||
72 | @Override | 63 | @Override |
73 | public void setIcon(Icon icon) | 64 | public void setIcon(Icon icon) { |
74 | { | 65 | super.setIcon(icon); |
75 | super.setIcon(icon); | 66 | if (icon == null) { |
76 | if (icon == null) | 67 | setPressedIcon(null); |
77 | { | 68 | setRolloverIcon(null); |
78 | setPressedIcon(null); | 69 | } else { |
79 | setRolloverIcon(null); | 70 | Icon pressedIcon = MyContorlUtil.createMovedIcon(icon); |
80 | } else | 71 | setPressedIcon(pressedIcon); |
81 | { | 72 | } |
82 | Icon pressedIcon = MyContorlUtil.createMovedIcon(icon); | 73 | } |
83 | setPressedIcon(pressedIcon); | ||
84 | } | ||
85 | } | ||
86 | 74 | ||
87 | 75 | ||
88 | @Override | 76 | @Override |
89 | public Dimension getPreferredSize() | 77 | public Dimension getPreferredSize() { |
90 | { | 78 | int width = super.getPreferredSize().width; |
91 | int width = super.getPreferredSize().width; | 79 | width = Math.max(width, buttonSize); |
92 | width = Math.max(width, buttonSize); | 80 | int height = buttonSize; |
93 | int height = buttonSize; | 81 | return new Dimension(width, height); |
94 | return new Dimension(width, height); | 82 | } |
95 | } | ||
96 | } | 83 | } |
diff --git a/src/cppcheckplus/control/UIFrame.java b/src/cppcheckplus/control/UIFrame.java index a2a04ab..bb15707 100644 --- a/src/cppcheckplus/control/UIFrame.java +++ b/src/cppcheckplus/control/UIFrame.java | |||
@@ -21,16 +21,9 @@ import java.awt.event.ActionEvent; | |||
21 | import java.awt.event.ActionListener; | 21 | import java.awt.event.ActionListener; |
22 | import java.awt.event.MouseAdapter; | 22 | import java.awt.event.MouseAdapter; |
23 | import java.awt.event.MouseEvent; | 23 | import java.awt.event.MouseEvent; |
24 | import java.io.BufferedReader; | ||
25 | import java.io.File; | 24 | import java.io.File; |
26 | import java.io.IOException; | ||
27 | import java.io.InputStream; | ||
28 | import java.io.InputStreamReader; | ||
29 | import java.io.UnsupportedEncodingException; | 25 | import java.io.UnsupportedEncodingException; |
30 | import java.nio.charset.StandardCharsets; | 26 | import java.nio.charset.StandardCharsets; |
31 | import java.nio.file.Files; | ||
32 | import java.nio.file.Path; | ||
33 | import java.nio.file.Paths; | ||
34 | import javax.swing.BorderFactory; | 27 | import javax.swing.BorderFactory; |
35 | import javax.swing.JComponent; | 28 | import javax.swing.JComponent; |
36 | import javax.swing.JFileChooser; | 29 | import javax.swing.JFileChooser; |
@@ -193,7 +186,8 @@ public class UIFrame extends JFrame { | |||
193 | if (src != null && src.length() != 0) { | 186 | if (src != null && src.length() != 0) { |
194 | new Thread() { | 187 | new Thread() { |
195 | public void run() { | 188 | public void run() { |
196 | ToolsRegistry.executeTool("flawfinder", src); | 189 | ToolsRegistry.executeTool("flawfinder", |
190 | src); | ||
197 | viewResult("flawfinder"); | 191 | viewResult("flawfinder"); |
198 | } | 192 | } |
199 | }.start(); | 193 | }.start(); |
diff --git a/src/cppcheckplus/control/XChartletFullScreenListenter.java b/src/cppcheckplus/control/XChartletFullScreenListenter.java index c7eca34..8890357 100644 --- a/src/cppcheckplus/control/XChartletFullScreenListenter.java +++ b/src/cppcheckplus/control/XChartletFullScreenListenter.java | |||
@@ -1,10 +1,8 @@ | |||
1 | |||
2 | package cppcheckplus.control; | 1 | package cppcheckplus.control; |
3 | 2 | ||
4 | import javax.swing.JPanel; | 3 | import javax.swing.JPanel; |
5 | 4 | ||
6 | 5 | ||
7 | public interface XChartletFullScreenListenter | 6 | public interface XChartletFullScreenListenter { |
8 | { | 7 | public void fullScreen(JPanel chartPanellet); |
9 | public void fullScreen(JPanel chartPanellet); | ||
10 | } | 8 | } |