htmlInputTextArea
Multi-line text input control class
[Previous] [Main] [Next]


Description
htmlInputTextArea encapsulates the <TEXTAREA></TEXTAREA> tags. It defines a multi-line text input field on a form.  
 
The text value of the control can be set using the assignment = operator or the Value() method. Text can be appended to the control using the insertion << operator or the Add() method. Likewise, the text value can be retrieved easily using the overloaded Value() method or the (String) casting operator.  
 
The number of characters per line is controlled using the Columns() method. Similarly, the number of rows that are displayed without scrolling is controlled using the Rows() method. Scrollbars will automatically appear in the input area if the text entered exceeds the specified number of columns or rows.  
 
Wrapping of words to new lines within the text area can be enabled or disabled using the Wrap() method.  
 
Declaration
#include <dcmicro/htmlpp/textarea.h>  
 
Hierarchy
htmlinputtextarea.gif  
 
See Also
htmlForm, htmlInputText  
 
Related Constants/Definitions
typedef enum {  
wrap_default = 0,  
wrap_off,  
wrap_soft,  
wrap_hard  
} WordWrapType ;  
 
Constructors
htmlInputTextArea()  
Constructs an empty object.  
 
htmlInputTextArea( const String& name, int rows, int columns )  
Constructs an empty object using the specified control name, with a maximum display area of rows and columns.  
 
htmlInputTextArea( const String& name,  
    const String& value,  
    int rows,  
    int columns )  
Constructs an object using the specified control name, with a maximum display area of rows and columns, populating it with text value.  
 
Destructor
virtual ~htmlInputTextArea()  
Destroys the object.  
 
Member Methods
=   htmlInputTextArea& operator=( const htmlInputTextArea& rhs )  
Replaces the contents with rhs and returns a pointer to the object.  
 
=   htmlInputTextArea& operator=( const String& text )  
Replaces the text value of the control with text and returns a pointer to the object. Functionally equivalent to the Value() method.  
 
<<   htmlInputTextArea& operator<< ( const String& text )  
Appends the text string to the object, and returns a reference to the object. Functionally equivalent to the Add() method.  
 
(String)htmlInputTextArea& operator String() const  
Returns the control value as a string, or an empty string if not set. Functionally equivalent to the Value() method.  
 
Add   htmlInputTextArea& Add( const String& text )  
Appends the text string to the object, and returns a reference to the object. Functionally equivalent to the << operator.  
 
NamehtmlInputTextArea& Name(const String& name )  
Sets the control name to name, and returns a reference to the object.  
 
NameString Name() const  
Returns the control name as a string, or an empty string if not set.  
 
ValuehtmlInputTextArea& Value(const String& value )  
Replaces the text value of the control with value, and returns a reference to the object.  
 
ValueString Name() const  
Returns the text value of the control as a string, or an empty string if not set.  
 
ColumnshtmlInputTextArea& Columns(int columns )  
Sets the display width, in columns, of the control value to columns, and returns a reference to the object.  
 
Columnsint Columns() const  
Returns the number of columns for the control display width, or zero if not set.  
 
RowshtmlInputTextArea& Rows( int rows )  
Sets the display height, in rows, of the control value to rows, and returns a reference to the object.  
 
Rowsint Rows() const  
Returns the number of rows for the control display height, or zero if not set.  
 
Wrap   htmlInputTextArea& Wrap( WordWrapType wrap )  
Sets how the browser wraps words on lines longer than the text area's column width, and returns a reference to the object.  
 
  • wrap_off disables word wrap. Text typed by the user is displayed exactly as typed. If the user inserts a line break, it is included as part of the value when the form is submitted. The user may need to scroll horizontally.
  • wrap_soft enables word wrap, but line breaks are not included when the user submits the form. The user does not need to scroll horizontally.
  • wrap_hard enables word wrap, including line breaks when the form is submitted. The user does not need to scroll horizontally.
 
Wrap   WordWrapType Wrap() const  
Returns the word wrap setting as an integer.  
 
ClonehtmlObject FAR * Clone() const  
Returns a base-class pointer to a deep copy of the object.  
 
Print   void Print( ostream& os ) const  
Outputs the object to os.  
 
Example Use
 
See Also: Tutorial: Forms: Multi-line Text Input  
 
#include <stdio.h>  
#include <stdlib.h>  
#include <dcmicro/htmlpp/htmlpp.h>  
 
int main( void )  
{  
   htmlCgi   server ;  
   htmlPage  page( "html++ example application" ) ;  
 
   //  Create a simple form to hold our controls  
   htmlForm  form( "/cgi-bin/script" ) ;  
 
   //  Create a 5 row X 30 column text area control,  
   //  using soft word-wrapping.  
   htmlInputTextArea   area( "comment", 5, 30 ) ;  
   area.Wrap( wrap_soft ) ;  
 
   //  Initiallly populate the control with some text  
   area "This is an example of a multi-line "  
          "text input control. Soft wrapping means "  
          "word wrap is enabled, but line breaks "  
          "won't be included in the value when the "  
          "form is submitted." ;  
 
   //  Include a submit button to be complete  
   form << htmlCenter( area )  
        << htmlParagraph()   
        << htmlCenter( htmlInputSubmit() ) ;  
 
   page << form ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
<FORM ACTION="/cgi-bin/script" METHOD="POST">  
<CENTER>  
<TEXTAREA NAME="comment" ROWS="5" COLS="30" WRAP="SOFT">This is an example of a multi-line text input control. Soft wrapping means word wrap is enabled, but line breaks won't be included in the value when the form is submitted.</TEXTAREA>  
</CENTER><P></P>  
<CENTER><INPUT TYPE="SUBMIT"></CENTER></FORM>  
</BODY>  
</HTML>  
 
 
textarea.gif  




©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.