htmlParagraph
Paragraph class
[Previous] [Main] [Next]


Description
htmlParagraph encapsulates the <P></P> tags. It is used to define regions of text as a single paragraph. Most browsers add a line of vertical space after a paragraph, so htmlParagraph can also be used as a paragraph separator. The </P> end tag is often omitted by HTML writers, because the start of a new paragraph also implies the end of the previous paragraph.  
 
By default, most browsers render paragraphs using flush left alignment. According to HTML 3.0, paragraphs can also be made flush right, centered, or justified. htmlParagraph supports each of these alignment types via the Align() method.  
 
Declaration
#include <dcmicro/htmlpp/styles.h>  
 
Hierarchy
htmlparagraph.gif  
 
See Also
Text Formatting Classes in the User's Guide  
 
Related Constants/Definitions
typedef enum {  
   align_default = 0,  
   align_left,  
   align_center,  
   align_right,  
   align_justify  
} Alignment ;  
 
Constructors
htmlParagraph( Alignment align = align_default )  
Constructs an empty paragraph object using the specified alignment.  
 
htmlParagraph( const htmlObject& element, Alignment align = align_default )  
Constructs a paragraph object, inserting element into it, and using the specified alignment.  
 
htmlParagraph( const String& text, Alignment align = align_default )  
Constructs a paragraph object, inserting the string text into it, and using the specified alignment.  
 
Destructor
virtual ~htmlParagraph()  
Destroys the object.  
 
Member Methods
Align   htmlParagraph& Align( Alignment align )  
Set the paragraph alignment to align.  
 
Align   int Align() const  
Returns the current setting for paragraph alignment, or align_default 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" ) ;  
 
   String  s ;  
   s << "This is a test of the emergency broadcast "  
     << "system. If this had been an actual "  
     << "emergency,..." ;  
 
   htmlParagraph p1, p2, p3 ;  
 
   p1 << htmlItalic("Default alignment. ") << s ;  
 
   p2.Align( align_center ) ;  
   p2 << htmlItalic("Center alignment. ") << s ;  
 
   p3.Align( align_right ) ;  
   p3 << htmlItalic("Right alignment. ") << s ;  
 
   page << p1 << p2 << p3 ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
<P><I>Default alignment. </I>This is a test of the emergency broadcast system. If this had been an actual emergency,...</P>  
<P ALIGN="CENTER"><I>Center alignment. </I>This is a test of the emergency broadcast system. If this had been an actual emergency,...</P>  
<P ALIGN="RIGHT"><I>Right alignment. </I>This is a test of the emergency broadcast system. If this had been an actual emergency,...</P>  
</BODY>  
</HTML>  
 
paragraph.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.