htmlHorizontalRule
Horizontal rule class
[Previous] [Main] [Next]

   
Description
htmlHorizontalRule encapsulates the <HR> tag. Horizontal rules are rendered as horizontal lines by web browsers, and are used to separate regions within document. Horizontal rules are preceded and followed by line breaks.  
 
The appearance of horizontal rules can be adjusted in several ways, and methods are provided to specify:  
  • thickness, measured in pixels
  • width, as a percentage of the display width or as pixels
  • horizontal alignment
  • shading
 
Note that the thickness, width, alignment, and shading are Netscape extensions to HTML and may not be supported by all browsers.  
 
Declaration
#include <dcmicro/htmlpp/horizrul.h>  
 
Hierarchy
htmlhorizontalrule.gif  

See Also
None.  
 
Related Constants/Definitions
typedef enum {  
   shade_solid = 0,  
   shade_shaded,  
} ShadeType ;  
 
typedef enum {  
   align_default = 0,  
   align_left,  
   align_center,  
   align_right,  
   align_justify  
} Alignment ;  
 
Constructors
htmlHorizontalRule()  
Constructs a horizontal rule using the browser's default settings.  
 
htmlHorizontalRule( int pixel_size )  
Constructs a horizontal rule using the specified pixel_size thickness.  
 
htmlHorizontalRule( Alignment align )  
Constructs a horizontal rule using the specified alignment.  
 
htmlHorizontalRule( int pixel_size, String& width_percent )  
Constructs a horizontal rule using the specified thickness pixel_size, and width as a percentage of the display.  
 
htmlHorizontalRule( int pixel_size, Alignment align )  
Constructs a horizontal rule using the specified thickness pixel_size, and alignment.  
 
htmlHorizontalRule( int pixel_size, String& width_percent, Alignment align )  
Constructs a horizontal rule using the specified thickness pixel_size, width as a percentage of the display, and alignment.  
 
htmlHorizontalRule(int pixel_size,  
      String& width_percent,  
      Alignment align,  
      ShadeType shading )  
Constructs a horizontal rule using the specified thickness pixel_size, width as a percentage of the display, alignment, and shading.  
 
Destructor
virtual ~htmlHorizontalRule()  
Destroys the object.  
 
Member Methods
Align   htmlHorizontalRule& Align( Alignment align )  
Sets the horizontal alignment to align and returns a reference to the object.  
 
Align   int Align() const  
Returns the horizontal alignment for the object, or align_default if not set.  
 
ShadehtmlHorizontalRule& Shade( ShadeType shading )  
Sets the method used by the browser to render the horizontal rule to shading (shade_solid or shade_shaded), and returns a reference to the object.  
 
ShadeShadeType Shade() const  
Returns the method specified for rendering the horizontal rule, shade_solid or shade_shaded.  
 
WidthhtmlHorizontalRule& Width( const String& percentage )  
Sets the horizontal width to as a percentage of the display size, then returns a reference to the object. The percentage argument can optionally include a percent (%) character.  
 
WidthhtmlHorizontalRule& Width( int pixels )  
Sets the horizontal width to pixels, then returns a reference to the object.  
 
WidthString Width() const  
Returns the width of the horizontal rule as a string. If the width is a percentage (instead of pixel size) value, the string will include a trailing percent (%) character. Otherwise, the string will be the equivalent of the pixel size value as text.  
 
Size   htmlHorizontalRule& Size( int pixel_size )  
Sets the thickness of the horizontal rule to pixel_size, then returns a reference to the object.  
 
Size   int Size() const  
Returns the thickness setting, in pixels, for the horizontal rule.  
 
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" ) ;  
 
   page << "Default rule" << htmlHorizontalRule() ;  
 
   htmlHorizontalRule   hr1 ;  
   hr1.Width( "50%" ).Size( 10 ) ;  
   page << "50% wide, 10 pixels thick" << hr1 ;  
 
   htmlHorizontalRule   hr2 ;  
   hr2.Width( 200 ).Shade( shade_shaded ) ;  
   page << "200 pixels wide, shaded" << hr2 ;  
 
   htmlHorizontalRule   hr3 ;  
   hr3.Shade( shade_solid ).Align( align_right ) ;  
   page << "Default width, solid, right-align" << hr3 ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
Default rule<HR>  
50% wide, 10 pixels thick<HR WIDTH="50%" SIZE="10">  
200 pixels wide, shaded<HR WIDTH="200">  
Default width, solid, right-align<HR NOSHADE ALIGN="RIGHT">  
</BODY>  
</HTML>  
 
horizrul.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.