htmlTableCaption
Table caption class
[Previous] [Main] [Next]


Description
htmlCaption encapsulates the <CAPTION></CAPTION> tags. It is used to create captions within tables.  
 
The alignment option in the constructor controls placement of the caption within the table:  
  • align_top places the caption at the top of the table (default)
  • align_bottom places the caption at the bottom of the table.
 
Declaration
#include <dcmicro/htmlpp/caption.h>  
 
Hierarchy
htmltablecaption.gif  
 
See Also
htmlTable, htmlTableRow, htmlTableCell  
 
Related Constants/Definitions
typedef enum {  
   valign_default = 0,  
   valign_top = align_justify + 1,  
   valign_middle,  
   valign_bottom,  
   valign_baseline  
} VerticalAlignment ;  
 
Constructors
htmlTableCaption( VerticalAlignment v_align = valign_default )  
Constructs an empty table caption using the specified alignment.  
 
htmlTableCaption(const htmlObject& element,  
      VerticalAlignment v_align = valign_default )  
Constructs a table caption object from element, using the specified alignment.  
 
htmlTableCaption(const String& text,  
      VerticalAlignment v_align = valign_default )  
Constructs a table caption object from text, using the specified alignment.  
 
htmlTableCaption( const htmlTableCaption& rhs )  
Copy constructor.  
 
Destructors
virtual ~htmlTableCaption()  
Destroys the object.  
 
Member Methods
Print   void Print( ostream& os ) const  
Outputs the object to os.  
 
ClonehtmlObject FAR * Clone() const  
Returns a base-class pointer to a deep copy of the object.  
 
Example Use
 
#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 caption  
   htmlTableCaption  caption( "Employee Information" ) ;  
   htmlTable   table( caption ) ;  
 
   //  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.