<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">###############################################################################
#
#   Package: NaturalDocs::Builder::FramedHTML
#
###############################################################################
#
#   A package that generates output in HTML with frames.
#
#   All functions are called with Package-&gt;Function() notation.
#
###############################################################################

# This file is part of Natural Docs, which is Copyright (C) 2003-2008 Greg Valure
# Natural Docs is licensed under the GPL


use strict;
use integer;

package NaturalDocs::Builder::FramedHTML;

use base 'NaturalDocs::Builder::HTMLBase';


###############################################################################
# Group: Implemented Interface Functions


#
#   Function: INIT
#
#   Registers the package with &lt;NaturalDocs::Builder&gt;.
#
sub INIT
    {
    NaturalDocs::Builder-&gt;Add(__PACKAGE__);
    };


#
#   Function: CommandLineOption
#
#   Returns the option to follow -o to use this package.  In this case, "html".
#
sub CommandLineOption
    {
    return 'FramedHTML';
    };


#
#   Function: BuildFile
#
#   Builds the output file from the parsed source file.
#
#   Parameters:
#
#       sourcefile       - The &lt;FileName&gt; of the source file.
#       parsedFile      - An arrayref of the source file as &lt;NaturalDocs::Parser::ParsedTopic&gt; objects.
#
sub BuildFile #(sourceFile, parsedFile)
    {
    my ($self, $sourceFile, $parsedFile) = @_;

    my $outputFile = $self-&gt;OutputFileOf($sourceFile);


    # 99.99% of the time the output directory will already exist, so this will actually be more efficient.  It only won't exist
    # if a new file was added in a new subdirectory and this is the first time that file was ever parsed.
    if (!open(OUTPUTFILEHANDLE, '&gt;' . $outputFile))
        {
        NaturalDocs::File-&gt;CreatePath( NaturalDocs::File-&gt;NoFileName($outputFile) );

        open(OUTPUTFILEHANDLE, '&gt;' . $outputFile)
            or die "Couldn't create output file " . $outputFile . "\n";
        };

    print OUTPUTFILEHANDLE



        # IE 6 doesn't like any doctype here at all.  Add one (strict or transitional doesn't matter) and it makes the page slightly too
        # wide for the frame.  Mozilla and Opera handle it like champs either way because they Don't Suck(tm).

        # '&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" '
        # . '"http://www.w3.org/TR/REC-html40/loose.dtd"&gt;' . "\n\n"

        '&lt;html&gt;&lt;head&gt;'

            . (NaturalDocs::Settings-&gt;CharSet() ?
                '&lt;meta http-equiv="Content-Type" content="text/html; charset=' . NaturalDocs::Settings-&gt;CharSet() . '"&gt;' : '')

            . '&lt;title&gt;'
                . $self-&gt;BuildTitle($sourceFile)
            . '&lt;/title&gt;'

            . '&lt;link rel="stylesheet" type="text/css" href="' . $self-&gt;MakeRelativeURL($outputFile, $self-&gt;MainCSSFile(), 1) . '"&gt;'

            . '&lt;script language=JavaScript src="' . $self-&gt;MakeRelativeURL($outputFile, $self-&gt;MainJavaScriptFile(), 1) . '"&gt;&lt;/script&gt;'

        . '&lt;/head&gt;&lt;body class="FramedContentPage" onLoad="NDOnLoad()"&gt;'
            . $self-&gt;OpeningBrowserStyles()

            . $self-&gt;StandardComments()

            . "\n\n\n"
                . $self-&gt;BuildContent($sourceFile, $parsedFile)
            . "\n\n\n"

            . $self-&gt;BuildToolTips()

            . $self-&gt;ClosingBrowserStyles()
        . '&lt;/body&gt;&lt;/html&gt;';


    close(OUTPUTFILEHANDLE);
    };


