htmlTableRow
Table row class
[Previous] [Main] [Next]


Description
htmlTableRow encapsulates the <TR></TR> tags. It is used to create rows within a table. Rows can contain htmlTableCell objects and htmlTableHeading objects.  
 
Declaration
#include <dcmicro/htmlpp/tablerow.h>  
 
Hierarchy
htmltablerow.gif  
 
See Also
htmlTable, htmlTableCell, htmlTableHeading  
 
Related Constants/Definitions
typedef enum {  
   align_default = 0,  
   align_left,  
   align_center,  
   align_right,  
   align_justify  
} Alignment ;  
 
typedef enum {  
   valign_default = 0,  
   valign_top = align_justify + 1,  
   valign_middle,  
   valign_bottom,  
   valign_baseline  
} VerticalAlignment ;  
 
Constructors
htmlTableRow( Alignment h_align = align_default,  
    VerticalAlignment v_align = valign_default )  
Constructs an empty row object, using the specified horizontal and vertical alignment settings.  
 
htmlTableRow( const htmlObject& element,  
    Alignment h_align = align_default,  
    VerticalAlignment v_align = valign_default )  
Constructs a row object, adding element to it as a cell, using the specified horizontal and vertical alignment settings. If element is a not a htmlTableCell or htmlTableHeading object, if will first be converted to a htmlTableCell object.  
 
htmlTableRow( const String& text,  
    Alignment h_align = align_default,  
    VerticalAlignment v_align = valign_default )  
Constructs a row object, adding text to it as a cell, using the specified horizontal and vertical alignment settings.  
 
htmlTableRow( const htmlTableRow& rhs )  
Copy constructor.  
 
Destructors
virtual ~htmlTableRow()  
Destroys the object.  
 
Member Methods
Add      virtual htmlObject FAR * Add( const htmlObject& element )  
Adds element as a cell to the row, and returns a pointer to the new object. If element is a not a htmlTableCell or htmlTableHeading object, if will first be converted to a htmlTableCell object..  
 
Add      virtual htmlObject FAR * Add( const String& text )  
Adds text as a cell to the row, and returns a pointer to the new object.  
 
Align      htmlTableRow& Align( Alignment h_align )  
Sets the horizontal alignment of the row to h_align, and returns a reference to the object.  
 
Align      int Align() const  
Returns the horizontal alignment of the row as an integer, or align_default if not set.  
 
VAlign   htmlTableRow& VAlign( VerticalAlignment v_align )  
Sets the vertical alignment of the row to v_align, and returns a reference to the object.  
 
VAlign   int VAlign() const  
Returns the vertical alignment of the row as an integer, or valign_default if not set.  
 
BackgoundColorhtmlTableRow& BackgroundColor(  
      ColorType background_color )  
Set the background color of the entire row to background_color, then returns a reference to the object. If COLOR_DEFAULT is specified, the browser default color will be used. Corresponds to the BGCOLOR attribute.  
 
BackgoundColorColorType BackgroundColor() const  
Returns the current setting for the row's background color, or COLOR_DEFAULT if not set.  
 
Print      void Print( ostream& os ) const  
Outputs the row to os.  
 
Clone   htmlObject FAR * Clone() const  
Returns a base-class pointer to a deep copy of the object.  
 
Example Use (see also: htmlListItem example)
 
#include <stdio.h>  
#include <stdlib.h>  
#include <dcmicro/htmlpp/htmlpp.h>  
 
//  Define a structure to hold data  
//  about each employee.  
typedef struct {  
   char *  name ;  
   char *  phone ;  
   char *  city ;  
} EmployeeInfo, * PEmployeeInfo ;  
 
//  Create an array of all employees  
EmployeeInfo Employee_Table[] = {  
   { "John Smith",    "245-7748""Lexington" },  
   { "Larry Jenkins""233-4456""Lexington" },  
   { "Susan Wall",    "294-3345""Georgetown" }  
} ;  
 
int main( void )  
{  
   htmlCgi   server ;  
   htmlPage  page( "html++ example application" ) ;  
 
   //  Create a table object with a centered caption  
   htmlTable   table( "Employee Information",   
                      align_center ) ;  
 
   //  Set the table width to 80% of the display  
   table.Width( "80%" ) ;  
 
   //  Use a border two pixels wide  
   table.Border( 2 ) ;  
 
   //  Loop for each element in the array  
   for ( int i = 0 ;  
         i < NUMBER_OF_ELEMENTS(Employee_Table) ;  
         i++ )  
   {  
      //  Create a pointer to the particular  
      //  array element for easier access.  
      PEmployeeInfo  emp = &Employee_Table[i] ;  
 
      //  Create a row object, specifying that  
      //  the cells in this row will be centered.  
      htmlTableRow  row ;  
      row.Align( align_center ) ;  
 
      //  Add each member of the array in a  
      //  separate cell.  
      row << htmlTableCell( emp->name )  
          << htmlTableCell( emp->phone )  
          << htmlTableCell( emp->city ) ;  
 
      //  Add the new row to the table.  
      table << row ;  
   }  
 
   //  Add the newly constructed table to the page  
   page << table ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
<TABLE WIDTH="80%" BORDER="2">  
<CAPTION>Employee Information</CAPTION>  
<TR ALIGN="CENTER"><TD>John Smith</TD>  
<TD>245-7748</TD>  
<TD>Lexington</TD>  
</TR>  
<TR ALIGN="CENTER"><TD>Larry Jenkins</TD>  
<TD>233-4456</TD>  
<TD>Lexington</TD>  
</TR>  
<TR ALIGN="CENTER"><TD>Susan Wall</TD>  
<TD>294-3345</TD>  
<TD>Georgetown</TD>  
</TR>  
</TABLE>  
</BODY>  
</HTML>  
 
table.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.