The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Gtk2::Ex::MindMapView - Display mind map or outline on a Gnome2::Canvas

VERSION

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

HEIRARCHY

 Glib::Object
 +----Gtk2::Object
      +----Gtk2::Widget
           +----Gtk2::Container
                +----Gtk2::Layout
                     +----Gnome2::Canvas
                          +----Gtk2::Ex::MindMapView

SYNOPSIS

#!/usr/bin/perl -w

use strict; use Gtk2 '-init'; use Gnome2::Canvas;

use Gtk2::Ex::MindMapView; use Gtk2::Ex::MindMapView::ItemFactory;

my $window = Gtk2::Window->new();

my $scroller = Gtk2::ScrolledWindow->new();

my $view = Gtk2::Ex::MindMapView->new(aa=>1);

my $factory = Gtk2::Ex::MindMapView::ItemFactory->new(view=>$view);

$view->set_scroll_region(-350,-325,350,325);

$scroller->add($view);

$window->signal_connect('destroy'=>sub { _closeapp($view); });

$window->set_default_size(900,350);

$window->add($scroller);

my $item1 = _text_item($factory, "Hello World!");

$view->add_item($item1);

my $item2 = _url_item($factory, "Google Search Engine", "http://www.google.com");

$view->add_item($item1, $item2);

my $item3 = _picture_item($factory, "./monalisa.jpeg");

$view->add_item($item1, $item3);

$view->layout();

$window->show_all();

Gtk2->main();

exit 0;

sub _closeapp { my $view = shift(@_);

    $view->destroy();

    Gtk2->main_quit();

    return 0;
}

sub _text_item { my ($factory, $text) = @_;

    my $item = $factory->create_item(border=>'Gtk2::Ex::MindMapView::Border::RoundedRect',
                                     content=>'Gtk2::Ex::MindMapView::Content::EllipsisText',
                                     text=>$text,
                                     font_desc=>Gtk2::Pango::FontDescription->from_string("Ariel Italic 8"),
                                     hotspot_color_gdk=>Gtk2::Gdk::Color->parse('lightgreen'));

    $item->signal_connect(event=>\&_test_handler);

    return $item;
}

sub _url_item { my ($factory, $text, $url) = @_;

    my $browser = '/usr/bin/firefox';

    my $item = $factory->create_item(border=>'Gtk2::Ex::MindMapView::Border::RoundedRect',
                                     content=>'Gtk2::Ex::MindMapView::Content::Uri',
                                     text=>$text, uri=>$url, browser=>$browser,
                                     text_color_gdk=>Gtk2::Gdk::Color->parse('blue'),
                                     fill_color_gdk   =>Gtk2::Gdk::Color->parse('white'));

    $item->signal_connect(event=>\&_test_handler);

    return $item;
}

sub _picture_item { my ($factory, $file) = @_;

    my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($file);

    my $item = $factory->create_item(border=>'Gtk2::Ex::MindMapView::Border::Rectangle',
                                     content=>'Gtk2::Ex::MindMapView::Content::Picture',
                                     pixbuf=>$pixbuf,
                                     hotspot_color_gdk=>Gtk2::Gdk::Color->parse('lightgreen'),
                                     fill_color_gdk   =>Gtk2::Gdk::Color->parse('white'));

    $item->signal_connect(event=>\&_test_handler);

    return $item;
}

sub _test_handler { my ($item, $event) = @_;

    my $event_type = $event->type;

    my @coords = $event->coords;

    print "Event, type: $event_type  coords: @coords\n";
}

1;

DESCRIPTION

The MindMapView draws a mind map (or outline) on a Gnome2::Canvas.

The MindMapView is an extension of the Gnome2::Canvas which is a Gtk2::Widget, so it can be placed in any Gtk2 container.

This is an alpha version of the software, the functionality is limited, and it contains BUGs. It should be used for experimentation only at this time. Interfaces will change and so will properties.

Currently the mind map is limited to a balanced display of text items. You may assign a font and change the color of the mind map items.

See the examples directory for examples of usage. You will find the synopsis example there.

The following border types are supported:

Gtk2::Ex::MindMapView::Border::RoundedRect - Displays a rounded rectangle border.

Gtk2::Ex::MindMapView::Border::Rectangle - Displays a rectangular border.

Gtk2::Ex::MindMapView::Border::Ellipse - Displays an elliptical border.

The following content types are supported:

Gtk2::Ex::MindMapView::Content::EllipsisText - Displays text with optional ellipsis (...)

Gtk2::Ex::MindMapView::Content::Picture - Displays a picture in a pixbuf.

Gtk2::Ex::MindMapView::Content::Uri - Displays a URI.

INTERFACE

Properties

'aa' (boolean : readable / writable /construct-only)

The antialiasing mode of the canvas.

'connection_color_gdk' (Gtk2::Gdk::Color : readable / writable)

The default color to apply to connection objects as they are created.

'connection_arrows' (string : readable / writable);

The type of arrow to use when creating a connection object. May be one of: 'none', 'one-way', or 'two-way'.

Methods

new(aa=>1)

Construct an anti-aliased canvas. Aliased canvases look just awful.

INIT_INSTANCE

This subroutine is called by Glib::Object::Subclass as the object is being instantiated. You should not call this subroutine directly. Leave it alone.

