|
htmlPage
Document page class | [Previous] [Main] [Next] |
| htmlPage encapsulates the <HTML></HTML> tags. It also manages the <HEAD></HEAD> and <BODY></BODY> tags, both of which are required for HTML documents, using htmlHead and htmlBody member objects. Member methods are provided to manipulate most head and body attributes, but their objects can also be accessed directly using the Head() and Body() methods.
| |
|
| |
| Meta information for pages, such as keywords, description, copyright, and HTTP response headers belong within the <HEAD></HEAD> tags. Such information can be added by inserting htmlMeta objects to the head object via the Head() method.
| |
|
| |
| Only one htmlPage object is required for each document page. Pages can contain any number or type of html++ objects. Objects are inserted into a page using the << insertion operator or the Add() method.
| |
|
| |
| Once constructed in memory, pages and their contents are output using the << streaming output operator. Output is typically directed to cout, but can also be directed to any C++ ostream-compatible object, including files or the html++ String class.
| |
|
| |
| When page objects are constucted, the OutputType parameter may be set to either page_cgi or page_non_cgi. If page_cgi is specified, the page contents will be prececeded by "Content-Type: text/html" during output.
| |
|
| |
| The HTML specification prohibits the use of <BODY> and <FRAMESET> tags within the same document. Framesets define the placement and dimensions of frames, and are created using the htmlFrameSet class. The only place a htmlFrameSet object can be used is in a unique kind of page, called a frameset definition document. Such a document lacks the usual htmlBody section, and has in it's place one or more htmlFrameSet objects, which in turn contain one or more htmlFrame objects that reference specific URL's.
| |
|
| |
| The htmlPage class is smart with respect to framesets. If any htmlFrameSet objects are added directly to it, htmlPage will omit the internal htmlBody object when outputting it's contents via the Print() method or << streaming output operator.
| |
|
| |
| #include <dcmicro/htmlpp/page.h>
| |
|
| |
|
| |
| htmlBody, htmlHead, htmlMeta, htmlFrameSet
| |
|
| |
| Advanced Topics : Redirecting Browsers to Another Page in the User's Guide
| |
|
| |
| typedef enum {
| |
| page_cgi = 0, // Include Content-Type header in output (normal)
| |
| page_non_cgi
| |
| } OutputType ;
| |
|
| |
| htmlPage( OutputType page_type = page_cgi )
| |
| Constructs an empty page object using the specified page output type. If page_cgi is specified, html++ will output "Content-Type: text/html" before outputting HTML code for the page.
| |
|
| |
| htmlPage( ColorType background_color, OutputType page_type = page_cgi )
| |
| Constructs an empty page object, setting the specified background color and page output type.
| |
|
| |
| htmlPage( const String& title, OutputType page_type = page_cgi )
| |
| Constructs an empty page object, setting the document title to title, and setting the specified page output type..
| |
|
| |
| htmlPage( | const String& title,
| |
| const String& background_image_url,
| ||
| OutputType page_type = page_cgi )
| ||
| Constructs an empty page object, setting the background image and page output type to the specified settings.
| |
|
| |
| htmlPage( | const String& title,
| |
| ColorType background_color,
| ||
| OutputType page_type = page_cgi )
| ||
| Constructs an empty page object, setting the background color and page output type to the specified settings.
| |
|
| |
| htmlPage( const htmlPage& rhs )
| |
| Copy constructor.
| |
|
| |
| virtual ~htmlPage()
| |
| Destroys the object.
| |
|
| |
| = | htmlPage& operator= ( const htmlPage& rhs )
| |
| Replaces object contents with rhs, and returns a reference to it.
| |
|
| |
| << | htmlPage& operator<< ( const htmlObject& element )
| |
| Adds the element object to the page and returns a reference to the page.
| |
|
| |
| << | htmlPage& operator<< ( const String& text )
| |
| Adds the text string to the page and returns a reference to the page.
| |
|
| |
| Add | htmlObject * Add( const htmlObject& element )
| |
| Adds element to the group and returns a pointer to the new object. If element is an htmlFrameSet object, an internal flag is set causing the page to become a frameset definition document.
| |
|
| |
| Add | htmlObject * Add( const String& text )
| |
| Adds text to the group and returns a pointer to the new object.
| |
|
| |
| Title | htmlPage& Title( const String& title )
| |
| Sets the page title to title, then returns a reference to the object. This method uses the underlying htmlHead member object.
| |
|
| |
| Title | String& Title() const
| |
| Returns the page title as a string, or an empty string if not set.
| |
|
| |
| BackgroundImage | htmlPage& BackgroundImage(
| |
| const String& background_image_url )
| ||
| Sets the background image for the page to background_image_url, then returns a reference to the object. This method uses the underlying htmlBody member object.
| |
|
| |
| BackgroundImage | String& BackgroundImage() const
| |
| Returns the background image URL as a string, or an empty string if not set.
| |
|
| |
| BackgroundColor | htmlPage& BackgroundColor(
| |
| ColorType background )
| ||
| Sets the background color for the page to background_color, then returns a reference to the object. This method uses the underlying htmlBody member object.
| |
|
| |
| BackgroundColor | ColorType BackgroundColor() const
| |
| Returns the background color setting for the page, or COLOR_DEFAULT if not set.
| |
|
| |
| TextColor | htmlPage& TextColor( ColorType text_color )
| |
| Sets the page 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. This method uses the underlying htmlBody member object.
| |
|
| |
| TextColor | ColorType TextColor() const
| |
| Returns the current setting for the text foreground color, or COLOR_DEFAULT if not set.
| |
|
| |
| PageType | htmlPage& PageType( OutputType page_type )
| |
| Sets the output type for the page to page_type (page_cgi or page_non_cgi), then returns a reference to the object. If page_cgi is specified, html++ will output "Content-Type: text/html" before outputting HTML code for the page.
| |
|
| |
| PageType | OutputType PageType() const
| |
| Returns the page output type, page_cgi or page_non_cgi.
| |
|
| |
| Head | htmlHead& Head()
| |
| Returns a reference to the htmlHead object for the page.
| |
|
| |
| Body | htmlBody& Body()
| |
| Returns a reference to the htmlBody object for the page.
| |
|
| |
| Header | String& Header()
| |
| Returns a reference to a string used to store optional headers for the the page. Such headers are transmitted before the document contents. See Advanced Topics: Redirecting Browsers to Another Page for additional information.
| |
|
| |
| NoHTML | htmlCookie& NoHTML( Boolean omit_html_tags = TRUE )
| |
| If omit_html_tags is TRUE, the page will not include the <HTML></HTML> tags when outputting it's contents.
| |
|
| |
| NoHead | htmlCookie& NoHead( Boolean omit_head_section = TRUE )
| |
| If omit_head_section is TRUE, the page will not include the <HEAD></HEAD> tags, or their contents, when outputting it's contents.
| |
|
| |
| NoBody | htmlCookie& NoBody( Boolean omit_body_section = TRUE )
| |
| If omit_body_section is TRUE, the page will not include the <BODY></BODY> tags, or their contents, when outputting it's contents.
| |
|
| |
| void Print( ostream& os ) const
| ||
| Outputs the object to os.
| |
|
| |
| Clone | htmlObject FAR * Clone() const
| |
| Returns a base-class pointer to a deep copy of the object.
| |
|
| |
|
| |
| #include <stdio.h>
| |
| #include <stdlib.h>
| |
| #include <dcmicro/htmlpp/htmlpp.h>
| |
|
| |
| int main( void )
| |
| {
| |
| htmlCgi server ;
| |
| htmlPage page( "html++ example application" ) ;
| |
|
| |
| // Set the page background and text colors
| |
| page.BackgroundColor( COLOR_YELLOW ) ;
| |
| page.TextColor( COLOR_GREEN ) ;
| |
|
| |
| // Access the underlying body object to
| |
| // set the link colors.
| |
| page.Body().LinkColor( COLOR_RED ) ;
| |
|
| |
| page << "This is a dmonstration of using the "
| |
| << "htmlPage class."
| |
| << htmlBreak() ;
| |
|
| |
| // Add a hypertext link
| |
| page << htmlHyperLink( "http://www.dcmicro.com",
| |
| "DC Micro Development home page" ) ;
| |
|
| |
| server << page ;
| |
| return 0 ;
| |
| }
| |
|
| |
|
| |
| Content-Type: text/html
| |
| <HTML>
| |
| <HEAD>
| |
| <TITLE>html++ example application</TITLE>
| |
| </HEAD>
| |
| <BODY BGCOLOR="ffff00" TEXT="00ff00" LINK="ff0000">
| |
| This is a dmonstration of using the htmlPage class.<BR>
| |
| <A HREF="http://www.dcmicro.com">DC Micro Development home page</A>
| |
| </BODY>
| |
| </HTML>
| |
|
| |
|
| |
| |
