Gtk2::Ex::MindMapView::BorderFactory - Maker of standard border items.


Gtk2-Ex-MindMapView documentation Contained in the Gtk2-Ex-MindMapView distribution.

Index


Code Index:

NAME

Top

Gtk2::Ex::MindMapView::BorderFactory - Maker of standard border items.

VERSION

Top

This document describes Gtk2::Ex::MindMapView::BorderFactory version 0.0.1

SYNOPSIS

Top

use Gtk2::Ex::MindMapView::BorderFactory;

DESCRIPTION

Top

This factory makes borders for mind map view items. The following types of borders are currently supported:

Gtk2::Ex::MindMapView::Border::RoundedRect - A rounded rectangle border.

Gtk2::Ex::MindMapView::Border::Rectangle - A rectangular border.

Gtk2::Ex::MindMapView::Border::Ellipse - An ellipse shaped border.

INTERFACE

Top

Properties

'view' (Gtk2::Ex::MindMapView)

The canvas on which the border will be drawn.

'type' (string)

The type of border to draw (see above).

'content' (Gtk2::Ex::MindMapView::Content)

The content to be placed in the border.

'fill_color_gdk' (Gtk2::Gdk::Color)

The color of the interior of the border.

'outline_color_gdk' (Gtk2::Gdk::Color)

The color of the border outline.

Methods

new (view=$view, ...)>

Constructor for this factory. Pass in a Gtk2::Ex::MindMapView argument.

create_border (type=$border_type, content=>$content, ...)>

Creates a new Gtk2::Ex::MindMapView::Border border with the specified content.

DIAGNOSTICS

Top

Invalid Gtk2::Ex::MindMapView argument.

The 'view' parameter must be a Gtk2::Ex::MindMapView.

Invalid content. 'content' parameter must be 'Gtk2::Ex::MindMapView::Content')

The only content types that subclass 'Gtk2::Ex::MindMapView::Content' are permitted.

Unexpected border type: $type

Only the border types listed above are currently supported.

DEPENDENCIES

Top

None.

BUGS AND LIMITATIONS

Top

No bugs have been reported.

Please report any bugs or feature requests to bug-gtk2-ex-mindmapview@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR

Top

James Muir <hemlock@vtlink.net>

LICENCE AND COPYRIGHT

Top

DISCLAIMER OF WARRANTY

Top

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


Gtk2-Ex-MindMapView documentation Contained in the Gtk2-Ex-MindMapView distribution.

package Gtk2::Ex::MindMapView::BorderFactory;

our $VERSION = '0.000001';

use warnings;
use strict;
use Carp;

use Gtk2::Ex::MindMapView::Border::Ellipse;
use Gtk2::Ex::MindMapView::Border::Rectangle;
use Gtk2::Ex::MindMapView::Border::RoundedRect;

use Gtk2::Ex::MindMapView::ArgUtils;

use List::Util;

use Glib ':constants';

sub new
{
    my $class = shift(@_);

    my @attributes = @_;

    my $self = {};

    bless $self, $class;

    my %attributes = @attributes;

    args_valid(\%attributes, qw(view fill_color_gdk outline_color_gdk));

    args_required(\%attributes, qw(view));

    args_store($self, \%attributes);

    if (!($self->{view}->isa('Gtk2::Ex::MindMapView')))
    {
	carp "Invalid Gtk2::Ex::MindMapView argument.\n";
    }

    arg_default($self, "fill_color_gdk", Gtk2::Gdk::Color->parse('white'));

    arg_default($self, "outline_color_gdk", Gtk2::Gdk::Color->parse('gray'));

    return $self;
}


sub create_border
{
    my ($self, @attributes) = @_;

    my %attributes = @attributes;

    args_valid(\%attributes, qw(type content fill_color_gdk outline_color_gdk));

    args_required(\%attributes, qw(type content));

    my $content = $attributes{content};

    if (!$content->isa('Gtk2::Ex::MindMapView::Content'))
    {
	croak "Invalid content. 'content' parameter must be a 'Gtk2::Ex::MindMapView::Content'.\n";
    }

    my $type              = $attributes{type};

    my $fill_color_gdk    = (defined $attributes{fill_color_gdk}) ?
	                     $attributes{fill_color_gdk} : $self->{fill_color_gdk};

    my $outline_color_gdk = (defined $attributes{outline_color_gdk}) ?
	                     $attributes{outline_color_gdk} : $self->{outline_color_gdk};

    if ($type eq 'Gtk2::Ex::MindMapView::Border::Ellipse')
    {
	return Gtk2::Ex::MindMapView::Border::Ellipse->new(
		       group=>$self->{view}->root,
		       content=>$content,
		       fill_color_gdk=>$fill_color_gdk,
		       outline_color_gdk=>$outline_color_gdk);
    }

    if ($type eq 'Gtk2::Ex::MindMapView::Border::RoundedRect')
    {
	return Gtk2::Ex::MindMapView::Border::RoundedRect->new(
		       group=>$self->{view}->root,
		       content=>$content,
		       fill_color_gdk=>$fill_color_gdk,
		       outline_color_gdk=>$outline_color_gdk);
    }


    if ($type eq 'Gtk2::Ex::MindMapView::Border::Rectangle')
    {
	return Gtk2::Ex::MindMapView::Border::Rectangle->new(
		       group=>$self->{view}->root,
		       content=>$content,
		       fill_color_gdk=>$fill_color_gdk,
		       outline_color_gdk=>$outline_color_gdk);
    }

    croak "Unexpected border type: $type\n";
}


1; # Magic true value required at end of module
__END__