#
#   Function: BuildIndex
#
#   Builds an index for the passed type.
#
#   Parameters:
#
#       type  - The &lt;TopicType&gt; to limit the index to, or undef if none.
#
sub BuildIndex #(type)
    {
    my ($self, $type) = @_;

    my $indexTitle = $self-&gt;IndexTitleOf($type);
    my $indexFile = $self-&gt;IndexFileOf($type);

    my $startIndexPage =

        '&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" '
            . '"http://www.w3.org/TR/REC-html40/loose.dtd"&gt;' . "\n\n"

        . '&lt;html&gt;&lt;head&gt;'

            . (NaturalDocs::Settings-&gt;CharSet() ?
                '&lt;meta http-equiv="Content-Type" content="text/html; charset=' . NaturalDocs::Settings-&gt;CharSet() . '"&gt;' : '')

            . '&lt;title&gt;';

            if (defined NaturalDocs::Menu-&gt;Title())
                {  $startIndexPage .= $self-&gt;StringToHTML(NaturalDocs::Menu-&gt;Title()) . ' - ';  };

                $startIndexPage .=
                $indexTitle
            . '&lt;/title&gt;'

            . '&lt;link rel="stylesheet" type="text/css" href="' . $self-&gt;MakeRelativeURL($indexFile, $self-&gt;MainCSSFile(), 1) . '"&gt;'

            . '&lt;script language=JavaScript src="' . $self-&gt;MakeRelativeURL($indexFile, $self-&gt;MainJavaScriptFile(), 1) . '"&gt;&lt;/script&gt;'

        . '&lt;/head&gt;&lt;body class="FramedIndexPage" onLoad="NDOnLoad()"&gt;'
            . $self-&gt;OpeningBrowserStyles()

            . "\n\n\n"
                . $self-&gt;StandardComments()
            . "\n\n\n"
                . '&lt;div id=Index&gt;'
                    . '&lt;div class=IPageTitle&gt;'
                        . $indexTitle
                    . '&lt;/div&gt;';


    my $endIndexPage =

                    '&lt;/div&gt;&lt;!--Index--&gt;'
                . "\n\n\n"

                . $self-&gt;ClosingBrowserStyles()

       . '&lt;/body&gt;&lt;/html&gt;';

    my $startSearchResultsPage =

        '&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" '
            . '"http://www.w3.org/TR/REC-html40/loose.dtd"&gt;' . "\n\n"

        . '&lt;html&gt;&lt;head&gt;'

            . (NaturalDocs::Settings-&gt;CharSet() ?
                '&lt;meta http-equiv="Content-Type" content="text/html; charset=' . NaturalDocs::Settings-&gt;CharSet() . '"&gt;' : '')

            . '&lt;link rel="stylesheet" type="text/css" href="' . $self-&gt;MakeRelativeURL($indexFile, $self-&gt;MainCSSFile(), 1) . '"&gt;'

            . '&lt;script language=JavaScript src="' . $self-&gt;MakeRelativeURL($indexFile, $self-&gt;MainJavaScriptFile(), 1) . '"&gt;&lt;/script&gt;'
            . '&lt;script language=JavaScript src="' . $self-&gt;MakeRelativeURL($indexFile, $self-&gt;SearchDataJavaScriptFile(), 1) . '"&gt;'
                . '&lt;/script&gt;'

        . '&lt;/head&gt;&lt;body class="FramedSearchResultsPage" onLoad="NDOnLoad()"&gt;'
            . $self-&gt;OpeningBrowserStyles()

            . "\n\n\n"
                . $self-&gt;StandardComments()
            . "\n\n\n"

                . '&lt;div id=Index&gt;'
                    . '&lt;div class=IPageTitle&gt;'
                        . 'Search Results'
                    . '&lt;/div&gt;';

    my $endSearchResultsPage =

                    '&lt;/div&gt;&lt;!--Index--&gt;'
                . "\n\n\n"

                . $self-&gt;ClosingBrowserStyles()

       . '&lt;/body&gt;&lt;/html&gt;';

    my $indexContent = NaturalDocs::SymbolTable-&gt;Index($type);
    my $pageCount = $self-&gt;BuildIndexPages($type, $indexContent, $startIndexPage, $endIndexPage,
                                                                  $startSearchResultsPage, $endSearchResultsPage);
    $self-&gt;PurgeIndexFiles($type, $indexContent, $pageCount + 1);
    };


