KHtml

html_form.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll ([email protected])
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * This file includes excerpts from the Document Object Model (DOM)
22  * Level 1 Specification (Recommendation)
23  * https://www.w3.org/TR/REC-DOM-Level-1/
24  * Copyright © World Wide Web Consortium , (Massachusetts Institute of
25  * Technology , Institut National de Recherche en Informatique et en
26  * Automatique , Keio University ). All Rights Reserved.
27  *
28  */
29 #ifndef HTML_FORM_H
30 #define HTML_FORM_H
31 
32 // --------------------------------------------------------------------------
33 #include <dom/html_element.h>
34 #include <dom/html_misc.h>
35 
36 namespace DOM
37 {
38 
39 class HTMLButtonElementImpl;
40 class HTMLFormElement;
41 class DOMString;
42 
43 /**
44  * Push button. See the <a
45  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-BUTTON">
46  * BUTTON element definition </a> in HTML 4.0.
47  *
48  */
49 class KHTML_EXPORT HTMLButtonElement : public HTMLElement
50 {
51 public:
54  HTMLButtonElement(const Node &other) : HTMLElement()
55  {
56  (*this) = other;
57  }
58 protected:
59  HTMLButtonElement(HTMLButtonElementImpl *impl);
60 public:
61 
62  HTMLButtonElement &operator = (const HTMLButtonElement &other);
63  HTMLButtonElement &operator = (const Node &other);
64 
66 
67  /**
68  * Returns the \c FORM element containing this
69  * control. Returns null if this control is not within the context
70  * of a form.
71  *
72  */
73  HTMLFormElement form() const;
74 
75  /**
76  * A single character access key to give access to the form
77  * control. See the <a
78  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey">
79  * accesskey attribute definition </a> in HTML 4.0.
80  *
81  */
82  DOMString accessKey() const;
83 
84  /**
85  * see accessKey
86  */
87  void setAccessKey(const DOMString &);
88 
89  /**
90  * The control is unavailable in this context. See the <a
91  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled">
92  * disabled attribute definition </a> in HTML 4.0.
93  *
94  */
95  bool disabled() const;
96 
97  /**
98  * see disabled
99  */
100  void setDisabled(bool);
101 
102  /**
103  * Form control or object name when submitted with a form. See the
104  * <a
105  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-name-BUTTON">
106  * name attribute definition </a> in HTML 4.0.
107  *
108  */
109  DOMString name() const;
110 
111  /**
112  * see name
113  */
114  void setName(const DOMString &);
115 
116  /**
117  * Index that represents the element's position in the tabbing
118  * order. See the <a
119  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex">
120  * tabindex attribute definition </a> in HTML 4.0.
121  *
122  */
123  long tabIndex() const;
124 
125  /**
126  * see tabIndex
127  */
128  void setTabIndex(long);
129 
130  /**
131  * The type of button. See the <a
132  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-type-BUTTON">
133  * type attribute definition </a> in HTML 4.0.
134  *
135  */
136  DOMString type() const;
137 
138  /**
139  * The current form control value. See the <a
140  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-value-BUTTON">
141  * value attribute definition </a> in HTML 4.0.
142  *
143  */
144  DOMString value() const;
145 
146  /**
147  * see value
148  */
149  void setValue(const DOMString &);
150 
151  /**
152  * Removes keyboard focus from this element.
153  *
154  */
155  void blur();
156 
157  /**
158  * Gives keyboard focus to this element.
159  *
160  */
161  void focus();
162 };
163 
164 // --------------------------------------------------------------------------
165 
166 class HTMLFieldSetElementImpl;
167 /**
168  * Organizes form controls into logical groups. See the <a
169  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-FIELDSET">
170  * FIELDSET element definition </a> in HTML 4.0.
171  *
172  */
173 class KHTML_EXPORT HTMLFieldSetElement : public HTMLElement
174 {
175 public:
178  HTMLFieldSetElement(const Node &other) : HTMLElement()
179  {
180  (*this) = other;
181  }
182 protected:
183  HTMLFieldSetElement(HTMLFieldSetElementImpl *impl);
184 public:
185 
186  HTMLFieldSetElement &operator = (const HTMLFieldSetElement &other);
187  HTMLFieldSetElement &operator = (const Node &other);
188 
190 
191  // TODO: deprecate/remove?
192  HTMLFormElement form() const;
193 };
194 
195 // --------------------------------------------------------------------------
196 
197 class HTMLFormElementImpl;
198 /**
199  * The \c FORM element encompasses behavior similar to a
200  * collection and an element. It provides direct access to the
201  * contained input elements as well as the attributes of the form
202  * element. See the <a
203  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-FORM">
204  * FORM element definition </a> in HTML 4.0.
205  *
206  */
207 class KHTML_EXPORT HTMLFormElement : public HTMLElement
208 {
209  friend class HTMLButtonElement;
210  friend class HTMLFieldSetElement;
211  friend class HTMLInputElement;
212  friend class HTMLLabelElement;
213  friend class HTMLLegendElement;
214  friend class HTMLSelectElement;
215  friend class HTMLTextAreaElement;
216  friend class HTMLOptionElement;
217  friend class HTMLIsIndexElement;
218  friend class HTMLObjectElement;
219 
220 public:
221  HTMLFormElement();
222  HTMLFormElement(const HTMLFormElement &other);
223  HTMLFormElement(const Node &other) : HTMLElement()
224  {
225  (*this) = other;
226  }
227 protected:
228  HTMLFormElement(HTMLFormElementImpl *impl);
229 public:
230 
231  HTMLFormElement &operator = (const HTMLFormElement &other);
232  HTMLFormElement &operator = (const Node &other);
233 
234  ~HTMLFormElement();
235 
236  /**
237  * Returns a collection of all control elements in the form.
238  *
239  */
240  HTMLCollection elements() const;
241 
242  /**
243  * The number of form controls in the form.
244  *
245  */
246  long length() const;
247 
248  /**
249  * Names the form.
250  *
251  */
252  DOMString name() const;
253 
254  /**
255  * see name
256  */
257  void setName(const DOMString &);
258 
259  /**
260  * List of character sets supported by the server. See the <a
261  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-accept-charset">
262  * accept-charset attribute definition </a> in HTML 4.0.
263  *
264  */
265  DOMString acceptCharset() const;
266 
267  /**
268  * see acceptCharset
269  */
270  void setAcceptCharset(const DOMString &);
271 
272  /**
273  * Server-side form handler. See the <a
274  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-action">
275  * action attribute definition </a> in HTML 4.0.
276  *
277  */
278  DOMString action() const;
279 
280  /**
281  * see action
282  */
283  void setAction(const DOMString &);
284 
285  /**
286  * The content type of the submitted form, generally
287  * "application/x-www-form-urlencoded". See the <a
288  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-enctype">
289  * enctype attribute definition </a> in HTML 4.0.
290  *
291  */
292  DOMString enctype() const;
293 
294  /**
295  * see enctype
296  */
297  void setEnctype(const DOMString &);
298 
299  /**
300  * HTTP method used to submit form. See the <a
301  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-method">
302  * method attribute definition </a> in HTML 4.0.
303  *
304  */
305  DOMString method() const;
306 
307  /**
308  * see method
309  */
310  void setMethod(const DOMString &);
311 
312  /**
313  * Frame to render the resource in. See the <a
314  * href="https://www.w3.org/TR/REC-html40/present/frames.html#adef-target">
315  * target attribute definition </a> in HTML 4.0.
316  *
317  */
318  DOMString target() const;
319 
320  /**
321  * see target
322  */
323  void setTarget(const DOMString &);
324 
325  /**
326  * Submits the form. It performs the same action as a submit
327  * button.
328  *
329  */
330  void submit();
331 
332  /**
333  * Restores a form element's default values. It performs the same
334  * action as a reset button.
335  *
336  */
337  void reset();
338 };
339 
340 // --------------------------------------------------------------------------
341 
342 class HTMLInputElementImpl;
343 /**
344  * Form control. Note. Depending upon the environment the page is
345  * being viewed, the value property may be read-only for the file
346  * upload input type. For the "password" input type, the actual value
347  * returned may be masked to prevent unauthorized use. See the <a
348  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-INPUT">
349  * INPUT element definition </a> in HTML 4.0.
350  *
351  */
352 class KHTML_EXPORT HTMLInputElement : public HTMLElement
353 {
354 public:
356  HTMLInputElement(const HTMLInputElement &other);
357  HTMLInputElement(const Node &other) : HTMLElement()
358  {
359  (*this) = other;
360  }
361 protected:
362  HTMLInputElement(HTMLInputElementImpl *impl);
363 public:
364 
365  HTMLInputElement &operator = (const HTMLInputElement &other);
366  HTMLInputElement &operator = (const Node &other);
367 
368  ~HTMLInputElement();
369 
370  /**
371  * Stores the initial control value (i.e., the initial value of
372  * \c value ).
373  *
374  */
375  DOMString defaultValue() const;
376 
377  /**
378  * see defaultValue
379  */
380  void setDefaultValue(const DOMString &);
381 
382  /**
383  * When \c type has the value "Radio" or "Checkbox",
384  * stores the initial value of the \c checked
385  * attribute.
386  *
387  */
388  bool defaultChecked() const;
389 
390  /**
391  * see defaultChecked
392  */
393  void setDefaultChecked(bool);
394 
395  // TODO: deprecate/remove?
396  HTMLFormElement form() const;
397 
398  /**
399  * A comma-separated list of content types that a server
400  * processing this form will handle correctly. See the <a
401  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-accept">
402  * accept attribute definition </a> in HTML 4.0.
403  *
404  */
405  DOMString accept() const;
406 
407  /**
408  * see accept
409  */
410  void setAccept(const DOMString &);
411 
412  /**
413  * A single character access key to give access to the form
414  * control. See the <a
415  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey">
416  * accesskey attribute definition </a> in HTML 4.0.
417  *
418  */
419  DOMString accessKey() const;
420 
421  /**
422  * see accessKey
423  */
424  void setAccessKey(const DOMString &);
425 
426  /**
427  * Aligns this object (vertically or horizontally) with respect to
428  * its surrounding text. See the <a
429  * href="https://www.w3.org/TR/REC-html40/struct/objects.html#adef-align-IMG">
430  * align attribute definition </a> in HTML 4.0. This attribute is
431  * deprecated in HTML 4.0.
432  *
433  */
434  DOMString align() const;
435 
436  /**
437  * see align
438  */
439  void setAlign(const DOMString &);
440 
441  /**
442  * Alternate text for user agents not rendering the normal content
443  * of this element. See the <a
444  * href="https://www.w3.org/TR/REC-html40/struct/objects.html#adef-alt">
445  * alt attribute definition </a> in HTML 4.0.
446  *
447  */
448  DOMString alt() const;
449 
450  /**
451  * see alt
452  */
453  void setAlt(const DOMString &);
454 
455  /**
456  * Describes whether a radio or check box is checked, when
457  * \c type has the value "Radio" or "Checkbox". The value is
458  * true if explicitly set. Represents the current state of the
459  * checkbox or radio button. See the <a
460  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-checked">
461  * checked attribute definition </a> in HTML 4.0.
462  *
463  */
464  bool checked() const;
465 
466  /**
467  * see checked
468  */
469  void setChecked(bool);
470 
471  /**
472  * Describes whether a radio box is indeterminate
473  */
474  bool indeterminate() const;
475 
476  /**
477  * see indeterminate
478  */
479  void setIndeterminate(bool);
480 
481  /**
482  * The control is unavailable in this context. See the <a
483  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled">
484  * disabled attribute definition </a> in HTML 4.0.
485  *
486  */
487  bool disabled() const;
488 
489  /**
490  * see disabled
491  */
492  void setDisabled(bool);
493 
494  /**
495  * Maximum number of characters for text fields, when \c type
496  * has the value "Text" or "Password". See the <a
497  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-maxlength">
498  * maxlength attribute definition </a> in HTML 4.0.
499  *
500  */
501  long maxLength() const;
502 
503  /**
504  * see maxLength
505  */
506  void setMaxLength(long);
507 
508  /**
509  * Form control or object name when submitted with a form. See the
510  * <a
511  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-name-INPUT">
512  * name attribute definition </a> in HTML 4.0.
513  *
514  */
515  DOMString name() const;
516 
517  /**
518  * see name
519  */
520  void setName(const DOMString &);
521 
522  /**
523  * This control is read-only. When \c type has the
524  * value "text" or "password" only. See the <a
525  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-readonly">
526  * readonly attribute definition </a> in HTML 4.0.
527  *
528  */
529  bool readOnly() const;
530 
531  // ### remove in 4.0
532  /**
533  * see readOnly
534  */
535  void setReadOnly(bool);
536 
537  /**
538  * @deprecated
539  */
540 #ifndef KHTML_NO_DEPRECATED
541  KHTML_DEPRECATED DOMString size() const;
542 #endif
543 
544  /**
545  * @deprecated
546  */
547 #ifndef KHTML_NO_DEPRECATED
548  KHTML_DEPRECATED void setSize(const DOMString &);
549 #endif
550 
551  /**
552  * Size information. The precise meaning is specific to each type
553  * of field. See the <a
554  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-size-INPUT">
555  * size attribute definition </a> in HTML 4.0.
556  *
557  */
558  long getSize() const;
559 
560  /**
561  * see getSize
562  */
563  void setSize(long);
564 
565  /**
566  * When the \c type attribute has the value "Image",
567  * this attribute specifies the location of the image to be used
568  * to decorate the graphical submit button. See the <a
569  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-src">
570  * src attribute definition </a> in HTML 4.0.
571  *
572  */
573  DOMString src() const;
574 
575  /**
576  * see src
577  */
578  void setSrc(const DOMString &);
579 
580  /**
581  * Index that represents the element's position in the tabbing
582  * order. See the <a
583  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex">
584  * tabindex attribute definition </a> in HTML 4.0.
585  *
586  */
587  long tabIndex() const;
588 
589  /**
590  * see tabIndex
591  */
592  void setTabIndex(long);
593 
594  /**
595  * The type of control created. See the <a
596  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-type-INPUT">
597  * type attribute definition </a> in HTML 4.0.
598  *
599  */
600  DOMString type() const;
601 
602  /**
603  * see type
604  */
605  void setType(const DOMString &);
606 
607  /**
608  * Use client-side image map. See the <a
609  * href="https://www.w3.org/TR/REC-html40/struct/objects.html#adef-usemap">
610  * usemap attribute definition </a> in HTML 4.0.
611  *
612  */
613  DOMString useMap() const;
614 
615  /**
616  * see useMap
617  */
618  void setUseMap(const DOMString &);
619 
620  /**
621  * The current form control value. Used for radio buttons and
622  * check boxes. See the <a
623  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-value-INPUT">
624  * value attribute definition </a> in HTML 4.0.
625  *
626  */
627  DOMString value() const;
628 
629  /**
630  * see value
631  */
632  void setValue(const DOMString &);
633 
634  /**
635  * Removes keyboard focus from this element.
636  *
637  */
638  void blur();
639 
640  /**
641  * Gives keyboard focus to this element.
642  *
643  */
644  void focus();
645 
646  /**
647  * Select the contents of the text area. For \c INPUT
648  * elements whose \c type attribute has one of the
649  * following values: "Text", "File", or "Password".
650  *
651  */
652  void select();
653 
654  /**
655  * Simulate a mouse-click. For \c INPUT elements whose
656  * \c type attribute has one of the following values:
657  * "Button", "Checkbox", "Radio", "Reset", or "Submit".
658  */
659  void click();
660 
661  /**
662  * Returns the character offset of beginning of selection, or if none,
663  * the cursor position.
664  * This operation is only supported if the type of this element is text;
665  * otherwise -1 is returned.
666  * NOTE: this method is not part of the DOM, but a Mozilla extension
667  */
668  long selectionStart();
669 
670  /**
671  * Move the beginning of the selection to the given offset in text
672  * This call has no effect if the type of this input element isn't text
673  * NOTE: this method is not part of the DOM, but a Mozilla extension
674  */
675  void setSelectionStart(long offset);
676 
677  /**
678  * Returns the character offset of end of selection, or if none,
679  * the cursor position.
680  * This operation is only supported if the type of this element is text;
681  * otherwise -1 is returned.
682  * NOTE: this method is not part of the DOM, but a Mozilla extension
683  */
684  long selectionEnd();
685 
686  /**
687  * Move the end of the selection (and the cursor) to the given offset in text
688  * This call has no effect if the type of this input element isn't text
689  * NOTE: this method is not part of the DOM, but a Mozilla extension
690  */
691  void setSelectionEnd(long offset);
692 
693  /**
694  * Makes the position span from start to end, and positions the cursor after the selection.
695  * This call has no effect if the type of this input element isn't text or if it is not rendered.
696  * NOTE: this method is not part of the DOM, but a Mozilla extension
697  */
698  void setSelectionRange(long start, long end);
699 
700 };
701 
702 // --------------------------------------------------------------------------
703 
704 class HTMLLabelElementImpl;
705 /**
706  * Form field label text. See the <a
707  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-LABEL">
708  * LABEL element definition </a> in HTML 4.0.
709  *
710  */
711 class KHTML_EXPORT HTMLLabelElement : public HTMLElement
712 {
713 public:
715  HTMLLabelElement(const HTMLLabelElement &other);
716  HTMLLabelElement(const Node &other) : HTMLElement()
717  {
718  (*this) = other;
719  }
720 protected:
721  HTMLLabelElement(HTMLLabelElementImpl *impl);
722 public:
723 
724  HTMLLabelElement &operator = (const HTMLLabelElement &other);
725  HTMLLabelElement &operator = (const Node &other);
726 
727  ~HTMLLabelElement();
728 
729  /**
730  * A single character access key to give access to the form
731  * control. See the <a
732  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey">
733  * accesskey attribute definition </a> in HTML 4.0.
734  *
735  */
736  DOMString accessKey() const;
737 
738  /**
739  * see accessKey
740  */
741  void setAccessKey(const DOMString &);
742 
743  /**
744  * This attribute links this label with another form control by
745  * \c id attribute. See the <a
746  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-for">
747  * for attribute definition </a> in HTML 4.0.
748  *
749  */
750  DOMString htmlFor() const;
751 
752  /**
753  * see htmlFor
754  */
755  void setHtmlFor(const DOMString &);
756 };
757 
758 // --------------------------------------------------------------------------
759 
760 class HTMLLegendElementImpl;
761 /**
762  * Provides a caption for a \c FIELDSET grouping. See the
763  * <a
764  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-LEGEND">
765  * LEGEND element definition </a> in HTML 4.0.
766  *
767  */
768 class KHTML_EXPORT HTMLLegendElement : public HTMLElement
769 {
770 public:
772  HTMLLegendElement(const HTMLLegendElement &other);
773  HTMLLegendElement(const Node &other) : HTMLElement()
774  {
775  (*this) = other;
776  }
777 protected:
778  HTMLLegendElement(HTMLLegendElementImpl *impl);
779 public:
780 
781  HTMLLegendElement &operator = (const HTMLLegendElement &other);
782  HTMLLegendElement &operator = (const Node &other);
783 
785 
786  // TODO: deprecate/remove?
787  HTMLFormElement form() const;
788 
789  /**
790  * A single character access key to give access to the form
791  * control. See the <a
792  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey">
793  * accesskey attribute definition </a> in HTML 4.0.
794  *
795  */
796  DOMString accessKey() const;
797 
798  /**
799  * see accessKey
800  */
801  void setAccessKey(const DOMString &);
802 
803  /**
804  * Text alignment relative to \c FIELDSET . See the <a
805  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-align-LEGEND">
806  * align attribute definition </a> in HTML 4.0. This attribute is
807  * deprecated in HTML 4.0.
808  *
809  */
810  DOMString align() const;
811 
812  /**
813  * see align
814  */
815  void setAlign(const DOMString &);
816 };
817 
818 // --------------------------------------------------------------------------
819 
820 class HTMLOptGroupElementImpl;
821 /**
822  * Group options together in logical subdivisions. See the <a
823  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-OPTGROUP">
824  * OPTGROUP element definition </a> in HTML 4.0.
825  *
826  */
827 class KHTML_EXPORT HTMLOptGroupElement : public HTMLElement
828 {
829 public:
832  HTMLOptGroupElement(const Node &other) : HTMLElement()
833  {
834  (*this) = other;
835  }
836 protected:
837  HTMLOptGroupElement(HTMLOptGroupElementImpl *impl);
838 public:
839 
840  HTMLOptGroupElement &operator = (const HTMLOptGroupElement &other);
841  HTMLOptGroupElement &operator = (const Node &other);
842 
844 
845  /**
846  * The control is unavailable in this context. See the <a
847  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled">
848  * disabled attribute definition </a> in HTML 4.0.
849  *
850  */
851  bool disabled() const;
852 
853  /**
854  * see disabled
855  */
856  void setDisabled(bool);
857 
858  /**
859  * Assigns a label to this option group. See the <a
860  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-label-OPTGROUP">
861  * label attribute definition </a> in HTML 4.0.
862  *
863  */
864  DOMString label() const;
865 
866  /**
867  * see label
868  */
869  void setLabel(const DOMString &);
870 };
871 
872 // --------------------------------------------------------------------------
873 
874 class HTMLSelectElementImpl;
875 /**
876  * The select element allows the selection of an option. The contained
877  * options can be directly accessed through the select element as a
878  * collection. See the <a
879  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-SELECT">
880  * SELECT element definition </a> in HTML 4.0.
881  *
882  */
883 class KHTML_EXPORT HTMLSelectElement : public HTMLElement
884 {
885 public:
887  HTMLSelectElement(const HTMLSelectElement &other);
888  HTMLSelectElement(const Node &other) : HTMLElement()
889  {
890  (*this) = other;
891  }
892 protected:
893  HTMLSelectElement(HTMLSelectElementImpl *impl);
894 public:
895 
896  HTMLSelectElement &operator = (const HTMLSelectElement &other);
897  HTMLSelectElement &operator = (const Node &other);
898 
900 
901  /**
902  * The type of control created.
903  *
904  */
905  DOMString type() const;
906 
907  /**
908  * The ordinal index of the selected option. The value -1 is
909  * returned if no element is selected. If multiple options are
910  * selected, the index of the first selected option is returned.
911  *
912  */
913  long selectedIndex() const;
914 
915  /**
916  * see selectedIndex
917  */
918  void setSelectedIndex(long);
919 
920  /**
921  * The current form control value.
922  *
923  */
924  DOMString value() const;
925 
926  /**
927  * see value
928  */
929  void setValue(const DOMString &);
930 
931  /**
932  * The number of options in this \c SELECT .
933  *
934  */
935  long length() const;
936 
937  // TODO: deprecate/remove?
938  HTMLFormElement form() const;
939 
940  /**
941  * The collection of \c OPTION elements contained by
942  * this element.
943  *
944  */
945  HTMLCollection options() const;
946 
947  /**
948  * The control is unavailable in this context. See the <a
949  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled">
950  * disabled attribute definition </a> in HTML 4.0.
951  *
952  */
953  bool disabled() const;
954 
955  /**
956  * see disabled
957  */
958  void setDisabled(bool);
959 
960  /**
961  * If true, multiple \c OPTION elements may be
962  * selected in this \c SELECT . See the <a
963  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-multiple">
964  * multiple attribute definition </a> in HTML 4.0.
965  *
966  */
967  bool multiple() const;
968 
969  /**
970  * see multiple
971  */
972  void setMultiple(bool);
973 
974  /**
975  * Form control or object name when submitted with a form. See the
976  * <a
977  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-name-SELECT">
978  * name attribute definition </a> in HTML 4.0.
979  *
980  */
981  DOMString name() const;
982 
983  /**
984  * see name
985  */
986  void setName(const DOMString &);
987 
988  /**
989  * Number of visible rows. See the <a
990  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-size-SELECT">
991  * size attribute definition </a> in HTML 4.0.
992  *
993  */
994  long size() const;
995 
996  /**
997  * see size
998  */
999  void setSize(long);
1000 
1001  /**
1002  * Index that represents the element's position in the tabbing
1003  * order. See the <a
1004  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex">
1005  * tabindex attribute definition </a> in HTML 4.0.
1006  *
1007  */
1008  long tabIndex() const;
1009 
1010  /**
1011  * see tabIndex
1012  */
1013  void setTabIndex(long);
1014 
1015  /**
1016  * Add a new element to the collection of \c OPTION
1017  * elements for this \c SELECT .
1018  *
1019  * @param element The element to add.
1020  *
1021  * @param before The element to insert before, or 0 for the
1022  * tail of the list.
1023  *
1024  */
1025  void add(const HTMLElement &element, const HTMLElement &before);
1026 
1027  /**
1028  * Remove an element from the collection of \c OPTION
1029  * elements for this \c SELECT . Does nothing if no
1030  * element has the given index.
1031  *
1032  * @param index The index of the item to remove.
1033  *
1034  */
1035  void remove(long index);
1036 
1037  /**
1038  * Removes keyboard focus from this element.
1039  *
1040  */
1041  void blur();
1042 
1043  /**
1044  * Gives keyboard focus to this element.
1045  *
1046  */
1047  void focus();
1048 };
1049 
1050 // --------------------------------------------------------------------------
1051 
1052 class HTMLTextAreaElementImpl;
1053 /**
1054  * Multi-line text field. See the <a
1055  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-TEXTAREA">
1056  * TEXTAREA element definition </a> in HTML 4.0.
1057  *
1058  */
1059 class KHTML_EXPORT HTMLTextAreaElement : public HTMLElement
1060 {
1061 public:
1064  HTMLTextAreaElement(const Node &other) : HTMLElement()
1065  {
1066  (*this) = other;
1067  }
1068 protected:
1069  HTMLTextAreaElement(HTMLTextAreaElementImpl *impl);
1070 public:
1071 
1072  HTMLTextAreaElement &operator = (const HTMLTextAreaElement &other);
1073  HTMLTextAreaElement &operator = (const Node &other);
1074 
1076 
1077  /**
1078  * Stores the initial control value (i.e., the initial value of
1079  * \c value ).
1080  *
1081  */
1082  DOMString defaultValue() const;
1083 
1084  /**
1085  * see defaultValue
1086  */
1087  void setDefaultValue(const DOMString &);
1088 
1089  // TODO: deprecate/remove?
1090  HTMLFormElement form() const;
1091 
1092  /**
1093  * A single character access key to give access to the form
1094  * control. See the <a
1095  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-accesskey">
1096  * accesskey attribute definition </a> in HTML 4.0.
1097  *
1098  */
1099  DOMString accessKey() const;
1100 
1101  /**
1102  * see accessKey
1103  */
1104  void setAccessKey(const DOMString &);
1105 
1106  /**
1107  * Width of control (in characters). See the <a
1108  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-cols-TEXTAREA">
1109  * cols attribute definition </a> in HTML 4.0.
1110  *
1111  */
1112  long cols() const;
1113 
1114  /**
1115  * see cols
1116  */
1117  void setCols(long);
1118 
1119  /**
1120  * The control is unavailable in this context. See the <a
1121  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled">
1122  * disabled attribute definition </a> in HTML 4.0.
1123  *
1124  */
1125  bool disabled() const;
1126 
1127  /**
1128  * see disabled
1129  */
1130  void setDisabled(bool);
1131 
1132  /**
1133  * Form control or object name when submitted with a form. See the
1134  * <a
1135  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-name-TEXTAREA">
1136  * name attribute definition </a> in HTML 4.0.
1137  *
1138  */
1139  DOMString name() const;
1140 
1141  /**
1142  * see name
1143  */
1144  void setName(const DOMString &);
1145 
1146  /**
1147  * This control is read-only. See the <a
1148  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-readonly">
1149  * readonly attribute definition </a> in HTML 4.0.
1150  *
1151  */
1152  bool readOnly() const;
1153 
1154  /**
1155  * see readOnly
1156  */
1157  void setReadOnly(bool);
1158 
1159  /**
1160  * Number of text rows. See the <a
1161  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-rows-TEXTAREA">
1162  * rows attribute definition </a> in HTML 4.0.
1163  *
1164  */
1165  long rows() const;
1166 
1167  /**
1168  * see rows
1169  */
1170  void setRows(long);
1171 
1172  /**
1173  * Index that represents the element's position in the tabbing
1174  * order. See the <a
1175  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex">
1176  * tabindex attribute definition </a> in HTML 4.0.
1177  *
1178  */
1179  long tabIndex() const;
1180 
1181  /**
1182  * see tabIndex
1183  */
1184  void setTabIndex(long);
1185 
1186  /**
1187  * The type of this form control.
1188  *
1189  */
1190  DOMString type() const;
1191 
1192  /**
1193  * The current textual content of the multi-line text field. If
1194  * the entirety of the data can not fit into a single wstring, the
1195  * implementation may truncate the data.
1196  *
1197  */
1198  DOMString value() const;
1199 
1200  /**
1201  * see value
1202  */
1203  void setValue(const DOMString &);
1204 
1205  /**
1206  * Removes keyboard focus from this element.
1207  */
1208  void blur();
1209 
1210  /**
1211  * Gives keyboard focus to this element.
1212  */
1213  void focus();
1214 
1215  /**
1216  * Select the contents of the \c TEXTAREA .
1217  */
1218  void select();
1219 
1220  /**
1221  * Returns the character offset of beginning of selection, or if none,
1222  * the cursor position.
1223  * NOTE: this method is not part of the DOM, but a Mozilla extension
1224  */
1225  long selectionStart();
1226 
1227  /**
1228  * Move the beginning of the selection to the given offset in text
1229  * NOTE: this method is not part of the DOM, but a Mozilla extension
1230  */
1231  void setSelectionStart(long offset);
1232 
1233  /**
1234  * Returns the character offset of end of selection, or if none,
1235  * the cursor position.
1236  * NOTE: this method is not part of the DOM, but a Mozilla extension
1237  */
1238  long selectionEnd();
1239 
1240  /**
1241  * Move the end of the selection (and the cursor) to the given offset in text
1242  * NOTE: this method is not part of the DOM, but a Mozilla extension
1243  */
1244  void setSelectionEnd(long offset);
1245 
1246  /**
1247  * Selects the text from start to end, and positions the cursor after the selection.
1248  * NOTE: this method is not part of the DOM, but a Mozilla extension
1249  */
1250  void setSelectionRange(long start, long end);
1251 
1252  /**
1253  * Returns the length of the text.
1254  * NOTE: this method is not part of the DOM, but a Mozilla extension
1255  */
1256  long textLength();
1257 };
1258 
1259 // --------------------------------------------------------------------------
1260 
1261 class HTMLOptionElementImpl;
1262 /**
1263  * A selectable choice. See the <a
1264  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-OPTION">
1265  * OPTION element definition </a> in HTML 4.0.
1266  *
1267  */
1268 class KHTML_EXPORT HTMLOptionElement : public HTMLElement
1269 {
1270 public:
1272  HTMLOptionElement(const HTMLOptionElement &other);
1273  HTMLOptionElement(const Node &other) : HTMLElement()
1274  {
1275  (*this) = other;
1276  }
1277 protected:
1278  HTMLOptionElement(HTMLOptionElementImpl *impl);
1279 public:
1280 
1281  HTMLOptionElement &operator = (const HTMLOptionElement &other);
1282  HTMLOptionElement &operator = (const Node &other);
1283 
1284  ~HTMLOptionElement();
1285 
1286  // TODO: deprecate/remove?
1287  HTMLFormElement form() const;
1288 
1289  /**
1290  * Stores the initial value of the \c selected
1291  * attribute.
1292  *
1293  */
1294  bool defaultSelected() const;
1295 
1296  /**
1297  * see defaultSelected
1298  */
1299  void setDefaultSelected(bool);
1300 
1301  /**
1302  * The text contained within the option element.
1303  *
1304  */
1305  DOMString text() const;
1306 
1307  /**
1308  * The index of this \c OPTION in its parent
1309  * \c SELECT .
1310  *
1311  */
1312  long index() const;
1313 
1314  /**
1315  * see index
1316  *
1317  * This function is obsolete - the index property is actually supposed to be read-only
1318  * (https://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html)
1319  */
1320  void setIndex(long);
1321 
1322  /**
1323  * The control is unavailable in this context. See the <a
1324  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled">
1325  * disabled attribute definition </a> in HTML 4.0.
1326  *
1327  */
1328  bool disabled() const;
1329 
1330  /**
1331  * see disabled
1332  */
1333  void setDisabled(bool);
1334 
1335  /**
1336  * Option label for use in hierarchical menus. See the <a
1337  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-label-OPTION">
1338  * label attribute definition </a> in HTML 4.0.
1339  *
1340  */
1341  DOMString label() const;
1342 
1343  /**
1344  * see label
1345  */
1346  void setLabel(const DOMString &);
1347 
1348  /**
1349  * Means that this option is initially selected. See the <a
1350  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-selected">
1351  * selected attribute definition </a> in HTML 4.0.
1352  *
1353  */
1354  bool selected() const;
1355 
1356  /**
1357  * see selected
1358  */
1359  void setSelected(bool);
1360 
1361  /**
1362  * The current form control value. See the <a
1363  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-value-OPTION">
1364  * value attribute definition </a> in HTML 4.0.
1365  *
1366  */
1367  DOMString value() const;
1368 
1369  /**
1370  * see value
1371  */
1372  void setValue(const DOMString &);
1373 };
1374 
1375 // --------------------------------------------------------------------------
1376 
1377 class HTMLIsIndexElementImpl;
1378 class HTMLFormElement;
1379 
1380 /**
1381  * This element is used for single-line text input. See the <a
1382  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#edef-ISINDEX">
1383  * ISINDEX element definition </a> in HTML 4.0. This element is
1384  * deprecated in HTML 4.0.
1385  *
1386  */
1387 class KHTML_EXPORT HTMLIsIndexElement : public HTMLElement
1388 {
1389 public:
1391  HTMLIsIndexElement(const HTMLIsIndexElement &other);
1392  HTMLIsIndexElement(const Node &other) : HTMLElement()
1393  {
1394  (*this) = other;
1395  }
1396 protected:
1397  HTMLIsIndexElement(HTMLIsIndexElementImpl *impl);
1398 public:
1399 
1400  HTMLIsIndexElement &operator = (const HTMLIsIndexElement &other);
1401  HTMLIsIndexElement &operator = (const Node &other);
1402 
1403  ~HTMLIsIndexElement();
1404 
1405  // TODO: deprecate/remove?
1406  HTMLFormElement form() const;
1407 
1408  /**
1409  * The prompt message. See the <a
1410  * href="https://www.w3.org/TR/REC-html40/interact/forms.html#adef-prompt">
1411  * prompt attribute definition </a> in HTML 4.0. This attribute is
1412  * deprecated in HTML 4.0.
1413  *
1414  */
1415  DOMString prompt() const;
1416 
1417  /**
1418  * see prompt
1419  */
1420  void setPrompt(const DOMString &);
1421 };
1422 
1423 } //namespace
1424 
1425 #endif
All HTML element interfaces derive from this class.
Definition: html_element.h:70
Generic embedded object.
Definition: html_object.h:268
Q_SCRIPTABLE Q_NOREPLY void start()
Organizes form controls into logical groups.
Definition: html_form.h:173
This library provides a full-featured HTML parser and widget.
An HTMLCollection is a list of nodes.
Definition: html_misc.h:133
Provides a caption for a FIELDSET grouping.
Definition: html_form.h:768
The FORM element encompasses behavior similar to a collection and an element.
Definition: html_form.h:207
Form control.
Definition: html_form.h:352
Form field label text.
Definition: html_form.h:711
Group options together in logical subdivisions.
Definition: html_form.h:827
Multi-line text field.
Definition: html_form.h:1059
A selectable choice.
Definition: html_form.h:1268
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
The select element allows the selection of an option.
Definition: html_form.h:883
This element is used for single-line text input.
Definition: html_form.h:1387
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
void setTarget(const SkyPoint &targetCoord)
Push button.
Definition: html_form.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Nov 28 2023 03:56:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.