001package com.hfg.html; 002 003import com.hfg.html.attribute.Align; 004import com.hfg.xml.XMLNode; 005 006//------------------------------------------------------------------------------ 007/** 008 * Represents a div (<div>) 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 Div extends HTMLTagWithCoreEvents 034{ 035 036 //########################################################################## 037 // CONSTRUCTORS 038 //########################################################################## 039 040 //-------------------------------------------------------------------------- 041 public Div() 042 { 043 super(HTML.DIV); 044 } 045 046 //-------------------------------------------------------------------------- 047 public Div(String inContent) 048 { 049 this(); 050 addContent(inContent); 051 } 052 053 //-------------------------------------------------------------------------- 054 public Div(HTMLTag inContent) 055 { 056 this(); 057 addSubtag(inContent); 058 } 059 060 //-------------------------------------------------------------------------- 061 public Div(String inContent, Align inAlign) 062 { 063 this(inContent); 064 setAlign(inAlign); 065 } 066 067 //-------------------------------------------------------------------------- 068 public Div(HTMLTag inContent, Align inAlign) 069 { 070 this(inContent); 071 setAlign(inAlign); 072 } 073 074 //-------------------------------------------------------------------------- 075 public Div(XMLNode inXMLNode) 076 { 077 this(); 078 initFromXMLNode(inXMLNode); 079 } 080 081 //########################################################################## 082 // PUBLIC METHODS 083 //########################################################################## 084 085 086 //-------------------------------------------------------------------------- 087 public Center addCenter() 088 { 089 Center center = new Center(); 090 addSubtag(center); 091 092 return center; 093 } 094 095 //-------------------------------------------------------------------------- 096 public Center addCenter(String inContent) 097 { 098 Center center = new Center(inContent); 099 addSubtag(center); 100 101 return center; 102 } 103 104 //-------------------------------------------------------------------------- 105 public Center addCenter(HTMLTag inContent) 106 { 107 Center center = new Center(inContent); 108 addSubtag(center); 109 110 return center; 111 } 112 113 //-------------------------------------------------------------------------- 114 public Div addDiv() 115 { 116 Div div = new Div(); 117 addSubtag(div); 118 119 return div; 120 } 121 122 //-------------------------------------------------------------------------- 123 public Div addDiv(String inContent) 124 { 125 Div div = new Div(inContent); 126 addSubtag(div); 127 128 return div; 129 } 130 131 //-------------------------------------------------------------------------- 132 public Div addDiv(HTMLTag inContent) 133 { 134 Div div = new Div(inContent); 135 addSubtag(div); 136 137 return div; 138 } 139 140 //-------------------------------------------------------------------------- 141 public Form addForm() 142 { 143 Form form = new Form(); 144 addSubtag(form); 145 146 return form; 147 } 148 149 //-------------------------------------------------------------------------- 150 public Form addForm(String inFormName) 151 { 152 Form form = new Form(inFormName); 153 addSubtag(form); 154 155 return form; 156 } 157 158 159 //-------------------------------------------------------------------------- 160 public Img addImage(String inSrc) 161 { 162 Img image = new Img(inSrc); 163 addSubtag(image); 164 165 return image; 166 } 167 168 //-------------------------------------------------------------------------- 169 public Link addLink() 170 { 171 Link link = new Link(); 172 addSubtag(link); 173 174 return link; 175 } 176 177 //-------------------------------------------------------------------------- 178 public Link addLink(CharSequence inURL) 179 { 180 Link link = new Link(inURL); 181 addSubtag(link); 182 183 return link; 184 } 185 186 //-------------------------------------------------------------------------- 187 public Link addLink(CharSequence inURL, String inContent) 188 { 189 Link link = new Link(inURL, inContent); 190 addSubtag(link); 191 192 return link; 193 } 194 195 //-------------------------------------------------------------------------- 196 public Link addLink(CharSequence inURL, HTMLTag inContent) 197 { 198 Link link = new Link(inURL, inContent); 199 addSubtag(link); 200 201 return link; 202 } 203 204 //-------------------------------------------------------------------------- 205 public Nobr addNobr() 206 { 207 Nobr nobr = new Nobr(); 208 addSubtag(nobr); 209 210 return nobr; 211 } 212 213 //-------------------------------------------------------------------------- 214 public Nobr addNobr(String inContent) 215 { 216 Nobr nobr = new Nobr(inContent); 217 addSubtag(nobr); 218 219 return nobr; 220 } 221 222 //-------------------------------------------------------------------------- 223 public Nobr addNobr(HTMLTag inContent) 224 { 225 Nobr nobr = new Nobr(inContent); 226 addSubtag(nobr); 227 228 return nobr; 229 } 230 231 232 //-------------------------------------------------------------------------- 233 public Pre addPre() 234 { 235 Pre pre = new Pre(); 236 addSubtag(pre); 237 238 return pre; 239 } 240 241 //-------------------------------------------------------------------------- 242 public Pre addPre(String inContent) 243 { 244 Pre pre = new Pre(inContent); 245 addSubtag(pre); 246 247 return pre; 248 } 249 250 //-------------------------------------------------------------------------- 251 public Pre addPre(HTMLTag inContent) 252 { 253 Pre pre = new Pre(inContent); 254 addSubtag(pre); 255 256 return pre; 257 } 258 259 //-------------------------------------------------------------------------- 260 public Span addSpan() 261 { 262 Span span = new Span(); 263 addSubtag(span); 264 265 return span; 266 } 267 268 //-------------------------------------------------------------------------- 269 public Span addSpan(String inContent) 270 { 271 Span span = new Span(inContent); 272 addSubtag(span); 273 274 return span; 275 } 276 277 //-------------------------------------------------------------------------- 278 public Span addSpan(HTMLTag inContent) 279 { 280 Span span = new Span(inContent); 281 addSubtag(span); 282 283 return span; 284 } 285 286 287 //-------------------------------------------------------------------------- 288 public Table addTable() 289 { 290 Table table = new Table(); 291 addSubtag(table); 292 293 return table; 294 } 295 296 //-------------------------------------------------------------------------- 297 public Ul addUnorderedList() 298 { 299 Ul ul = new Ul(); 300 addSubtag(ul); 301 302 return ul; 303 } 304 305 306 307 308 //-------------------------------------------------------------------------- 309 public InputButton addButton() 310 { 311 InputButton button = new InputButton(); 312 addSubtag(button); 313 314 return button; 315 } 316 317 //-------------------------------------------------------------------------- 318 public InputButton addButton(String inName, String inValue) 319 { 320 InputButton button = new InputButton(inName, inValue); 321 addSubtag(button); 322 323 return button; 324 } 325 326 //-------------------------------------------------------------------------- 327 public InputCheckbox addCheckbox(String inName, String inValue) 328 { 329 InputCheckbox checkbox = new InputCheckbox(inName, inValue); 330 addSubtag(checkbox); 331 332 return checkbox; 333 } 334 335 //-------------------------------------------------------------------------- 336 public InputCheckbox addCheckbox(String inName, String inValue, boolean checked) 337 { 338 InputCheckbox checkbox = new InputCheckbox(inName, inValue, checked); 339 addSubtag(checkbox); 340 341 return checkbox; 342 } 343 344 345 //-------------------------------------------------------------------------- 346 public InputFile addFileInput() 347 { 348 InputFile subtag = new InputFile(); 349 addSubtag(subtag); 350 351 return subtag; 352 } 353 354 //-------------------------------------------------------------------------- 355 public InputFile addFileInput(String inName) 356 { 357 InputFile subtag = new InputFile(inName); 358 addSubtag(subtag); 359 360 return subtag; 361 } 362 363 //-------------------------------------------------------------------------- 364 public InputFile addFileInput(String inName, String inValue) 365 { 366 InputFile subtag = new InputFile(inName, inValue); 367 addSubtag(subtag); 368 369 return subtag; 370 } 371 372 373 //-------------------------------------------------------------------------- 374 public Label addLabel() 375 { 376 Label label = new Label(); 377 addSubtag(label); 378 379 return label; 380 } 381 382 //-------------------------------------------------------------------------- 383 public Label addLabel(String inValue) 384 { 385 Label label = new Label(inValue); 386 addSubtag(label); 387 388 return label; 389 } 390 391 392 //-------------------------------------------------------------------------- 393 public InputPassword addPasswordInput() 394 { 395 InputPassword password = new InputPassword(); 396 addSubtag(password); 397 398 return password; 399 } 400 401 //-------------------------------------------------------------------------- 402 public InputPassword addPasswordInput(String inName, String inValue) 403 { 404 InputPassword password = new InputPassword(inName, inValue); 405 addSubtag(password); 406 407 return password; 408 } 409 410 //-------------------------------------------------------------------------- 411 public InputRadio addRadio(String inName, String inValue) 412 { 413 InputRadio radio = new InputRadio(inName, inValue); 414 addSubtag(radio); 415 416 return radio; 417 } 418 419 //-------------------------------------------------------------------------- 420 public InputRadio addRadio(String inName, String inValue, boolean checked) 421 { 422 InputRadio radio = new InputRadio(inName, inValue, checked); 423 addSubtag(radio); 424 425 return radio; 426 } 427 428 //-------------------------------------------------------------------------- 429 public InputReset addReset() 430 { 431 InputReset reset = new InputReset(); 432 addSubtag(reset); 433 434 return reset; 435 } 436 437 //-------------------------------------------------------------------------- 438 public Select addSelect(String inName) 439 { 440 Select select = new Select(inName); 441 addSubtag(select); 442 443 return select; 444 } 445 446 //-------------------------------------------------------------------------- 447 public InputSubmit addSubmit() 448 { 449 InputSubmit submit = new InputSubmit(); 450 addSubtag(submit); 451 452 return submit; 453 } 454 455 //-------------------------------------------------------------------------- 456 public InputSubmit addSubmit(String inName, String inValue) 457 { 458 InputSubmit submit = new InputSubmit(inName, inValue); 459 addSubtag(submit); 460 461 return submit; 462 } 463 464 465 //-------------------------------------------------------------------------- 466 public Script addScript() 467 { 468 Script script = new Script(); 469 addSubtag(script); 470 471 return script; 472 } 473 474 //-------------------------------------------------------------------------- 475 public Textarea addTextarea(String inName, String inValue) 476 { 477 Textarea textarea = new Textarea(inName, inValue); 478 addSubtag(textarea); 479 480 return textarea; 481 } 482 483 //-------------------------------------------------------------------------- 484 public Textarea addTextarea(String inName, String inValue, int inRows, int inCols) 485 { 486 Textarea textarea = new Textarea(inName, inValue, inRows, inCols); 487 addSubtag(textarea); 488 489 return textarea; 490 } 491 492 493 //-------------------------------------------------------------------------- 494 public InputText addTextInput() 495 { 496 InputText text = new InputText(); 497 addSubtag(text); 498 499 return text; 500 } 501 502 //-------------------------------------------------------------------------- 503 public InputText addTextInput(String inName, String inValue) 504 { 505 InputText text = new InputText(inName, inValue); 506 addSubtag(text); 507 508 return text; 509 } 510 511 512 //-------------------------------------------------------------------------- 513 public Div setAlign(Align inValue) 514 { 515 setAttribute(inValue.getHTMLAttributeName(), inValue.toString()); 516 517 return this; 518 } 519 520 //-------------------------------------------------------------------------- 521 public Div setTitle(String inValue) 522 { 523 setAttribute(HTML.TITLE, inValue); 524 return this; 525 } 526 527 //-------------------------------------------------------------------------- 528 public String getTitle() 529 { 530 return getAttributeValue(HTML.TITLE); 531 } 532 533 //-------------------------------------------------------------------------- 534 public Div br() 535 { 536 HTMLUtil.br(this); 537 return this; 538 } 539 540 //-------------------------------------------------------------------------- 541 public Div br(int inNumber) 542 { 543 HTMLUtil.br(this, inNumber); 544 return this; 545 } 546 547 //-------------------------------------------------------------------------- 548 public void nbsp(int inNumber) 549 { 550 HTMLUtil.nbsp(this, inNumber); 551 } 552 553 //-------------------------------------------------------------------------- 554 public Hr hr() 555 { 556 return HTMLUtil.hr(this); 557 } 558 559 //-------------------------------------------------------------------------- 560 public Hr hr(String inWidth) 561 { 562 return HTMLUtil.hr(this, inWidth); 563 } 564 565 // Overrides for HTMLTag setters to allow method chaining. 566 567 //-------------------------------------------------------------------------- 568 @Override 569 public Div addClass(String inValue) 570 { 571 return (Div) super.addClass(inValue); 572 } 573 574 //-------------------------------------------------------------------------- 575 @Override 576 public Div setClass(String inValue) 577 { 578 return (Div) super.setClass(inValue); 579 } 580 581 //-------------------------------------------------------------------------- 582 @Override 583 public Div setId(String inValue) 584 { 585 return (Div) super.setId(inValue); 586 } 587 588 //-------------------------------------------------------------------------- 589 @Override 590 public Div setStyle(CharSequence inValue) 591 { 592 return (Div) super.setStyle(inValue); 593 } 594 595 //-------------------------------------------------------------------------- 596 @Override 597 public Div addStyle(String inValue) 598 { 599 return (Div) super.addStyle(inValue); 600 } 601 602 603 //-------------------------------------------------------------------------- 604 @Override 605 public Div setDraggable(boolean inValue) 606 { 607 return (Div) super.setDraggable(inValue); 608 } 609 610 // Overrides for HTMLTagWithCoreEvents setters to allow method chaining. 611 612 //-------------------------------------------------------------------------- 613 @Override 614 public Div setOnClick(String inValue) 615 { 616 return (Div) super.setOnClick(inValue); 617 } 618 619 //-------------------------------------------------------------------------- 620 @Override 621 public Div setOnDblClick(String inValue) 622 { 623 return (Div) super.setOnDblClick(inValue); 624 } 625 626 //-------------------------------------------------------------------------- 627 @Override 628 public Div setOnMouseDown(String inValue) 629 { 630 return (Div) super.setOnMouseDown(inValue); 631 } 632 633 //-------------------------------------------------------------------------- 634 @Override 635 public Div setOnMouseMove(String inValue) 636 { 637 return (Div) super.setOnMouseMove(inValue); 638 } 639 640 //-------------------------------------------------------------------------- 641 @Override 642 public Div setOnMouseOut(String inValue) 643 { 644 return (Div) super.setOnMouseOut(inValue); 645 } 646 647 //-------------------------------------------------------------------------- 648 @Override 649 public Div setOnMouseOver(String inValue) 650 { 651 return (Div) super.setOnMouseOver(inValue); 652 } 653 654 //-------------------------------------------------------------------------- 655 @Override 656 public Div setOnMouseUp(String inValue) 657 { 658 return (Div) super.setOnMouseUp(inValue); 659 } 660 661 //-------------------------------------------------------------------------- 662 @Override 663 public Div setOnKeyDown(String inValue) 664 { 665 return (Div) super.setOnKeyDown(inValue); 666 } 667 668 //-------------------------------------------------------------------------- 669 @Override 670 public Div setOnKeyPress(String inValue) 671 { 672 return (Div) super.setOnKeyPress(inValue); 673 } 674 675 //-------------------------------------------------------------------------- 676 @Override 677 public Div setOnKeyUp(String inValue) 678 { 679 return (Div) super.setOnKeyUp(inValue); 680 } 681 682}