|
htmlTableCell
Table cell class | [Previous] [Main] [Next] |
| htmlTableCell encapsulates the <TD></TD> tags. It is used to create data cells within rows of a table. htmlTableCell objects can contain any other html++ object, including other tables. To construct a table, htmlTableCell objects are inserted into htmlTableRow objects, which are in turn inserted in htmlTable objects. Multiple cells in a row constitute columns in a table.
| |
|
| |
| You can set the background color of a cell using the BackgroundColor() method. Setting the background color of a cell overrides any color setting for the row or table in which it appears.
| |
|
| |
| Cell spacing is controlled by the table containing the cells. The htmlTable::CellSpacing() method lets you specify the distance between cells, while the htmlTable::CellPadding() method lets you contol the distance between the cell border and it's contents. All cells in a table share the same padding and spacing attributes.
| |
|
| |
| The Align() and VAlign() methods control horizontal and vertical alignment of the cell contents, respectively. These method override alignment settings for the row and table in which the cell appears.
| |
|
| |
| If a cell contains no data, it will be rendered as completely empty -- no background color, content, or border -- despite whatever settings are in place for the table. If you want an empty cell to look like other cells in a table, you must put something in it (such as htmlLiteral(" ") ).
| |
|
| |
| In some cases, you may want a cell to occupy more than one column or row. To accomplish that, use the ColumnSpan() and RowSpan() methods.
| |
|
| |
| Normally, text within cells automatically wraps to the next line if it's too wide for the cell. You can use the EnableWrap() method to enable or disable this feature.
| |
|
| |
| #include <dcmicro/htmlpp/tablecel.h>
| |
|
| |
| |
|
| |
| htmlTable, htmlTableRow, htmlTableHeading
| |
|
| |
| 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 ;
| |
|
| |
| htmlTableCell( | Alignment h_align = align_default,
| |
| VerticalAlignment v_align = valign_default )
| ||
| Constructs an empty cell object, using the specified horizontal and vertical alignment settings.
| |
|
| |
| htmlTableCell( | const htmlObject& element,
| |
| Alignment h_align = align_default,
| ||
| VerticalAlignment v_align = valign_default )
| ||
| Constructs a cell object, adding element to it, using the specified horizontal and vertical alignment settings.
| |
|
| |
| htmlTableCell( | const String& text,
| |
| Alignment h_align = align_default,
| ||
| VerticalAlignment v_align = valign_default )
| ||
| Constructs a cell object, adding text to it, using the specified horizontal and vertical alignment settings.
| |
|
| |
| htmlTableCell( const htmlTableCell& rhs )
| |
| Copy constructor.
| |
|
| |
| virtual ~htmlTableCell()
| |
| Destroys the object.
| |
|
| |
| Align | htmlTableCell& Align( Alignment h_align )
| |
| Sets the horizontal alignment of the cell to h_align, and returns a reference to the object.
| |
|
| |
| Align | int Align() const
| |
| Returns the horizontal alignment of the cell as an integer, or align_default if not set.
| |
|
| |
| VAlign | htmlTableCell& VAlign( VerticalAlignment v_align )
| |
| Sets the vertical alignment of the cell to v_align, and returns a reference to the object.
| |
|
| |
| VAlign | int VAlign() const
| |
| Returns the vertical alignment of the cell as an integer, or valign_default if not set.
| |
|
| |
| BackgoundColor | htmlTableCell& BackgroundColor(
| |
| ColorType background_color )
| ||
| Set the background color of the cell 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.
| |
|
| |
| BackgoundColor | ColorType BackgroundColor() const
| |
| Returns the current setting for the cell's background color, or COLOR_DEFAULT if not set.
| |
|
| |
| ColumnSpan | htmlTableCell& ColumnSpan( int span )
| |
| Sets the number of columns the cell will occupy to span, and returns a reference to the object. Values less than 1 clear the attribute.
| |
|
| |
| ColumnSpan | int ColumnSpan() const
| |
| Returns the number of columns the cell is set to occupy as an integer (default = 1 ).
| |
|
| |
| RowSpan | htmlTableCell& RowSpan( int span )
| |
| Sets the number of rows the cell will occupy to span, and returns a reference to the object. Values less than 1 clear the attribute.
| |
|
| |
| RowSpan | int RowSpan() const
| |
| Returns the number of rows the cell is set to occupy as an integer (default = 1 ).
| |
|
| |
| WrapEnable | htmlTableCell& WrapEnable( Boolean enable = TRUE )
| |
| Sets the word-wrap for the cell, and returns a reference to the object. If enable is TRUE (the default), words will automatically wrap within the cell boundary. If enable is FALSE, words will not wrap.
| |
|
| |
| IsWrapEnabled | Boolean IsWrapEnabled() const
| |
| Returns TRUE if the cell wrap feature is enabled, FALSE otherwise.
| |
|
| |
| Height | htmlTableCell& Height( int pixels )
| |
| Sets the height of the cell to pixels, and returns a reference to the object. If pixels is a negative value, the attribute is cleared.
| |
|
| |
| Height | int Height() const
| |
| Returns the height of the cell in pixels, or zero if not set.
| |
|
| |
| Width | htmlTableCell& Width( int pixels )
| |
| Sets the width of the cell to pixels, and returns a reference to the object. If pixels is a negative value, the attribute is cleared.
| |
|
| |
| Width | int Width() const
| |
| Returns the width of the cell in pixels, or zero if not set.
| |
|
| |
| 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.
| |
|
| |
|
| |
| #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
| |
| htmlTable table( "Employee Information" ) ;
| |
|
| |
| // 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 ;
| |
| }
| |
|
| |
|
| |
| 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>
| |
|
| |
| |
