Displaying Multiple Columns
[Previous] [Main] [Next]

 
A transparent table can be used to display text in multiple columns. Creating such a table is trivial using html++, but could be quite cumbersome if manually coding the HTML output.  
 
The technique uses htmlTable for the table and htmlTableCell for the text columns. htmlTableRow is also used, but since we're interested in producing a columnar display, the table will have only one row.  
 
Example Use
 
#include <stdio.h>  
#include <stdlib.h>  
#include <dcmicro/htmlpp/htmlpp.h>  
 
int main( void )  
{  
   htmlCgi   server ;  
   htmlPage  page( "html++ example application" ) ;  
 
   htmlBreak     br ;  
   htmlTable     table ;  
   htmlTableCell col1 ;  
   htmlTableCell col2 ;  
 
   //  Set the spacing between the cells (columns)  
   //  to 20 pixels  
   table.CellSpacing( 20 ) ;  
 
   //  Create the left column  
   col1 << htmlBold( "Internet Affects Newspaper Sales" )   
       << br  
        << "ATLANTA, GA. The growth of the internet as a "  
           "news medium is apparently having an adverse "  
           "impact on newspaper readership. Within the "  
           "last year, several metropolitan newspaper "  
           "companies have reported declining subscription "  
           "rates, citing increased competition from "  
           "online services such as CNN.COM and "  
           "MSNBC.COM." ;  
 
   //  Create the right column  
   col2 << htmlBold( "html++ Helps Developers Create "  
                     "Dynamic Content" )  
       << br  
        << "LEXINGTON,KY. DC Micro Development, publishers "  
           "of the Crusher! Data Compression Toolkits and "  
           "other C/C++ programming libraries, have "  
           "introduced a new tool that enables programmers "  
           "to create interactive web sites using C++. "  
        << htmlItalic( "\"The C++ language offers far "  
             "greater speed and convenience than arcane "  
             "scripting languages such as Perl.\"" )  
        << " says David Cecil, president of the company. "  
        << htmlItalic( "\"Our new tool lets C++ programmers"  
             "leverage their existing investments in skills "  
             "and tools to become immediately productive "  
             "developing interactive web sites.\"" ) ;  
 
   //  Output the columns to the row, then the row to  
   //  the table. Note the alignment options for the row.  
   table << ( htmlTableRow(align_left,valign_top)   
                  << col1 << col2 ) ;  
 
   page << table ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
<TABLE CELLSPACING="20">  
<TR ALIGN="LEFT" VALIGN="TOP">  
<TD>  
<B>Internet Affects Newspaper Sales</B><BR>  
ATLANTA, GA. The growth of the internet as a news medium is apparently having an adverse impact on newspaper readership. Within the last year, several metropolitan newspaper companies have reported declining subscription rates, citing increased competition from online services such as CNN.COM and MSNBC.COM.  
</TD>  
<TD>  
<B>html++ Helps Developers Create Dynamic Content</B><BR>  
LEXINGTON, KY. DC Micro Development, publishers of the Crusher! Data Compression Toolkits and other C/C++ programming libraries, have introduced a new tool that enables programmers to create interactive web sites using C++. <I>&quot;The C++ language offers far greater speed and convenience than arcane scripting languages such as Perl.&quot;</I> says David Cecil, president of the company. <I>&quot;Our new tool lets C++ programmers leverage their existing investments in skills and tools to become immediately productive developing interactive web sites.&quot;</I>  
</TD>  
</TR>  
</TABLE>  
</BODY>  
</HTML>  
 
 

ex_columns.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.