CGI::MxScreen::Layout - ancestor for layout objects


CGI-MxScreen documentation Contained in the CGI-MxScreen distribution.

Index


Code Index:

NAME

Top

CGI::MxScreen::Layout - ancestor for layout objects

SYNOPSIS

Top

 use base qw(CGI::MxScreen::Layout);

 sub init {                  # redefine initialization
     my $self = shift;
     my ($screen) = @_;
     ...
 }

 sub preamble {              # redefine pre-amble
     my $self = shift;
     ...
 }

 sub postamble {             # redefine post-amble
     my $self = shift;
     ...
 }

DESCRIPTION

Top

This class is meant to be the ancestor of all the layout objects that can be given to the CGI::MxScreen manager via the -layout argument.

In order to define your own layout, you must create a class inheriting from CGI::MxScreen::Layout and redefine the init(), preamble() and postamble() features, which do nothing by default.

Because this kind in inheritance is a specialization of some behaviour, you need to understand the various operations that get carried on, so that you may plug your layout properly.

It works as follows:

AUTHOR

Top

Raphael Manfredi <Raphael_Manfredi@pobox.com>

SEE ALSO

Top

CGI::MxScreen(3), CGI::MxScreen::Screen(3).


CGI-MxScreen documentation Contained in the CGI-MxScreen distribution.

# -*- Mode: perl -*-
#
# $Id: Layout.pm,v 0.1 2001/04/22 17:57:03 ram Exp $
#
#  Copyright (c) 1998-2001, Raphael Manfredi
#  Copyright (c) 2000-2001, Christophe Dehaudt
#  
#  You may redistribute only under the terms of the Artistic License,
#  as specified in the README file that comes with the distribution.
#
# HISTORY
# $Log: Layout.pm,v $
# Revision 0.1  2001/04/22 17:57:03  ram
# Baseline for first Alpha release.
#
# $EndLog$
#

use strict;

package CGI::MxScreen::Layout;

use Carp::Datum;
require CGI;

#
# ->make
#
# Creation routine.
#
sub make {
    DFEATURE my $f_;
    my $self = bless {}, shift;
    return DVAL $self;
}

#
# ->start_HTML
#
# Emit the HTML headers.
#
# NB: Can't call it "start_html", because if one uses CGI within heirs, that
# routine would no longer be visible (CGI exports a start_html routine).
#
sub start_HTML {
    DFEATURE my $f_;
    my $self = shift;

	print CGI::header(-nph => 0);
	print CGI::start_html(@_);

	return DVOID;
}

#
# ->end_HTML
#
# Emit the HTML trailers.
#
# NB: Can't call it "end_html", because if one uses CGI within heirs, that
# routine would no longer be visible (CGI exports an end_html routine).
#
sub end_HTML {
    DFEATURE my $f_;
    my $self = shift;

	print CGI::end_html;

	return DVOID;
}

#
# ->init
#
# Initialize yourself.
# Routine called before start_HTML() with the screen to display.
# In case of internal errors, screen may be undef.
#
# When bouncing from screen to screen, this routine may be called more than
# once, for each screen we bounce to.  In particular, the $screen variable
# may or may not be different each time.
#
sub init {
    DFEATURE my $f_;
    my $self = shift;
	my ($screen) = @_;
	### to be redefined, optionally
	return DVOID;
}

#
# ->preamble
#
# Emit layout preamble, before screen generates any output.
#
sub preamble {
    DFEATURE my $f_;
	### to be redefined, optionally
	return DVOID;
}

#
# ->postamble
#
# Emit layout postamble, after screen has generated its output.
#
sub postamble {
    DFEATURE my $f_;
	### to be redefined, optionally
	return DVOID;
}

1;