diff options
Diffstat (limited to 'src/cppcheckplus/toolbar/MyToolBar.java')
-rw-r--r-- | src/cppcheckplus/toolbar/MyToolBar.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/cppcheckplus/toolbar/MyToolBar.java b/src/cppcheckplus/toolbar/MyToolBar.java new file mode 100644 index 0000000..e0473a6 --- /dev/null +++ b/src/cppcheckplus/toolbar/MyToolBar.java | |||
@@ -0,0 +1,60 @@ | |||
1 | |||
2 | package cppcheckplus.toolbar; | ||
3 | |||
4 | import java.awt.Dimension; | ||
5 | import java.awt.FlowLayout; | ||
6 | import java.awt.Graphics; | ||
7 | import java.awt.Graphics2D; | ||
8 | import java.awt.TexturePaint; | ||
9 | import javax.swing.BorderFactory; | ||
10 | import javax.swing.Icon; | ||
11 | import javax.swing.JPanel; | ||
12 | |||
13 | import cppcheckplus.control.MyContorlUtil; | ||
14 | |||
15 | |||
16 | public class MyToolBar extends JPanel | ||
17 | { | ||
18 | private String backgroundImageURL; | ||
19 | private int preferredHeight; | ||
20 | private TexturePaint paint; | ||
21 | private int buttonGap; | ||
22 | |||
23 | public MyToolBar() | ||
24 | { | ||
25 | preferredHeight = MyContorlUtil.getImageIcon("control/images/toolbar_background.png").getIconHeight(); | ||
26 | paint = MyContorlUtil.createTexturePaint("control/images/toolbar_background.png"); | ||
27 | buttonGap = 2; | ||
28 | init(); | ||
29 | } | ||
30 | |||
31 | private void init() | ||
32 | { | ||
33 | setLayout(new FlowLayout(3, buttonGap, 0)); | ||
34 | setBorder(BorderFactory.createEmptyBorder(2, 5, 0, 5)); | ||
35 | } | ||
36 | public void addButton(Icon icon, String tooltip,String actionCommand,boolean rover) | ||
37 | { | ||
38 | MyToolBarButton barButton; | ||
39 | if (rover) | ||
40 | barButton = new MyToolBarRoverButton(); | ||
41 | else | ||
42 | barButton = new MyToolBarButton(); | ||
43 | barButton.setIcon(icon); | ||
44 | barButton.setToolTipText(tooltip); | ||
45 | barButton.setActionCommand(actionCommand); | ||
46 | add(barButton); | ||
47 | } | ||
48 | protected void paintComponent(Graphics g) | ||
49 | { | ||
50 | super.paintComponent(g); | ||
51 | Graphics2D g2d = (Graphics2D)g; | ||
52 | g2d.setPaint(paint); | ||
53 | g2d.fillRect(0, 0, getWidth(), getHeight()); | ||
54 | } | ||
55 | |||
56 | public Dimension getPreferredSize() | ||
57 | { | ||
58 | return new Dimension(super.getPreferredSize().width, preferredHeight); | ||
59 | } | ||
60 | } | ||