1 package org.catacomb.druid.gui.edit;
2
3
4 import java.awt.Color;
5 import java.util.ArrayList;
6
7 import org.catacomb.druid.event.LabelActor;
8 import org.catacomb.druid.swing.DBaseButton;
9 import org.catacomb.druid.swing.DButton;
10 import org.catacomb.icon.DImageIcon;
11 import org.catacomb.icon.IconLoader;
12 import org.catacomb.interlish.structure.Button;
13 import org.catacomb.interlish.structure.Suggestible;
14
15
16 public class DruButton extends DruGCPanel implements LabelActor, Button, Suggestible {
17
18 static final long serialVersionUID = 1001;
19
20 String label;
21
22 ArrayList<Effect> effects;
23
24 DBaseButton button;
25
26
27
28
29 public DruButton(String lab) {
30 this(lab, null);
31 }
32
33
34
35
36 public DruButton(String lab, String ac) {
37 super();
38 label = lab;
39 button = makeButton(label);
40 setActionCommand(ac);
41
42 setActionMethod(ac);
43
44 addSingleDComponent(button);
45 button.setLabelActor(this);
46
47 }
48
49
50 public void suggest() {
51
52
53
54 button.suggest();
55 }
56
57
58 public void deSuggest() {
59 button.deSuggest();
60 }
61
62
63 public String toString() {
64 return ("DruButton " + label);
65 }
66
67
68 public DBaseButton getButton() {
69 return button;
70 }
71
72
73
74
75 public void setRolloverPolicy(int inorm, int ihover) {
76 button.setRolloverPolicy(inorm, ihover);
77 }
78
79
80
81 public DBaseButton makeButton(String sl) {
82 return new DButton(sl);
83 }
84
85
86 public void setBg(Color c) {
87 button.setBg(c);
88 }
89
90
91 public void setFg(Color c) {
92 button.setFg(c);
93 }
94
95
96
97 public String getLabel() {
98 return button.getText();
99 }
100
101
102 public void disable() {
103 able(false);
104 }
105
106 public void enable() {
107 able(true);
108 }
109
110 public void able(boolean b) {
111 button.setEnabled(b);
112 }
113
114
115
116 public void setBoldFont() {
117 button.setBoldFont();
118 }
119
120
121 public void setImage(String iconName) {
122 DImageIcon icon = IconLoader.createImageIcon(iconName);
123 button.setIcon(icon);
124 }
125
126
127 public void setIconSource(String imgsrc) {
128 button.setIconSource(imgsrc);
129 }
130
131
132 public void setLabelText(String s) {
133 button.setLabelText(s);
134 }
135
136
137 public void postApply() {
138 button.setMouseActor(this);
139 }
140
141
142
143
144 public void setActionCommand(String s) {
145 button.setActionCommand(s);
146 }
147
148
149 public void applyEffects(boolean b) {
150 if (effects != null) {
151 for (Effect eff : effects) {
152 eff.apply(b);
153 }
154 }
155
156
157 }
158
159
160 public void labelAction(String s, boolean b) {
161 exportInfo();
162
163 applyEffects(true);
164
165 action();
166
167 }
168
169
170 public void addEffect(Effect eff) {
171 if (effects == null) {
172 effects = new ArrayList<Effect>();
173 }
174 effects.add(eff);
175 }
176
177 public void setEffects(ArrayList<Effect> arl) {
178 effects = arl;
179 }
180
181
182
183 public void setPadding(int padding) {
184 button.setPadding(padding);
185 }
186
187
188 public void setPadding(int pl, int pr, int pt, int pb) {
189 button.setPadding(pl, pr, pt, pb);
190 }
191
192 }