001package com.hfg.html;
002
003
004import com.hfg.xml.XMLNode;
005
006//------------------------------------------------------------------------------
007/**
008 * Represents a label (<label>) tag.
009 *
010 * @author J. Alex Taylor, hairyfatguy.com
011 */
012//------------------------------------------------------------------------------
013// com.hfg XML/HTML Coding Library
014//
015// This library is free software; you can redistribute it and/or
016// modify it under the terms of the GNU Lesser General Public
017// License as published by the Free Software Foundation; either
018// version 2.1 of the License, or (at your option) any later version.
019//
020// This library is distributed in the hope that it will be useful,
021// but WITHOUT ANY WARRANTY; without even the implied warranty of
022// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
023// Lesser General Public License for more details.
024//
025// You should have received a copy of the GNU Lesser General Public
026// License along with this library; if not, write to the Free Software
027// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
028//
029// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
030// jataylor@hairyfatguy.com
031//------------------------------------------------------------------------------
032
033public class Label extends HTMLTagWithCoreEvents
034{
035
036   //##########################################################################
037   // CONSTRUCTORS
038   //##########################################################################
039
040   //--------------------------------------------------------------------------
041   public Label()
042   {
043      super(HTML.LABEL);
044   }
045
046   //--------------------------------------------------------------------------
047   public Label(String inContent)
048   {
049      this();
050      addContent(inContent);
051   }
052
053   //--------------------------------------------------------------------------
054   public Label(HTMLTag inContent)
055   {
056      this();
057      addSubtag(inContent);
058   }
059
060   //--------------------------------------------------------------------------
061   public Label(XMLNode inXMLNode)
062   {
063      this();
064      initFromXMLNode(inXMLNode);
065   }
066
067   //##########################################################################
068   // PUBLIC METHODS
069   //##########################################################################
070
071
072   //--------------------------------------------------------------------------
073   public InputCheckbox addCheckbox(String inName)
074   {
075      return addCheckbox(inName, "true");
076   }
077
078   //--------------------------------------------------------------------------
079   public InputCheckbox addCheckbox(String inName, String inValue)
080   {
081      return addCheckbox(inName, inValue, false);
082   }
083
084   //--------------------------------------------------------------------------
085   public InputCheckbox addCheckbox(String inName, String inValue, boolean inChecked)
086   {
087      InputCheckbox chkbox = new InputCheckbox(inName, inValue, inChecked);
088      addSubtag(chkbox);
089
090      return chkbox;
091   }
092
093
094   //--------------------------------------------------------------------------
095   public InputRadio addRadioBtn(String inName, String inValue)
096   {
097      InputRadio radio = new InputRadio(inName, inValue);
098      addSubtag(radio);
099
100      return radio;
101   }
102
103   //--------------------------------------------------------------------------
104   public InputRadio addRadioBtn(String inName, String inValue, boolean checked)
105   {
106      InputRadio radio = new InputRadio(inName, inValue, checked);
107      addSubtag(radio);
108
109      return radio;
110   }
111
112
113
114   //--------------------------------------------------------------------------
115   public Img addImage(String inSrc)
116   {
117      Img image = new Img(inSrc);
118      addSubtag(image);
119
120      return image;
121   }
122
123   //--------------------------------------------------------------------------
124   public Link addLink()
125   {
126      Link link = new Link();
127      addSubtag(link);
128
129      return link;
130   }
131
132   //--------------------------------------------------------------------------
133   public Link addLink(CharSequence inURL)
134   {
135      Link link = new Link(inURL);
136      addSubtag(link);
137
138      return link;
139   }
140
141   //--------------------------------------------------------------------------
142   public Link addLink(CharSequence inURL, String inContent)
143   {
144      Link link = new Link(inURL, inContent);
145      addSubtag(link);
146
147      return link;
148   }
149
150   //--------------------------------------------------------------------------
151   public Link addLink(CharSequence inURL, HTMLTag inContent)
152   {
153      Link link = new Link(inURL, inContent);
154      addSubtag(link);
155
156      return link;
157   }
158
159   //--------------------------------------------------------------------------
160   public Nobr addNobr()
161   {
162      Nobr nobr = new Nobr();
163      addSubtag(nobr);
164
165      return nobr;
166   }
167
168   //--------------------------------------------------------------------------
169   public Nobr addNobr(String inContent)
170   {
171      Nobr nobr = new Nobr(inContent);
172      addSubtag(nobr);
173
174      return nobr;
175   }
176
177   //--------------------------------------------------------------------------
178   public Nobr addNobr(HTMLTag inContent)
179   {
180      Nobr nobr = new Nobr(inContent);
181      addSubtag(nobr);
182
183      return nobr;
184   }
185
186
187   //--------------------------------------------------------------------------
188   public Span addSpan()
189   {
190      Span span = new Span();
191      addSubtag(span);
192
193      return span;
194   }
195
196   //--------------------------------------------------------------------------
197   public Span addSpan(String inContent)
198   {
199      Span span = new Span(inContent);
200      addSubtag(span);
201
202      return span;
203   }
204
205   //--------------------------------------------------------------------------
206   @Override
207   public Span appendToOnMouseOut(String inValue)
208   {
209      return (Span) super.appendToOnMouseOut(inValue);
210   }
211
212   //--------------------------------------------------------------------------
213   @Override
214   public Span appendToOnMouseOver(String inValue)
215   {
216      return (Span) super.appendToOnMouseOver(inValue);
217   }
218
219   //--------------------------------------------------------------------------
220   @Override
221   public Span appendToOnClick(String inValue)
222   {
223      return (Span) super.appendToOnClick(inValue);
224   }
225
226
227   //--------------------------------------------------------------------------
228   public Label setFor(String inValue)
229   {
230      setAttribute(HTML.FOR, inValue);
231      return this;
232   }
233
234   //--------------------------------------------------------------------------
235   public String getFor()
236   {
237      return getAttributeValue(HTML.FOR);
238   }
239
240
241   //--------------------------------------------------------------------------
242   public Label setTitle(String inValue)
243   {
244      setAttribute(HTML.TITLE, inValue);
245      return this;
246   }
247
248   //--------------------------------------------------------------------------
249   public String getTitle()
250   {
251      return getAttributeValue(HTML.TITLE);
252   }
253
254
255   //--------------------------------------------------------------------------
256   public Label br()
257   {
258      HTMLUtil.br(this);
259      return this;
260   }
261
262   //--------------------------------------------------------------------------
263   public Label br(int inNumber)
264   {
265      HTMLUtil.br(this, inNumber);
266      return this;
267   }
268
269   //--------------------------------------------------------------------------
270   public Label nbsp(int inNumber)
271   {
272      HTMLUtil.nbsp(this, inNumber);
273      return this;
274   }
275
276   // Overrides for HTMLTag setters to allow method chaining.
277
278   //--------------------------------------------------------------------------
279   @Override
280   public Label addClass(String inValue)
281   {
282      return (Label) super.addClass(inValue);
283   }
284
285   //--------------------------------------------------------------------------
286   @Override
287   public Label setClass(String inValue)
288   {
289      return (Label) super.setClass(inValue);
290   }
291
292   //--------------------------------------------------------------------------
293   @Override
294   public Label setId(String inValue)
295   {
296      return (Label) super.setId(inValue);
297   }
298
299   //--------------------------------------------------------------------------
300   @Override
301   public Label setStyle(CharSequence inValue)
302   {
303      return (Label) super.setStyle(inValue);
304   }
305
306   //--------------------------------------------------------------------------
307   @Override
308   public Label addStyle(String inValue)
309   {
310      return (Label) super.addStyle(inValue);
311   }
312
313
314   //--------------------------------------------------------------------------
315   @Override
316   public Label setDraggable(boolean inValue)
317   {
318      return (Label) super.setDraggable(inValue);
319   }
320
321   // Overrides for HTMLTagWithCoreEvents setters to allow method chaining.
322
323   //--------------------------------------------------------------------------
324   @Override
325   public Label setOnClick(String inValue)
326   {
327      return (Label) super.setOnClick(inValue);
328   }
329
330   //--------------------------------------------------------------------------
331   @Override
332   public Label setOnDblClick(String inValue)
333   {
334      return (Label) super.setOnDblClick(inValue);
335   }
336
337   //--------------------------------------------------------------------------
338   @Override
339   public Label setOnMouseDown(String inValue)
340   {
341      return (Label) super.setOnMouseDown(inValue);
342   }
343
344   //--------------------------------------------------------------------------
345   @Override
346   public Label setOnMouseMove(String inValue)
347   {
348      return (Label) super.setOnMouseMove(inValue);
349   }
350
351   //--------------------------------------------------------------------------
352   @Override
353   public Label setOnMouseOut(String inValue)
354   {
355      return (Label) super.setOnMouseOut(inValue);
356   }
357
358   //--------------------------------------------------------------------------
359   @Override
360   public Label setOnMouseOver(String inValue)
361   {
362      return (Label) super.setOnMouseOver(inValue);
363   }
364
365   //--------------------------------------------------------------------------
366   @Override
367   public Label setOnMouseUp(String inValue)
368   {
369      return (Label) super.setOnMouseUp(inValue);
370   }
371
372   //--------------------------------------------------------------------------
373   @Override
374   public Label setOnKeyDown(String inValue)
375   {
376      return (Label) super.setOnKeyDown(inValue);
377   }
378
379   //--------------------------------------------------------------------------
380   @Override
381   public Label setOnKeyPress(String inValue)
382   {
383      return (Label) super.setOnKeyPress(inValue);
384   }
385
386   //--------------------------------------------------------------------------
387   @Override
388   public Label setOnKeyUp(String inValue)
389   {
390      return (Label) super.setOnKeyUp(inValue);
391   }
392}