diff options
Diffstat (limited to 'src/cppcheckplus/outlookpanel/MyOutlookHeader.java')
-rw-r--r-- | src/cppcheckplus/outlookpanel/MyOutlookHeader.java | 179 |
1 files changed, 84 insertions, 95 deletions
diff --git a/src/cppcheckplus/outlookpanel/MyOutlookHeader.java b/src/cppcheckplus/outlookpanel/MyOutlookHeader.java index c7ba589..9cd4026 100644 --- a/src/cppcheckplus/outlookpanel/MyOutlookHeader.java +++ b/src/cppcheckplus/outlookpanel/MyOutlookHeader.java | |||
@@ -1,9 +1,11 @@ | |||
1 | |||
2 | package cppcheckplus.outlookpanel; | 1 | package cppcheckplus.outlookpanel; |
3 | 2 | ||
3 | import cppcheckplus.control.MyContorlUtil; | ||
4 | import cppcheckplus.control.MyHeader; | ||
5 | import cppcheckplus.control.MyListSplitListener; | ||
6 | import cppcheckplus.toolbar.MyToolBarButton; | ||
4 | import java.awt.FlowLayout; | 7 | import java.awt.FlowLayout; |
5 | import java.awt.LayoutManager; | 8 | import java.awt.LayoutManager; |
6 | import java.awt.event.ActionEvent; | ||
7 | import java.awt.event.ActionListener; | 9 | import java.awt.event.ActionListener; |
8 | import javax.swing.BorderFactory; | 10 | import javax.swing.BorderFactory; |
9 | import javax.swing.Icon; | 11 | import javax.swing.Icon; |
@@ -13,97 +15,84 @@ import javax.swing.JLabel; | |||
13 | import javax.swing.JPanel; | 15 | import javax.swing.JPanel; |
14 | import javax.swing.border.Border; | 16 | import javax.swing.border.Border; |
15 | 17 | ||
16 | import cppcheckplus.control.MyContorlUtil; | 18 | public class MyOutlookHeader extends MyHeader { |
17 | import cppcheckplus.control.MyHeader; | 19 | private LayoutManager toolbarLayout; |
18 | import cppcheckplus.control.MyListSplitListener; | 20 | private JPanel toolbar; |
19 | import cppcheckplus.toolbar.MyToolBarButton; | 21 | private ImageIcon separatorIcon; |
20 | 22 | ||
21 | public class MyOutlookHeader extends MyHeader | 23 | public MyOutlookHeader(ActionListener listener) { |
22 | { | 24 | toolbarLayout = new FlowLayout(FlowLayout.LEFT, 2, 1); |
23 | private LayoutManager toolbarLayout; | 25 | toolbar = new JPanel(toolbarLayout); |
24 | private JPanel toolbar; | 26 | separatorIcon = |
25 | private ImageIcon separatorIcon; | 27 | MyContorlUtil.getImageIcon("control/images/toolbar_separator.png"); |
26 | 28 | init(); | |
27 | public MyOutlookHeader(ActionListener listener) | 29 | //加载工具栏 |
28 | { | 30 | MyContorlUtil.loadOutlookToolBar("cppcheckplus/control/toolbar.xml", |
29 | toolbarLayout = new FlowLayout(FlowLayout.LEFT,2,1); | 31 | this, listener); |
30 | toolbar = new JPanel(toolbarLayout); | 32 | } |
31 | separatorIcon = MyContorlUtil.getImageIcon("control/images/toolbar_separator.png"); | 33 | |
32 | init(); | 34 | private void init() { |
33 | //加载工具栏 | 35 | toolbar.setOpaque(false); |
34 | MyContorlUtil.loadOutlookToolBar("cppcheckplus/control/toolbar.xml", this,listener); | 36 | toolbar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); |
35 | } | 37 | add(toolbar, "Center"); |
36 | 38 | } | |
37 | private void init() | 39 | |
38 | { | 40 | //在Header上添加工具按钮 |
39 | toolbar.setOpaque(false); | 41 | public MyToolBarButton addButton(Icon icon, String tooltip, |
40 | toolbar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); | 42 | ActionListener action, String command) { |
41 | add(toolbar, "Center"); | 43 | MyToolBarButton button = new MyToolBarButton(); |
42 | } | 44 | button.setIcon(icon); |
43 | //在Header上添加工具按钮 | 45 | button.setToolTipText(tooltip); |
44 | public MyToolBarButton addButton(Icon icon, String tooltip, ActionListener action, String command) | 46 | if (action != null) { |
45 | { | 47 | button.addActionListener(action); |
46 | MyToolBarButton button = new MyToolBarButton(); | 48 | } |
47 | button.setIcon(icon); | 49 | button.setActionCommand(command); |
48 | button.setToolTipText(tooltip); | 50 | toolbar.add(button); |
49 | if (action != null) | 51 | return button; |
50 | button.addActionListener(action); | 52 | } |
51 | button.setActionCommand(command); | 53 | |
52 | toolbar.add(button); | 54 | public void addSeparator() { |
53 | return button; | 55 | toolbar.add(new JLabel(separatorIcon)); |
54 | } | 56 | } |
55 | 57 | ||
56 | public void addSeparator() | 58 | protected Object getResizeHandlerLayoutConstraint() { |
57 | { | 59 | return "East"; |
58 | toolbar.add(new JLabel(separatorIcon)); | 60 | } |
59 | } | 61 | |
60 | 62 | protected Object getShrinkHandlerLayoutConstraint() { | |
61 | protected Object getResizeHandlerLayoutConstraint() | 63 | return "West"; |
62 | { | 64 | } |
63 | return "East"; | 65 | |
64 | } | 66 | protected MyListSplitListener createSplitListener() { |
65 | 67 | return new MyOutlookSplitListener(this); | |
66 | protected Object getShrinkHandlerLayoutConstraint() | 68 | } |
67 | { | 69 | |
68 | return "West"; | 70 | protected Border createBorder() { |
69 | } | 71 | return BorderFactory.createEmptyBorder(4, 0, 0, 7); |
70 | 72 | } | |
71 | protected MyListSplitListener createSplitListener() | 73 | |
72 | { | 74 | protected ImageIcon getShrinkIcon(boolean shrinked) { |
73 | return new MyOutlookSplitListener(this); | 75 | if (shrinked) { |
74 | } | 76 | return RIGHT_ARROW_ICON; |
75 | 77 | } else { | |
76 | protected Border createBorder() | 78 | return LEFT_ARROW_ICON; |
77 | { | 79 | } |
78 | return BorderFactory.createEmptyBorder(4, 0, 0, 7); | 80 | } |
79 | } | 81 | |
80 | 82 | protected JComponent getCenterComponent() { | |
81 | protected ImageIcon getShrinkIcon(boolean shrinked) | 83 | return null; |
82 | { | 84 | } |
83 | if (shrinked) | 85 | |
84 | return RIGHT_ARROW_ICON; | 86 | public void setShrink(boolean shrinked) { |
85 | else | 87 | super.setShrink(shrinked); |
86 | return LEFT_ARROW_ICON; | 88 | toolbar.setVisible(!shrinked); |
87 | } | 89 | } |
88 | 90 | ||
89 | protected JComponent getCenterComponent() | 91 | protected int getShrinkedWidth() { |
90 | { | 92 | return 37; |
91 | return null; | 93 | } |
92 | } | 94 | |
93 | 95 | public JPanel getToolBar() { | |
94 | public void setShrink(boolean shrinked) | 96 | return toolbar; |
95 | { | 97 | } |
96 | super.setShrink(shrinked); | ||
97 | toolbar.setVisible(!shrinked); | ||
98 | } | ||
99 | |||
100 | protected int getShrinkedWidth() | ||
101 | { | ||
102 | return 37; | ||
103 | } | ||
104 | |||
105 | public JPanel getToolBar() | ||
106 | { | ||
107 | return toolbar; | ||
108 | } | ||
109 | } | 98 | } |