htmlBody
Document body class
[Previous] [Main] [Next]


Description
htmlBody encapsulates the page <BODY></BODY> tags. It is used internally by the htmlPage class, which provides the htmlPage::Body() method for direct access.  
 
htmlBody provides methods to specifiy characteristics for the document. You can control foreground and background colors, active link color, visited and unvisited link colors, or specify an image to use as a tiled background.  
 
The HTML specification imposes a limit of one color per attribute for text within a document, thereby making it impossible to associate different colors for different regions of a page, or to produce words or paragraphs that differ in color. Once a color value is specified, it is applied throughout the page.  
 
Declaration
#include <dcmicro/htmlpp/body.h>  
 
Hierarchy
htmlbody.gif  
 
See Also
htmlPage, htmlHead  
 
Related Constants/Definitions
ColorType  

Constructors
htmlBody()  
Constructs an empty page body object.  
 
htmlBody( const String& background_image_url )  
Constructs a body object, using the background_image_url image as the page background.  
 
htmlBody( ColorType background_color )  
Constructs a body object, using background_color as the page background color.  
 
htmlBody( const htmlBody& rhs )  
Copy constructor.  
 
Destructors
virtual ~htmlBody()  
Destroys the object.  
 
Member Methods
BackgoundImagehtmlBody& BackgroundImage(  
      const String& background_image_url )  
Set the background image to background_image_url, then returns a reference to the object. Corresponds to the BACKGROUND attribute.  
 
BackgoundImageString BackgroundImage() const  
Returns the URL of the background image as a string.  
 
BackgoundColorhtmlBody& BackgroundColor(  
      ColorType background_color )  
Set the background color 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.  
 
BackgoundColorColorType BackgroundColor() const  
Returns the current setting for the background color, or COLOR_DEFAULT if not set.  
 
TextColor   htmlBody& TextColor(  
      ColorType text_color ) const  
Sets the text foreground color to text_color, then returns a reference to the object. If COLOR_DEFAULT is specified, the browser default color will be used, which is typically black. Corresponds to the TEXT attribute.  
 
TextColor   ColorType TextColor() const  
Returns the current setting for the text foreground color, or COLOR_DEFAULT if not set.  
 
LinkColor   htmlBody& LinkColor( ColorType link_color )  
Set the link color, the color used to display hypertext links on a page, to link_color, then returns a reference to the object. If COLOR_DEFAULT is specified, the browser default color will be used. Corresponds to the LINK attribute.  
 
LinkColor   ColorType LinkColor() const  
Returns the current setting for the link color, or COLOR_DEFAULT if not set.  
 
ActiveLinkColorhtmlBody& ActiveLinkColor( ColorType active_color )  
Set the active link color, the color shown when a user clicks on a hypertext link on a page, to active_color, then returns a reference to the object. If COLOR_DEFAULT is specified, the browser default color will be used. Corresponds to the ALINK attribute.  
 
ActiveLinkColorColorType ActiveLinkColor() const  
Returns the current setting for the active link color, or COLOR_DEFAULT if not set.  
 
VisitedLinkColorhtmlBody& VisitedLinkColor( ColorType visited_color )  
Set the visited link color, the color used to distinguish hypertext links the user has already visited, to visited_color, then returns a reference to the object. If COLOR_DEFAULT is specified, the browser default color will be used. Corresponds to the VLINK attribute.  
 
VisitedLinkColorColorType VisitedLinkColor() const  
Returns the current setting for the visited link color, or COLOR_DEFAULT if not set.  
 
Print      void Print( ostream& os ) const  
Outputs the object to os.  
 
Clone   htmlObject * 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" ) ;  
 
   //  set our background color  
   page.BackgroundColor( COLOR_BLUE ) ;  
 
   //  Use the Body() method to obtain a reference  
   //  to the body object for the page, then set  
   //  the link colors so that they'll stand out.  
   page.Body().LinkColor( COLOR_YELLOW)  
       .ActiveLinkColor( COLOR_GREEN )  
       .VisitedLinkColor( COLOR_RED );  
 
   page << htmlBreak()  
       << "This link has not yet been visited "  
        << htmlHyperLink( "http://www.espn.com",  
                          "ESPN Sports Page" )  
        << htmlParagraph() ;  
 
   page << "The following link is a different color "  
        << "because we've already visited it. "  
        << htmlBreak()  
        << htmlHyperLink( "http://www.cnn.com",  
                 "CNN Interactive" ) ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY BGCOLOR="0000ff" LINK="ffff00" ALINK="00ff00" VLINK="ff0000"><BR>  
This link has not yet been visited <A HREF="http://www.espn.com">ESPN Sports Page</A><P></P>  
The following link is a different color because we've already visited it. <BR>  
<A HREF="http://www.cnn.com">CNN Interactive</A>  
</BODY>  
</HTML>  
 
 
body.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.