htmlListItem
List item class
[Previous] [Main] [Next]


Description
htmlListItem encapsulates the <LI> tag, and is used to define itemized element in a list, which is usually preceded by a bullet, a number, or a letter.  
 
htmlListItem is used in conjunction with the htmlList class, which produces ordered and unordered lists. htmlListItem objects are added to htmlList objects using htmlList::Add() or htmlList::operator<<.  
 
Declaration
#include <dcmicro/htmlpp/listitem.h>  
 
Hierarchy
htmllistitem.gif  
 
See Also
htmlList  
 
Related Constants/Definitions
typedef enum {  
   number_default = 0,  
   number_standard_arabic,   // Numbering styles  
   number_uppercase_letter,  
   number_lowercase_letter,  
   number_uppercase_roman,  
   number_lowercase_roman,  
   bullet_disc,      // Bullet styles  
   bullet_circle,  
   bullet_square  
} NumberStyle ;  
 
Constructors
htmlListItem()  
Constructs an empty list item object.  
 
htmlListItem( NumberStyle number_style = number_default )  
Constructs an empty list item using the specified number_style.  
 
htmlListItem(const htmlObject& element,  
   NumberStyle number_style = number_default )  
Constructs a list item from element, using the specified number_style.  
 
htmlListItem(const String& text,  
   NumberStyle number_style = number_default )  
Constructs a list item from text, using the specified number_style.  
 
htmlListItem( const htmlText& rhs )  
Copy constructor.  
 
Destructors
virtual ~htmlListItem()  
Destroys the object.  
 
Member Methods
=   htmlListItem& operator= ( const htmlListItem& rhs )  
Replaces object contents with rhs, and returns a reference to it.  
 
BullethtmlListItem& Bullet( NumberStyle number_style )  
Sets the type of symbol or numbering sequence to use for the list item to number_style, then returns a reference to the object.  
 
Bulletint Bullet() const  
Returns the type of symbol or numbering sequence set to use for the list item, or number_default if not set.  
 
NumberhtmlListItem& Number( int counter_value )  
Sets the counter number for the item as it will appear in an ordered list, then returns a reference to the object. This method is only applicable for for an ordered list.  
 
Numberint Number() const  
Returns the counter number for the item, or zero if not set.  
 
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>  
 
int main( void )  
{  
   htmlCgi   server ;  
   htmlPage  page( "html++ example application" ) ;  
 
   //  Create four separate lists, each one using  
   //  slightly different formatting options.  
   htmlList   list1 ;  
   list1 << htmlListItem("One", number_standard_arabic)  
         << htmlListItem("Two", number_uppercase_letter)  
         << htmlListItem("Three", number_uppercase_roman) ;  
 
   htmlList   list2 ;  
   list2 << htmlListItem( "One" ).Number(10)  
         << htmlListItem( "Two" )  
         << htmlListItem( "Three" ) ;  
 
   htmlList   list3( unordered_list ) ;  
   list3 << htmlListItem( "One" ).Bullet( bullet_disc )  
         << htmlListItem( "Two" )  
         << htmlListItem( "Three" ) ;  
 
   htmlList   list4( unordered_list ) ;  
   list4 << htmlListItem( "One" ).Bullet( bullet_square )  
         << htmlListItem( "Two" )  
         << htmlListItem( "Three" ) ;  
 
   //  Create a 2x2 table to hold the four lists  
   htmlTable  table( htmlCenter("Example use of htmlListItem") ) ;  
   table.CellPadding( 10 ) ;  
 
   //  Add the lists as cells in the rows of the table.  
   //  Note how parentheses are used to create row and  
   //  cell objects on the stack without any local  
   //  variables.  
   table << ( htmlTableRow() << list1 << list3 )  
         << ( htmlTableRow() << list2 << list4 ) ;  
 
   //  Output the table to the page  
   page << table ;  
 
   //  Display the results  
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
 
<TABLE CELLPADDING="10">  
<CAPTION><CENTER>Example use of htmlListItem</CENTER></CAPTION>  
 
<TR>  
<TD><OL><LI TYPE="1">One</LI>  
<LI TYPE="A">Two</LI>  
<LI TYPE="I">Three</LI>  
</OL>  
</TD>  
<TD><UL><LI TYPE="DISC">One</LI>  
<LI>Two</LI>  
<LI>Three</LI>  
</UL>  
</TD>  
</TR>  
 
<TR>  
<TD><OL><LI VALUE="10">One</LI>  
<LI>Two</LI>  
<LI>Three</LI>  
</OL>  
</TD>  
<TD><UL><LI TYPE="SQUARE">One</LI>  
<LI>Two</LI>  
<LI>Three</LI>  
</UL>  
</TD>  
</TR>  
 
</TABLE>  
</BODY>  
</HTML>  
 
 
listitem.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.