Salome HOME
Update copyrights 2014.
[tools/siman.git] / Workspace / Siman / src / org / splat / wapp / ToolBar.java
1 package org.splat.wapp;
2
3 import java.util.List;
4
5
6 public class ToolBar extends ContextualMenu {
7
8 //  ==============================================================================================================================
9 //  Constructor
10 //  ==============================================================================================================================
11
12     public ToolBar (int size) {
13 //  -------------------------
14       _width  = 0;
15       _height = size;
16     }
17
18 //  ==============================================================================================================================
19 //  Member functions
20 //  ==============================================================================================================================
21
22     public void addTool (String name, String icon, String command) {
23 //  --------------------------------------------------------------
24       addTool(name, new ToolButton(icon).action(command) );
25     }
26
27     public void addTool (String name, String icon, String command, String arg) {
28 //  --------------------------------------------------------------------------
29       addTool(name, new ToolButton(icon).action(command).argument(arg) );
30     }
31
32     public void addTool (String name, String icon, String tip, String command, String arg) {
33 //  --------------------------------------------------------------------------------------
34       addTool(name, new ToolButton(icon).tooltip(tip).action(command).argument(arg) );
35     }
36
37     public void addTool (String name, ToolButton item) {
38 //  --------------------------------------------------
39       item._width  = this._height;
40       item._height = this._height;
41       this._width += item._width;
42       if (!this.isEmpty()) _width += 6;        // Gap between icons
43       super.addItem(name, item);
44     }
45
46     public void addSeparator () {
47 //  ---------------------------
48       _width += 6;
49       super.addItem("", new ToolButton());
50     }
51
52         @SuppressWarnings({"rawtypes","unchecked"})
53         public List<ToolButton> asList () {
54 //  ---------------------------------
55       return (List)_items;
56     }
57
58     public ToolButton item (String name) {
59 //  ------------------------------------
60       return (ToolButton)_items.get(_indices.get(name));
61     }
62 }