SET_PROPERTY

This subroutine is called by Glib::Object::Subclass to set a property value. You should not call this subroutine directly. Leave it alone.

add_item ($item)

Add the root item to the mind map. This is the node off of which all other nodes are attached. The item must be a Gtk2::Ex::MindMapView::Item.

add_item ($predecessor_item, $item)

Add an item to the mind map. The item is linked to its predecessor item. The item must be a Gtk2::Ex::MindMapView::Item.

clear()

Clear the items from the mind map.

layout()

Layout the mind map. The map is redrawn on the canvas.

predecessors ($item)

Returns an array of Gtk2::Ex::MindMapView::Items that are the items that link to the item argument you have specified. Each item in the mind map may have zero or more predecessors.

remove_item ($item)

Remove the root Gtk2::Ex::MindMapView::Item from the mind map. This item should not have any successors or predecessors.

remove_item ($predecessor_item, $item)

Remove an item from the mind map. The Gtk2::Ex::MindMapView::Item must be a successor of predecessor Gtk2::Ex::MindMapView::Item. You can think of this as removing an edge from the graph underlying the mind map. This routine makes sure that the visible connection on the canvas is removed and that the item is removed from the underlying graph.

set_root ($item)

Change the root Gtk2::Ex::MindMapView::Item in the underlying graph, and revise the visible connections in the mind map.

DIAGNOSTICS

You may only add a Gtk2::Ex::MindMapView::Item

You attempted to add something other than a Gtk2::Ex::MindMapView::Item to the mind map. The only items that may be added to the Gtk2::Ex::MindMapView are of type Gtk2::Ex::MindMapView::Item. Look at the Gtk2::Ex::MindMapView::ItemFactory to create items of type Gtk2::Ex::MindMapView::Item.

You may only add items that have a Gtk2::Ex::MindMapView::Item as predecessor

You attempted to add a predecessor item that is something other than a Gtk2::Ex::MindMapView::Item to the mind map. The only items that may be added to the Gtk2::Ex::MindMapView are of type Gtk2::Ex::MindMapView::Item. Look at the Gtk2::Ex::MindMapView::ItemFactory to create items of type Gtk2::Ex::MindMapView::Item.

You may only get the predecessors of a Gtk2::Ex::MindMapView::Item

You attempted to get predecessors of an item that is something other than a Gtk2::Ex::MindMapView::Item.

You may only remove a Gtk2::Ex::MindMapView::Item

You attempted to remove something other than a Gtk2::Ex::MindMapView::Item from the mind map. The only items that may be from to the Gtk2::Ex::MindMapView are of type Gtk2::Ex::MindMapView::Item.

You may only remove items that have a Gtk2::Ex::MindMapView::Item as predecessor

You attempted to remove an item that does not have a Gtk2::Ex::MindMapView::Item as it's predecessor.

You must remove the successors of this item prior to removing this item.

You attempted to remove an item that has successor items. A Gtk2::Ex::MindMapView::Item may only be removed once it's successors have been removed.

You may only set the root to a Gtk2::Ex::MindMapView::Item

You attempted to set root of your Gtk2::Ex::MindMapView to an item that is something other than a Gtk2::Ex::MindMapView::Item.

You may only set the root to a Gtk2::Ex::MindMapView::Item that's been added to the view.

You attempted to set root of your Gtk2::Ex::MindMapView to a Gtk2::Ex::MindMapView::Item that is not in the mind map. You must first add the item to the mind map and then set it to be the root.

You may only get the successors of a Gtk2::Ex::MindMapView::Item

You attempted to get successors of an item that is something other than a Gtk2::Ex::MindMapView::Item.

You may only set the connection color to a Gtk2::Gdk::Color

You must pass in a Gtk2::Gdk:Color in order to set the color.

You may only set the connection arrows to: 'none', 'one-way', 'two-way'

You must pass in either 'none', 'one-way' or 'two-way' for the connection arrow type.

CONFIGURATION AND ENVIRONMENT

Gtk2::Ex::MindMapView requires no configuration files or environment variables.

DEPENDENCIES

The modules in Gtk2::Ex::MindMapView depend on the following CPAN modules:

Gnome2::Canvas
Graph

Each of these modules has their own dependencies.

INCOMPATIBILITIES

This software is incompatible with older versions of libgnomecanvas. See bugs below.

BUGS AND LIMITATIONS

As of the alpha release of this software the following are known bugs:

    On resize of a Gtk2::Ex::MindMapView::Item if the cursor moves from the item to the window frame, a 'button-release' event may not occur and the layout will not be redrawn.

    On older versions of libgnomecanvas, you may receive the following error message when quitting your application or destroying the canvas:

    "nomeCanvas-CRITICAL **: file gnome-canvas.c line 3698 (gnome_canvas_request_redraw): assertion 'GNOME_IS_CANVAS (canvas)' failed during global destruction."

    This is due to a bug in the finalization process of the canvas. It attempts to redraw the screen during destruction. You get either an assertion (as shown above) or a segfault.

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

James Muir <hemlock@vtlink.net>

LICENCE AND COPYRIGHT

Copyright (c) 2006, James Muir <hemlock@vtlink.net>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY

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.