Uncommented beaudio code
[pwlib.git] / src / ptclib / html.cxx
blob989fff9239847f29bacb49645573bce8a90df62f
1 /*
2 * html.cxx
4 * HTML classes.
6 * Portable Windows Library
8 * Copyright (c) 1993-2002 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Contributor(s): ______________________________________.
26 * $Log$
27 * Revision 1.19 2002/11/06 22:47:24 robertj
28 * Fixed header comment (copyright etc)
30 * Revision 1.18 2001/02/13 04:39:08 robertj
31 * Fixed problem with operator= in container classes. Some containers will
32 * break unless the copy is virtual (eg PStringStream's buffer pointers) so
33 * needed to add a new AssignContents() function to all containers.
35 * Revision 1.17 1998/11/30 04:51:51 robertj
36 * New directory structure
38 * Revision 1.16 1998/09/23 06:22:04 robertj
39 * Added open source copyright license.
41 * Revision 1.15 1998/01/26 02:49:15 robertj
42 * GNU support.
44 * Revision 1.14 1997/06/16 13:18:03 robertj
45 * Set Is() function to be const as it should have been.
47 * Revision 1.13 1996/08/19 13:40:31 robertj
48 * Fixed incorrect formatting of HTML tags (cosmetic only).
50 * Revision 1.12 1996/06/28 13:08:55 robertj
51 * Changed PHTML class so can create html fragments.
52 * Fixed nesting problem in tables.
54 * Revision 1.11 1996/06/01 04:18:45 robertj
55 * Fixed bug in RadioButton, having 2 VALUE fields
57 * Revision 1.10 1996/04/29 12:21:22 robertj
58 * Fixed spelling error in assert.
59 * Fixed check box HTML, should always have a value.
60 * Added display of value of unclosed HTML element.
62 * Revision 1.9 1996/04/14 02:52:04 robertj
63 * Added hidden fields to HTML.
65 * Revision 1.8 1996/03/31 09:03:07 robertj
66 * Changed HTML token so doesn't have trailing CRLF.
68 * Revision 1.7 1996/03/16 04:54:06 robertj
69 * Made the assert for unclosed HTML elements only on debug version.
71 * Revision 1.6 1996/03/12 11:30:33 robertj
72 * Fixed resetting of HTML output using operator=.
74 * Revision 1.5 1996/03/10 13:14:55 robertj
75 * Simplified some of the classes and added catch all string for attributes.
77 * Revision 1.4 1996/02/25 11:14:22 robertj
78 * Radio button support for forms.
80 * Revision 1.3 1996/02/19 13:31:51 robertj
81 * Removed MSC_VER test as now completely removed from WIN16 library.
83 * Revision 1.2 1996/02/08 12:24:30 robertj
84 * Further implementation.
86 * Revision 1.1 1996/02/03 11:18:46 robertj
87 * Initial revision
89 * Revision 1.3 1996/01/28 02:49:16 robertj
90 * Further implementation.
92 * Revision 1.2 1996/01/26 02:24:30 robertj
93 * Further implemetation.
95 * Revision 1.1 1996/01/23 13:04:32 robertj
96 * Initial revision
100 #ifdef __GNUC__
101 #pragma implementation "html.h"
102 #endif
104 #include <ptlib.h>
105 #include <ptclib/html.h>
108 //////////////////////////////////////////////////////////////////////////////
109 // PHTML
111 PHTML::PHTML(ElementInSet initialState)
113 memset(elementSet, 0, sizeof(elementSet));
114 tableNestLevel = 0;
115 initialElement = initialState;
116 switch (initialState) {
117 case NumElementsInSet :
118 break;
119 case InBody :
120 Set(InBody);
121 break;
122 case InForm :
123 Set(InBody);
124 Set(InForm);
125 break;
126 default :
127 PAssertAlways(PInvalidParameter);
132 PHTML::PHTML(const char * cstr)
134 memset(elementSet, 0, sizeof(elementSet));
135 tableNestLevel = 0;
136 initialElement = NumElementsInSet;
137 *this << Title(cstr) << Body() << Heading(1) << cstr << Heading(1);
141 PHTML::PHTML(const PString & str)
143 memset(elementSet, 0, sizeof(elementSet));
144 tableNestLevel = 0;
145 initialElement = NumElementsInSet;
146 *this << Title(str) << Body() << Heading(1) << str << Heading(1);
150 PHTML::~PHTML()
152 #ifndef NDEBUG
153 if (initialElement != NumElementsInSet) {
154 Clr(initialElement);
155 Clr(InBody);
157 for (PINDEX i = 0; i < PARRAYSIZE(elementSet); i++)
158 PAssert(elementSet[i] == 0, psprintf("Failed to close element %u", i));
159 #endif
163 void PHTML::AssignContents(const PContainer & cont)
165 PStringStream::AssignContents(cont);
166 memset(elementSet, 0, sizeof(elementSet));
170 BOOL PHTML::Is(ElementInSet elmt) const
172 return (elementSet[elmt>>3]&(1<<(elmt&7))) != 0;
176 void PHTML::Set(ElementInSet elmt)
178 elementSet[elmt>>3] |= (1<<(elmt&7));
182 void PHTML::Clr(ElementInSet elmt)
184 elementSet[elmt>>3] &= ~(1<<(elmt&7));
188 void PHTML::Toggle(ElementInSet elmt)
190 elementSet[elmt>>3] ^= (1<<(elmt&7));
194 void PHTML::Element::Output(PHTML & html) const
196 PAssert(reqElement == NumElementsInSet || html.Is(reqElement),
197 "HTML element out of context");
199 if (crlf == BothCRLF || (crlf == OpenCRLF && !html.Is(inElement)))
200 html << "\r\n";
202 html << '<';
203 if (html.Is(inElement))
204 html << '/';
205 html << name;
207 AddAttr(html);
209 if (attr != NULL)
210 html << ' ' << attr;
212 html << '>';
213 if (crlf == BothCRLF || (crlf == CloseCRLF && html.Is(inElement)))
214 html << "\r\n";
216 if (inElement != NumElementsInSet)
217 html.Toggle(inElement);
221 void PHTML::Element::AddAttr(PHTML &) const
226 PHTML::HTML::HTML(const char * attr)
227 : Element("HTML", attr, InHTML, NumElementsInSet, BothCRLF)
231 PHTML::Head::Head()
232 : Element("HEAD", NULL, InHead, NumElementsInSet, BothCRLF)
236 void PHTML::Head::Output(PHTML & html) const
238 PAssert(!html.Is(InBody), "HTML element out of context");
239 if (!html.Is(InHTML))
240 html << HTML();
241 Element::Output(html);
245 PHTML::Body::Body(const char * attr)
246 : Element("BODY", attr, InBody, NumElementsInSet, BothCRLF)
251 void PHTML::Body::Output(PHTML & html) const
253 if (!html.Is(InHTML))
254 html << HTML();
255 if (html.Is(InTitle))
256 html << Title();
257 if (html.Is(InHead))
258 html << Head();
259 Element::Output(html);
260 if (!html.Is(InBody))
261 html << HTML();
265 PHTML::Title::Title()
266 : Element("TITLE", NULL, InTitle, InHead, CloseCRLF)
268 titleString = NULL;
271 PHTML::Title::Title(const char * titleCStr)
272 : Element("TITLE", NULL, InTitle, InHead, CloseCRLF)
274 titleString = titleCStr;
277 PHTML::Title::Title(const PString & titleStr)
278 : Element("TITLE", NULL, InTitle, InHead, CloseCRLF)
280 titleString = titleStr;
283 void PHTML::Title::Output(PHTML & html) const
285 PAssert(!html.Is(InBody), "HTML element out of context");
286 if (!html.Is(InHead))
287 html << Head();
288 if (html.Is(InTitle)) {
289 if (titleString != NULL)
290 html << titleString;
291 Element::Output(html);
293 else {
294 Element::Output(html);
295 if (titleString != NULL) {
296 html << titleString;
297 Element::Output(html);
303 PHTML::Banner::Banner(const char * attr)
304 : Element("BANNER", attr, NumElementsInSet, InBody, BothCRLF)
309 PHTML::Division::Division(const char * attr)
310 : Element("DIV", attr, InDivision, InBody, BothCRLF)
315 PHTML::Heading::Heading(int number,
316 int sequence,
317 int skip,
318 const char * attr)
319 : Element("H", attr, InHeading, InBody, CloseCRLF)
321 num = number;
322 srcString = NULL;
323 seqNum = sequence;
324 skipSeq = skip;
327 PHTML::Heading::Heading(int number,
328 const char * image,
329 int sequence,
330 int skip,
331 const char * attr)
332 : Element("H", attr, InHeading, InBody, CloseCRLF)
334 num = number;
335 srcString = image;
336 seqNum = sequence;
337 skipSeq = skip;
340 PHTML::Heading::Heading(int number,
341 const PString & imageStr,
342 int sequence,
343 int skip,
344 const char * attr)
345 : Element("H", attr, InHeading, InBody, CloseCRLF)
347 num = number;
348 srcString = imageStr;
349 seqNum = sequence;
350 skipSeq = skip;
353 void PHTML::Heading::AddAttr(PHTML & html) const
355 PAssert(num >= 1 && num <= 6, "Bad heading number");
356 html << num;
357 if (srcString != NULL)
358 html << " SRC=\"" << srcString << '"';
359 if (seqNum > 0)
360 html << " SEQNUM=" << seqNum;
361 if (skipSeq > 0)
362 html << " SKIP=" << skipSeq;
366 PHTML::BreakLine::BreakLine(const char * attr)
367 : Element("BR", attr, NumElementsInSet, InBody, CloseCRLF)
372 PHTML::Paragraph::Paragraph(const char * attr)
373 : Element("P", attr, NumElementsInSet, InBody, OpenCRLF)
378 PHTML::PreFormat::PreFormat(int widthInChars, const char * attr)
379 : Element("PRE", attr, InPreFormat, InBody, CloseCRLF)
381 width = widthInChars;
385 void PHTML::PreFormat::AddAttr(PHTML & html) const
387 if (width > 0)
388 html << " WIDTH=" << width;
392 PHTML::HotLink::HotLink(const char * href, const char * attr)
393 : Element("A", attr, InAnchor, InBody, NoCRLF)
395 hrefString = href;
398 void PHTML::HotLink::AddAttr(PHTML & html) const
400 if (hrefString != NULL && *hrefString != '\0')
401 html << " HREF=\"" << hrefString << '"';
402 else
403 PAssert(html.Is(InAnchor), PInvalidParameter);
407 PHTML::Target::Target(const char * name, const char * attr)
408 : Element("A", attr, NumElementsInSet, InBody, NoCRLF)
410 nameString = name;
413 void PHTML::Target::AddAttr(PHTML & html) const
415 if (nameString != NULL && *nameString != '\0')
416 html << " NAME=\"" << nameString << '"';
420 PHTML::ImageElement::ImageElement(const char * n,
421 const char * attr,
422 ElementInSet elmt,
423 ElementInSet req,
424 OptionalCRLF c,
425 const char * image)
426 : Element(n, attr, elmt, req, c)
428 srcString = image;
432 void PHTML::ImageElement::AddAttr(PHTML & html) const
434 if (srcString != NULL)
435 html << " SRC=\"" << srcString << '"';
439 PHTML::Image::Image(const char * src, int w, int h, const char * attr)
440 : ImageElement("IMG", attr, NumElementsInSet, InBody, NoCRLF, src)
442 altString = NULL;
443 width = w;
444 height = h;
447 PHTML::Image::Image(const char * src,
448 const char * alt,
449 int w, int h,
450 const char * attr)
451 : ImageElement("IMG", attr, NumElementsInSet, InBody, NoCRLF, src)
453 altString = alt;
454 width = w;
455 height = h;
458 void PHTML::Image::AddAttr(PHTML & html) const
460 PAssert(srcString != NULL && *srcString != '\0', PInvalidParameter);
461 if (altString != NULL)
462 html << " ALT=\"" << altString << '"';
463 if (width != 0)
464 html << " WIDTH=" << width;
465 if (height != 0)
466 html << " HEIGHT=" << height;
467 ImageElement::AddAttr(html);
471 PHTML::HRule::HRule(const char * image, const char * attr)
472 : ImageElement("HR", attr, NumElementsInSet, InBody, BothCRLF, image)
477 PHTML::Note::Note(const char * image, const char * attr)
478 : ImageElement("NOTE", attr, InNote, InBody, BothCRLF, image)
483 PHTML::Address::Address(const char * attr)
484 : Element("ADDRESS", attr, InAddress, InBody, BothCRLF)
489 PHTML::BlockQuote::BlockQuote(const char * attr)
490 : Element("BQ", attr, InBlockQuote, InBody, BothCRLF)
495 PHTML::Credit::Credit(const char * attr)
496 : Element("CREDIT", attr, NumElementsInSet, InBlockQuote, OpenCRLF)
500 PHTML::SetTab::SetTab(const char * id, const char * attr)
501 : Element("TAB", attr, NumElementsInSet, InBody, NoCRLF)
503 ident = id;
506 void PHTML::SetTab::AddAttr(PHTML & html) const
508 PAssert(ident != NULL && *ident != '\0', PInvalidParameter);
509 html << " ID=" << ident;
513 PHTML::Tab::Tab(int indent, const char * attr)
514 : Element("TAB", attr, NumElementsInSet, InBody, NoCRLF)
516 ident = NULL;
517 indentSize = indent;
520 PHTML::Tab::Tab(const char * id, const char * attr)
521 : Element("TAB", attr, NumElementsInSet, InBody, NoCRLF)
523 ident = id;
524 indentSize = 0;
527 void PHTML::Tab::AddAttr(PHTML & html) const
529 PAssert(indentSize!=0 || (ident!=NULL && *ident!='\0'), PInvalidParameter);
530 if (indentSize > 0)
531 html << " INDENT=" << indentSize;
532 else
533 html << " TO=" << ident;
537 PHTML::SimpleList::SimpleList(const char * attr)
538 : Element("UL", attr, InList, InBody, BothCRLF)
542 void PHTML::SimpleList::AddAttr(PHTML & html) const
544 html << " PLAIN";
548 PHTML::BulletList::BulletList(const char * attr)
549 : Element("UL", attr, InList, InBody, BothCRLF)
554 PHTML::OrderedList::OrderedList(int seqNum, const char * attr)
555 : Element("OL", attr, InList, InBody, BothCRLF)
557 sequenceNum = seqNum;
560 void PHTML::OrderedList::AddAttr(PHTML & html) const
562 if (sequenceNum > 0)
563 html << " SEQNUM=" << sequenceNum;
564 if (sequenceNum < 0)
565 html << " CONTINUE";
569 PHTML::DefinitionList::DefinitionList(const char * attr)
570 : Element("DL", attr, InList, InBody, BothCRLF)
575 PHTML::ListHeading::ListHeading(const char * attr)
576 : Element("LH", attr, InListHeading, InList, CloseCRLF)
580 PHTML::ListItem::ListItem(int skip, const char * attr)
581 : Element("LI", attr, NumElementsInSet, InList, OpenCRLF)
583 skipSeq = skip;
586 void PHTML::ListItem::AddAttr(PHTML & html) const
588 if (skipSeq > 0)
589 html << " SKIP=" << skipSeq;
593 PHTML::DefinitionTerm::DefinitionTerm(const char * attr)
594 : Element("DT", attr, NumElementsInSet, InList, NoCRLF)
598 void PHTML::DefinitionTerm::Output(PHTML & html) const
600 PAssert(!html.Is(InDefinitionTerm), "HTML definition item missing");
601 Element::Output(html);
602 html.Set(InDefinitionTerm);
606 PHTML::DefinitionItem::DefinitionItem(const char * attr)
607 : Element("DD", attr, NumElementsInSet, InList, NoCRLF)
611 void PHTML::DefinitionItem::Output(PHTML & html) const
613 PAssert(html.Is(InDefinitionTerm), "HTML definition term missing");
614 Element::Output(html);
615 html.Clr(InDefinitionTerm);
619 PHTML::TableStart::TableStart(const char * attr)
620 : Element("TABLE", attr, InTable, InBody, BothCRLF)
622 borderFlag = FALSE;
625 PHTML::TableStart::TableStart(BorderCodes border, const char * attr)
626 : Element("TABLE", attr, InTable, InBody, BothCRLF)
628 borderFlag = border == Border;
631 void PHTML::TableStart::Output(PHTML & html) const
633 if (html.tableNestLevel > 0)
634 html.Clr(InTable);
635 Element::Output(html);
638 void PHTML::TableStart::AddAttr(PHTML & html) const
640 if (borderFlag)
641 html << " BORDER";
642 html.tableNestLevel++;
646 PHTML::TableEnd::TableEnd()
647 : Element("TABLE", "", InTable, InBody, BothCRLF)
651 void PHTML::TableEnd::Output(PHTML & html) const
653 PAssert(html.tableNestLevel > 0, "Table nesting error");
654 Element::Output(html);
655 html.tableNestLevel--;
656 if (html.tableNestLevel > 0)
657 html.Set(InTable);
661 PHTML::TableRow::TableRow(const char * attr)
662 : Element("TR", attr, NumElementsInSet, InTable, OpenCRLF)
667 PHTML::TableHeader::TableHeader(const char * attr)
668 : Element("TH", attr, NumElementsInSet, InTable, CloseCRLF)
673 PHTML::TableData::TableData(const char * attr)
674 : Element("TD", attr, NumElementsInSet, InTable, NoCRLF)
679 PHTML::Form::Form(const char * method,
680 const char * action,
681 const char * mimeType,
682 const char * script)
683 : Element("FORM", NULL, InForm, InBody, BothCRLF)
685 methodString = method;
686 actionString = action;
687 mimeTypeString = mimeType;
688 scriptString = script;
691 void PHTML::Form::AddAttr(PHTML & html) const
693 if (methodString != NULL)
694 html << " METHOD=" << methodString;
695 if (actionString != NULL)
696 html << " ACTION=\"" << actionString << '"';
697 if (mimeTypeString != NULL)
698 html << " ENCTYPE=\"" << mimeTypeString << '"';
699 if (scriptString != NULL)
700 html << " SCRIPT=\"" << scriptString << '"';
704 PHTML::FieldElement::FieldElement(const char * n,
705 const char * attr,
706 ElementInSet elmt,
707 OptionalCRLF c,
708 DisableCodes disabled)
709 : Element(n, attr, elmt, InForm, c)
711 disabledFlag = disabled == Disabled;
714 void PHTML::FieldElement::AddAttr(PHTML & html) const
716 if (disabledFlag)
717 html << " DISABLED";
721 PHTML::Select::Select(const char * fname, const char * attr)
722 : FieldElement("SELECT", attr, InSelect, BothCRLF, Enabled)
724 nameString = fname;
727 PHTML::Select::Select(const char * fname,
728 DisableCodes disabled,
729 const char * attr)
730 : FieldElement("SELECT", attr, InSelect, BothCRLF, disabled)
732 nameString = fname;
735 void PHTML::Select::AddAttr(PHTML & html) const
737 if (!html.Is(InSelect)) {
738 PAssert(nameString != NULL && *nameString != '\0', PInvalidParameter);
739 html << " NAME=\"" << nameString << '"';
741 FieldElement::AddAttr(html);
745 PHTML::Option::Option(const char * attr)
746 : FieldElement("OPTION", attr, NumElementsInSet, NoCRLF, Enabled)
748 selectedFlag = FALSE;
751 PHTML::Option::Option(SelectionCodes select,
752 const char * attr)
753 : FieldElement("OPTION", attr, NumElementsInSet, NoCRLF, Enabled)
755 selectedFlag = select == Selected;
758 PHTML::Option::Option(DisableCodes disabled,
759 const char * attr)
760 : FieldElement("OPTION", attr, NumElementsInSet, NoCRLF, disabled)
762 selectedFlag = FALSE;
765 PHTML::Option::Option(SelectionCodes select,
766 DisableCodes disabled,
767 const char * attr)
768 : FieldElement("OPTION", attr, NumElementsInSet, NoCRLF, disabled)
770 selectedFlag = select == Selected;
773 void PHTML::Option::AddAttr(PHTML & html) const
775 if (selectedFlag)
776 html << " SELECTED";
777 FieldElement::AddAttr(html);
781 PHTML::FormField::FormField(const char * n,
782 const char * attr,
783 ElementInSet elmt,
784 OptionalCRLF c,
785 DisableCodes disabled,
786 const char * fname)
787 : FieldElement(n, attr, elmt, c, disabled)
789 nameString = fname;
792 void PHTML::FormField::AddAttr(PHTML & html) const
794 PAssert(nameString != NULL && *nameString != '\0', PInvalidParameter);
795 html << " NAME=\"" << nameString << '"';
796 FieldElement::AddAttr(html);
800 PHTML::TextArea::TextArea(const char * fname,
801 DisableCodes disabled,
802 const char * attr)
803 : FormField("TEXTAREA", attr, InSelect, BothCRLF, disabled, fname)
805 numRows = numCols = 0;
808 PHTML::TextArea::TextArea(const char * fname,
809 int rows, int cols,
810 DisableCodes disabled,
811 const char * attr)
812 : FormField("TEXTAREA", attr, InSelect, BothCRLF, disabled, fname)
814 numRows = rows;
815 numCols = cols;
818 void PHTML::TextArea::AddAttr(PHTML & html) const
820 if (numRows > 0)
821 html << " ROWS=" << numRows;
822 if (numCols > 0)
823 html << " COLS=" << numCols;
824 FormField::AddAttr(html);
828 PHTML::InputField::InputField(const char * type,
829 const char * fname,
830 DisableCodes disabled,
831 const char * attr)
832 : FormField("INPUT", attr, NumElementsInSet, NoCRLF, disabled, fname)
834 typeString = type;
837 void PHTML::InputField::AddAttr(PHTML & html) const
839 PAssert(typeString != NULL && *typeString != '\0', PInvalidParameter);
840 html << " TYPE=" << typeString;
841 FormField::AddAttr(html);
845 PHTML::HiddenField::HiddenField(const char * fname,
846 const char * value,
847 const char * attr)
848 : InputField("hidden", fname, Enabled, attr)
850 valueString = value;
853 void PHTML::HiddenField::AddAttr(PHTML & html) const
855 InputField::AddAttr(html);
856 PAssert(valueString != NULL, PInvalidParameter);
857 html << " VALUE=\"" << valueString << '"';
861 PHTML::InputText::InputText(const char * fname,
862 int size,
863 const char * init,
864 const char * attr)
865 : InputField("text", fname, Enabled, attr)
867 width = size;
868 length = 0;
869 value = init;
872 PHTML::InputText::InputText(const char * fname,
873 int size,
874 DisableCodes disabled,
875 const char * attr)
876 : InputField("text", fname, disabled, attr)
878 width = size;
879 length = 0;
880 value = NULL;
883 PHTML::InputText::InputText(const char * fname,
884 int size,
885 int maxLength,
886 DisableCodes disabled,
887 const char * attr)
888 : InputField("text", fname, disabled, attr)
890 width = size;
891 length = maxLength;
892 value = NULL;
895 PHTML::InputText::InputText(const char * fname,
896 int size,
897 const char * init,
898 int maxLength,
899 DisableCodes disabled,
900 const char * attr)
901 : InputField("text", fname, disabled, attr)
903 width = size;
904 length = maxLength;
905 value = init;
908 PHTML::InputText::InputText(const char * type,
909 const char * fname,
910 int size,
911 const char * init,
912 int maxLength,
913 DisableCodes disabled,
914 const char * attr)
915 : InputField(type, fname, disabled, attr)
917 width = size;
918 length = maxLength;
919 value = init;
922 void PHTML::InputText::AddAttr(PHTML & html) const
924 InputField::AddAttr(html);
925 html << " SIZE=" << width;
926 if (length > 0)
927 html << " MAXLENGTH=" << length;
928 if (value != NULL)
929 html << " VALUE=\"" << value << '"';
933 PHTML::InputPassword::InputPassword(const char * fname,
934 int size,
935 const char * init,
936 const char * attr)
937 : InputText("password", fname, size, init, 0, Enabled, attr)
941 PHTML::InputPassword::InputPassword(const char * fname,
942 int size,
943 DisableCodes disabled,
944 const char * attr)
945 : InputText("password", fname, size, NULL, 0, disabled, attr)
949 PHTML::InputPassword::InputPassword(const char * fname,
950 int size,
951 int maxLength,
952 DisableCodes disabled,
953 const char * attr)
954 : InputText("password", fname, size, NULL, maxLength, disabled, attr)
958 PHTML::InputPassword::InputPassword(const char * fname,
959 int size,
960 const char * init,
961 int maxLength,
962 DisableCodes disabled,
963 const char * attr)
964 : InputText("password", fname, size, init, maxLength, disabled, attr)
969 PHTML::RadioButton::RadioButton(const char * fname,
970 const char * value,
971 const char * attr)
972 : InputField("radio", fname, Enabled, attr)
974 valueString = value;
975 checkedFlag = FALSE;
978 PHTML::RadioButton::RadioButton(const char * fname,
979 const char * value,
980 DisableCodes disabled,
981 const char * attr)
982 : InputField("radio", fname, disabled, attr)
984 valueString = value;
985 checkedFlag = FALSE;
988 PHTML::RadioButton::RadioButton(const char * fname,
989 const char * value,
990 CheckedCodes check,
991 DisableCodes disabled,
992 const char * attr)
993 : InputField("radio", fname, disabled, attr)
995 valueString = value;
996 checkedFlag = check == Checked;
999 PHTML::RadioButton::RadioButton(const char * type,
1000 const char * fname,
1001 const char * value,
1002 CheckedCodes check,
1003 DisableCodes disabled,
1004 const char * attr)
1005 : InputField(type, fname, disabled, attr)
1007 valueString = value;
1008 checkedFlag = check == Checked;
1011 void PHTML::RadioButton::AddAttr(PHTML & html) const
1013 InputField::AddAttr(html);
1014 PAssert(valueString != NULL, PInvalidParameter);
1015 html << " VALUE=" << valueString;
1016 if (checkedFlag)
1017 html << " CHECKED";
1021 PHTML::CheckBox::CheckBox(const char * fname, const char * attr)
1022 : RadioButton("checkbox", fname, "TRUE", UnChecked, Enabled, attr)
1026 PHTML::CheckBox::CheckBox(const char * fname,
1027 DisableCodes disabled,
1028 const char * attr)
1029 : RadioButton("checkbox", fname, "TRUE", UnChecked, disabled, attr)
1033 PHTML::CheckBox::CheckBox(const char * fname,
1034 CheckedCodes check,
1035 DisableCodes disabled,
1036 const char * attr)
1037 : RadioButton("checkbox", fname, "TRUE", check, disabled, attr)
1042 PHTML::InputRange::InputRange(const char * fname,
1043 int min, int max, int value,
1044 DisableCodes disabled,
1045 const char * attr)
1046 : InputField("range", fname, disabled, attr)
1048 PAssert(min <= max, PInvalidParameter);
1049 minValue = min;
1050 maxValue = max;
1051 if (value < min)
1052 initValue = min;
1053 else if (value > max)
1054 initValue = max;
1055 else
1056 initValue = value;
1059 void PHTML::InputRange::AddAttr(PHTML & html) const
1061 InputField::AddAttr(html);
1062 PINDEX max = PMAX(-minValue, maxValue);
1063 PINDEX width = 3;
1064 while (max > 10) {
1065 width++;
1066 max /= 10;
1068 html << " SIZE=" << width
1069 << " MIN=" << minValue
1070 << " MAX=" << maxValue
1071 << " VALUE=" << initValue;
1075 PHTML::InputFile::InputFile(const char * fname,
1076 const char * accept,
1077 DisableCodes disabled,
1078 const char * attr)
1079 : InputField("file", fname, disabled, attr)
1081 acceptString = accept;
1084 void PHTML::InputFile::AddAttr(PHTML & html) const
1086 InputField::AddAttr(html);
1087 if (acceptString != NULL)
1088 html << " ACCEPT=\"" << acceptString << '"';
1092 PHTML::InputImage::InputImage(const char * fname,
1093 const char * src,
1094 DisableCodes disabled,
1095 const char * attr)
1096 : InputField("image", fname, disabled, attr)
1098 srcString = src;
1101 PHTML::InputImage::InputImage(const char * type,
1102 const char * fname,
1103 const char * src,
1104 DisableCodes disabled,
1105 const char * attr)
1106 : InputField(type, fname, disabled, attr)
1108 srcString = src;
1111 void PHTML::InputImage::AddAttr(PHTML & html) const
1113 InputField::AddAttr(html);
1114 if (srcString != NULL)
1115 html << " SRC=\"" << srcString << '"';
1119 PHTML::InputScribble::InputScribble(const char * fname,
1120 const char * src,
1121 DisableCodes disabled,
1122 const char * attr)
1123 : InputImage("scribble", fname, src, disabled, attr)
1127 PHTML::ResetButton::ResetButton(const char * title,
1128 const char * fname,
1129 const char * src,
1130 DisableCodes disabled,
1131 const char * attr)
1132 : InputImage("reset", fname != NULL ? fname : "reset", src, disabled, attr)
1134 titleString = title;
1137 PHTML::ResetButton::ResetButton(const char * type,
1138 const char * title,
1139 const char * fname,
1140 const char * src,
1141 DisableCodes disabled,
1142 const char * attr)
1143 : InputImage(type, fname, src, disabled, attr)
1145 titleString = title;
1148 void PHTML::ResetButton::AddAttr(PHTML & html) const
1150 InputImage::AddAttr(html);
1151 if (titleString != NULL)
1152 html << " VALUE=\"" << titleString << '"';
1156 PHTML::SubmitButton::SubmitButton(const char * title,
1157 const char * fname,
1158 const char * src,
1159 DisableCodes disabled,
1160 const char * attr)
1161 : ResetButton("submit",
1162 title, fname != NULL ? fname : "submit", src, disabled, attr)
1166 // End Of File ///////////////////////////////////////////////////////////////