NAME

Tickit::Widget::Table::Paged - table widget with support for scrolling/paging

VERSION

version 0.004

SYNOPSIS

use Tickit;
use Tickit::Widget::Table::Paged;

my $tbl = Tickit::Widget::Table::Paged->new;
$tbl->{row_offset} = 0;
$tbl->add_column(
	label => 'Left',
	align => 'left',
	width => 8,
);
$tbl->add_column(
	label => 'Second column',
	align => 'centre'
);
$tbl->add_row('left', 'middle') for 1..100;
Tickit->new(root => $tbl)->run;

DESCRIPTION

WARNING: This is a preview release. API is subject to change in future, please get in contact if you're using this, or wait for version 1.000.

This widget provides a scrollable table implementation.

Paged table widget in action

METHODS

new

Instantiate. Will attempt to take focus.

METHODS - Table content

data

Returns the table's current data content as an arrayref.

Note that it is not recommended to make any changes to this data structure - you are responsible for triggering any necessary redrawing or resizing logic if you choose to do so.

clear

Clear all data in the table.

add_row

Add a row to the table. Data should be provided as a list with one item per column.

Returns $self.

add_column

Add a new column. Takes the following named parameters:

  • width - (optional) number of columns

  • type - (optional) data type, currently only supports 'text' (the default)

  • align - (optional) align left, center or right

Returns $self.

selected_rows

Returns the selected row, or multiple rows as a list if multi_select is enabled. If multi_select is enabled it does not return the row currently highlighted (unless that row is also selected).

METHODS - Callbacks

on_activate

Accessor for the activation callback - if called without parameters, will return the current coderef (if any), otherwise, will set the new callback.

This callback will be triggered via "key_activate":

$code->($row_index, $row_data_as_arrayref)

If multiselect is enabled, the callback will have the following:

$code->(
  [$highlight_row_index, @selected_row_indices],
  $highlight_row_data_as_arrayref,
  @selected_rows_as_arrayrefs
)

(the selected row data + index list could be empty here)

multi_select

Accessor for multi_select mode - when set, this allows multiple rows to be selected.

METHODS - Other

lines

Number of lines to request.

cols

Number of columns to request.

vscroll

True if there's a vertical scrollbar.

hscroll

True if there's a horizontal scrollbar.

row_offset

Current row offset (vertical scroll position).

visible_lines

Returns the list of lines currently visible in the display.

header_rect

Returns the Tickit::Rect representing the header area.

body_rect

Returns the Tickit::Rect representing the body area.

scrollbar_rect

Returns the Tickit::Rect representing the scroll bar.

render_header

Render the header area.

render_to_rb

Render the table.

render_body

Render the body area.

apply_column_widget

Add widgets for the column.

render_scrollbar

Render the scrollbar.

render_cell

Render a given cell.

reshape

Handle reshape requests.

distribute_columns

Distribute space between columns.

window_gained

Called when a window has been assigned to the widget.

expose_rows

Expose the given rows.

highlight_row

Returns the index of the currently-highlighted row.

highlight_visible_row

Returns the position of the highlighted row taking scrollbar into account.

scroll_highlight

Update scroll information after changing highlight position.

move_highlight

Change the highlighted row.

key_previous_row

Go to the previous row.

key_next_row

Move to the next row.

key_first_row

Move to the first row.

key_last_row

Move to the last row.

key_previous_page

Go up a page.

key_next_page

Go down a page.

scroll_position

Current vertical scrollbar position.

row_count

Total number of rows.

sb_height

Current scrollbar height.

scroll_rows

Positions of the scrollbar indicator.

active_scrollbar_rect

Rectangle representing the area covered by the current scrollbar.

scroll_dimension

Size of the vertical scrollbar.

key_next_column

Move to the next column.

key_previous_column

Move to the previous column.

key_first_column

Move to the first column.

key_last_column

Move to the last column.

key_activate

Activate the highlighted item.

key_select_toggle

Toggle selected row.

TODO

Current list of pending features:

  • Storage abstraction - the main difference between this widget and Tickit::Widget::Table is that this is designed to work with a storage abstraction. The current abstraction implementation needs more work before it's reliable enough for release, so this version only has basic arrayref support.

  • Column and cell highlighting modes

  • Proper widget-in-cell support

  • Formatters for converting raw cell data into printable format (without having to go through a separate widget)

  • Better header support (more than one row, embedded widgets)

SEE ALSO

INHERITED METHODS

Tickit::Widget

get_style_pen, get_style_text, get_style_values, key_focus_next_after, key_focus_next_before, on_pen_changed, parent, pen, redraw, requested_cols, requested_lines, requested_size, resized, set_parent, set_pen, set_requested_size, set_style, set_style_tag, set_window, style_classes, take_focus, window, window_lost

AUTHOR

Tom Molesworth <cpan@entitymodel.com>

LICENSE

Copyright Tom Molesworth 2012-2013. Licensed under the same terms as Perl itself.