#
#   Function: UpdateMenu
#
#   Builds the menu file.  Also generates index.html.
#
sub UpdateMenu
    {
    my $self = shift;

    my $outputDirectory = NaturalDocs::Settings-&gt;OutputDirectoryOf($self);
    my $outputFile = NaturalDocs::File-&gt;JoinPaths($outputDirectory, 'menu.html');


    open(OUTPUTFILEHANDLE, '&gt;' . $outputFile)
        or die "Couldn't create output file " . $outputFile . "\n";

    my $title = 'Menu';
    if (defined $title)
        {  $title .= ' - ' . NaturalDocs::Menu-&gt;Title();  };

    $title = $self-&gt;StringToHTML($title);


    print OUTPUTFILEHANDLE


        '&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" '
            . '"http://www.w3.org/TR/REC-html40/loose.dtd"&gt;' . "\n\n"

        . '&lt;html&gt;&lt;head&gt;'

            . (NaturalDocs::Settings-&gt;CharSet() ?
                '&lt;meta http-equiv="Content-Type" content="text/html; charset=' . NaturalDocs::Settings-&gt;CharSet() . '"&gt;' : '')

            . '&lt;title&gt;'
                . $title
            . '&lt;/title&gt;'

            . '&lt;base target="Content"&gt;'

            . '&lt;link rel="stylesheet" type="text/css" href="' . $self-&gt;MakeRelativeURL($outputFile, $self-&gt;MainCSSFile(), 1) . '"&gt;'

            . '&lt;script language=JavaScript src="' . $self-&gt;MakeRelativeURL($outputFile, $self-&gt;MainJavaScriptFile(), 1) . '"&gt;&lt;/script&gt;'
            . '&lt;script language=JavaScript src="' . $self-&gt;MakeRelativeURL($outputFile, $self-&gt;SearchDataJavaScriptFile(), 1) . '"&gt;'
                . '&lt;/script&gt;'

        . '&lt;/head&gt;&lt;body class="FramedMenuPage" onLoad="NDOnLoad()"&gt;'
            . $self-&gt;OpeningBrowserStyles()

            . $self-&gt;StandardComments()

            . "\n\n\n"
                . $self-&gt;BuildMenu(undef, undef)
            . "\n\n\n"
                . $self-&gt;BuildFooter(1)
            . "\n\n\n"

            . $self-&gt;ClosingBrowserStyles()
        . '&lt;/body&gt;&lt;/html&gt;';


    close(OUTPUTFILEHANDLE);


    # Update index.html

    my $firstMenuEntry = $self-&gt;FindFirstFile();
    my $indexFile = NaturalDocs::File-&gt;JoinPaths( NaturalDocs::Settings-&gt;OutputDirectoryOf($self), 'index.html' );

    # We have to check because it's possible that there may be no files with Natural Docs content and thus no files on the menu.
    if (defined $firstMenuEntry)
        {
        open(INDEXFILEHANDLE, '&gt;' . $indexFile)
            or die "Couldn't create output file " . $indexFile . ".\n";

        print INDEXFILEHANDLE

            '&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" '
                . '"http://www.w3.org/TR/REC-html40/frameset.dtd"&gt;'

            . '&lt;html&gt;'

                . '&lt;head&gt;'

                    . (NaturalDocs::Settings-&gt;CharSet() ?
                        '&lt;meta http-equiv="Content-Type" content="text/html; charset=' . NaturalDocs::Settings-&gt;CharSet() . '"&gt;' : '')

                    . '&lt;title&gt;'
                        . $self-&gt;StringToHTML(NaturalDocs::Menu-&gt;Title())
                    . '&lt;/title&gt;'

                . '&lt;/head&gt;'

                . $self-&gt;StandardComments()

                . '&lt;frameset cols="185,*"&gt;'
                    . '&lt;frame name=Menu src="menu.html"&gt;'
                    . '&lt;frame name=Content src="'
                        . $self-&gt;MakeRelativeURL($indexFile, $self-&gt;OutputFileOf($firstMenuEntry-&gt;Target()), 1) . '"&gt;'
                . '&lt;/frameset&gt;'

                . '&lt;noframes&gt;'
                    . 'This documentation was designed for use with frames.  However, you can still use it by '
                    . '&lt;a href="menu.html"&gt;starting from the menu page&lt;/a&gt;.'
                    . "&lt;script language=JavaScript&gt;&lt;!--\n"
                        . 'location.href="menu.html";'
                    . "\n// --&gt;&lt;/script&gt;"
                . '&lt;/noframes&gt;'

            . '&lt;/html&gt;';

        close INDEXFILEHANDLE;
        }

    elsif (-e $indexFile)
        {
        unlink($indexFile);
        };
    };


1;
</pre></body></html>