|
htmlTableHeading
Table row/column heading class | [Previous] [Main] [Next] |
| htmlTableHeading encapsulates the <TH></TH> tags. It is similar to the htmlTableCell class, and is used to create data cells within rows of a table whose contents are displayed in a bolder font than those of regular table cells. It is intended for row or column headings.
| |
|
| |
| #include <dcmicro/htmlpp/tablehd.h>
| |
|
| |
| |
|
| |
| htmlTable, htmlTableRow, htmlTableCell
| |
|
| |
| ColorType
| |
|
| |
| 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 ;
| |
|
| |
| htmlTableHeading( | Alignment h_align = align_default,
| |
| VerticalAlignment v_align = valign_default )
| ||
| Constructs an empty cell heading object, using the specified horizontal and vertical alignment settings.
| |
|
| |
| htmlTableHeading( | const htmlObject& element,
| |
| Alignment h_align = align_default,
| ||
| VerticalAlignment v_align = valign_default )
| ||
| Constructs a cell heading object, adding element to it, using the specified horizontal and vertical alignment settings.
| |
|
| |
| htmlTableHeading( | const String& text,
| |
| Alignment h_align = align_default,
| ||
| VerticalAlignment v_align = valign_default )
| ||
| Constructs a cell heading object, adding text to it, using the specified horizontal and vertical alignment settings.
| |
|
| |
| htmlTableHeading( const htmlTableHeading& rhs )
| |
| Copy constructor.
| |
|
| |
| virtual ~htmlTableHeading()
| |
| Destroys the object.
| |
|
| |
| void Print( ostream& os ) const
| ||
| Outputs the cell 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( htmlHeading(3,"Employee Information") );
| |
|
| |
| // Set the table width to 95% of the display,
| |
| // and center it.
| |
| table.Width( "95%" ).Align( align_center ) ;
| |
|
| |
| // Use a border two pixels wide
| |
| table.Border( 2 ) ;
| |
|
| |
| // Add some room between each cell
| |
| // and it's border.
| |
| table.CellPadding( 10 ) ;
| |
|
| |
| // Create the column heading cells
| |
| htmlTableRow column_headings ;
| |
| column_headings << htmlTableHeading( "Name" )
| |
| << htmlTableHeading( "Phone" )
| |
| << htmlTableHeading( "City" ) ;
| |
| table << column_headings ;
| |
|
| |
| // 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 ;
| |
|
| |
| // Add each member of the array in a
| |
| // separate cell. Give each column it's
| |
| // own color.
| |
| row << htmlTableCell( emp->name ).BackgroundColor( COLOR_RED )
| |
| << htmlTableCell( emp->phone ).BackgroundColor( COLOR_GREEN )
| |
| << htmlTableCell( emp->city ).BackgroundColor( COLOR_BLUE ) ;
| |
|
| |
| // Add the new row to the table.
| |
| table << row ;
| |
| }
| |
|
| |
| // Add the newly constructed table to the page
| |
| page << table ;
| |
|
| |
| server << page ;
| |
| return 0 ;
| |
| }
| |
|
| |
|
| |
| Content-Type: text/html
| |
| <HTML>
| |
| <HEAD>
| |
| <TITLE>html++ example application</TITLE>
| |
| </HEAD>
| |
| <BODY>
| |
| <TABLE WIDTH="95%" ALIGN="CENTER" BORDER="2" CELLPADDING="10">
| |
| <CAPTION><H3>Employee Information</H3>
| |
| </CAPTION>
| |
| <TR><TH>Name</TH>
| |
| <TH>Phone</TH>
| |
| <TH>City</TH>
| |
| </TR>
| |
| <TR><TD BGCOLOR="ff0000">John Smith</TD>
| |
| <TD BGCOLOR="00ff00">245-7748</TD>
| |
| <TD BGCOLOR="0000ff">Lexington</TD>
| |
| </TR>
| |
| <TR><TD BGCOLOR="ff0000">Larry Jenkins</TD>
| |
| <TD BGCOLOR="00ff00">233-4456</TD>
| |
| <TD BGCOLOR="0000ff">Lexington</TD>
| |
| </TR>
| |
| <TR><TD BGCOLOR="ff0000">Susan Wall</TD>
| |
| <TD BGCOLOR="00ff00">294-3345</TD>
| |
| <TD BGCOLOR="0000ff">Georgetown</TD>
| |
| </TR>
| |
| </TABLE>
| |
| </BODY>
| |
| </HTML>
| |
|
| |
| |
