The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Gtk2::Ex::CellRendererWrappedText - Widget for displaying and editing multi-line text entries in a TreeView

SYNOPSIS

 use Gtk2::Ex::CellRendererWrappedText;
 
 $treeview->new( $model );
 
 $cell = Gtk2::CellRender

 $cell = Gtk2::Ex::CellRendererWrappedText->new;
 
 $cell->set( editable => 1 );
 
 $cell->set( wrap_mode => 'word' );
 
 $cell->set( wrap_width => 400 );
 
 $cell->signal_connect (edited => sub {
                my ($cell, $text_path, $new_text, $model) = @_;
                my $path = Gtk2::TreePath->new_from_string ($text_path);
                my $iter = $model->get_iter ($path);
                $model->set ($iter, 1, $new_text);
        }, $model);

 $column = Gtk2::TreeViewColumn->new_with_attributes( 'Wrapped', $cell, text => 1 );
 
 $column->set_resizable( 1 );
 
 $view->append_column ($column);
 

WIDGET HIERARCHY

  Glib::Object
  +----Glib::InitiallyUnowned
       +----Gtk2::Object
            +----Gtk2::CellRenderer
                 +----Gtk2::CellRendererText
                      +----Gtk2::Ex::CellRendererWrappedText

DESCRIPTION

Gtk2::Ex::CellRendererWrappedText is a Gtk2::CellRendererText that automatically updates the wrap-width of the of the renderer so that the text always fills (or shrinks to match) the available area.

Gtk2::Ex::CellRendererWrappedText also handles editing of strings that span multiple lines. Gtk2::CellRendererText only displays multi-line strings on one line while in edit mode, regardless of the wrap-wdith of the renderer.

Pressing <Esc> whil in edit mode cancels the edit. Pressing <Ctrl+Enter> moves to the next line. Pressing <Ctrl+Enter> or focusing out of the render finishes editing and emits the 'edited' signal on the renderer.

SEE ALSO

Gtk2::CellRendererText, Gtk2::Ex::DateEntry::CellRenderer, Gtk2::Ex::TimeEntry::CellRenderer

AUTHOR

Jeffrey Hallock <jeffrey dot hallock @ gmail dot com>.

Some code adapted from Muppet's customrenderer.pl script included in the Gtk2 examples directory.

CAVEATS & BUGS

None known. Please send bugs to <jeffrey dot hallock @ gmail dot com>. Patches and suggestions welcome.

LICENSE

Gtk2-Ex-CellRendererText is Copyright 2010 Jeffrey Ray Hallock

Gtk2-Ex-CellRendererText is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Gtk2-Ex-CellRendererText is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Gtk2-Ex-DateEntry. If not, see http://www.gnu.org/licenses/.