NAME
Gtk2::Ex::DateSpinner::CellRenderer -- date cell renderer with DateSpinner for editing
SYNOPSIS
use Gtk2::Ex::DateSpinner::CellRenderer;
my $renderer = Gtk2::Ex::DateSpinner::CellRenderer->new;
$treeviewcolumn->pack_start ($renderer, 0);
$treeviewcolumn->add_attribute ($renderer, text => 0);
$renderer->signal_connect (edited => sub { ... });
WIDGET HIERARCHY
Gtk2::Ex::DateSpinner::CellRenderer
is a subclass of Gtk2::CellRendererText
.
Gtk2::Object
Gtk2::CellRenderer
Gtk2::CellRendererText
Gtk2::Ex::DateSpinner::CellRenderer
DESCRIPTION
DateSpinner::CellRenderer
is a cell renderer for use in a viewer widget like Gtk2::TreeView
. It displaying an ISO format YYYY-MM-DD date as a text field. Editing the field presents a popup Gtk2::Ex::DateSpinner
and a Gtk2::Entry
.
The popup allows mouse clicks or arrow keys to increment or decrement the date components. This is good if you often just want to bump a date up or down a bit, and if you're displaying YYYY-MM-DD it makes sense to present it like that for editing. Of course there's a huge range of other ways you could display or edit a date, this is merely one.
Details
The date to edit is taken from the renderer text
property and must be in YYYY-MM-DD format. The new edited value is passed to the edited
signal emitted on the renderer in the usual way (see Gtk2::CellRenderer). Text renderer properties affect the display. xalign
is copied to the Entry widget to have it left, right or centred while editing the same as displayed (like CellRendererText does).
Pressing Return in the fields accepts the values. Pressing Escape cancels the edit. Likewise the Ok and Cancel button widgets. The stock accelerators activate the buttons too, eg. Alt-O and Alt-C in an English locale, though Return and Escape are much easier to remember.
Note you must set the editable
property (per the base Gtk2::CellRendererText
) to make the DateSpinner::CellRenderer editable, otherwise nothing happens when you click. That property can be controlled by the usual model column or data function mechanisms to have some rows editable and others not.
FUNCTIONS
$renderer = Gtk2::Ex::DateSpinner::CellRenderer->new (key=>value,...)
-
Create and return a new DateSpinner::CellRenderer object. Optional key/value pairs set initial properties as per
Glib::Object->new
. Eg.my $renderer = Gtk2::Ex::DateSpinner::CellRenderer->new;
OTHER NOTES
Like the plain CellRendererText, DateSpinner::CellRenderer creates a new editable widget for every edit, including a new popup window every time. Both are destroyed when accepted or cancelled. That's a bit wasteful, but it's usually fast enough for casual editing and it might save some memory in between.
The code for the popup and entry are in the Gtk2::Ex::DateSpinner::PopupForEntry
and Gtk2::Ex::DateSpinner::EntryWithCancel
components. They're not loaded until the first edit. They're only meant for internal use as yet.
SEE ALSO
Gtk2::Ex::DateSpinner, Gtk2::CellRendererText
Gtk2-Perl examples/cellrenderer_date.pl does a similar thing popping up a Gtk2::Calendar
.
HOME PAGE
http://www.geocities.com/user42_kevin/gtk2-ex-datespinner/index.html
LICENSE
Gtk2-Ex-DateSpinner is Copyright 2008, 2009 Kevin Ryde
Gtk2-Ex-DateSpinner 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-DateSpinner 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-DateSpinner. If not, see <http://www.gnu.org/licenses/>.