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

NAME

Tk::SourceCatalog - creates a self-standing sources catalog widget

SYNOPSIS

    use Tk::AstroCatalog;

    $cat = new Tk::AstroCatalog($MW, $addCmd, $upDate, $onDestroy);

DESCRIPTION

Tk::AstroCatalog creates a non-editable text widget, displaying sources from a default catalog or user-selected catalog file.

PUBLIC METHODS

Methods available in this class:

Constructor

new

Create a new Tk::AstroCatalog object. A new catalog object will be created. Callbacks must be specified for -addCmd and -upDate; a warning is issued for -onDestroy when it is missing.

    $cat = new Tk::AstroCatalog($MW,
        -addCmd => $addCmd,
        -upDate => $upDate,
        -onDestroy => $onDestroy);

Additionally a pre-existing Astro::Catalog object can be supplied using the "-catalog" option.

    $cat = new Tk::AstroCatalog($MW,
        -addCmd => $addCmd,
        -upDate => $upDate
        -catalog => $cat);

The "-transient" option can be used if only a single value is required from the widget. Default behaviour is for the widget to be permanent. The "-transient" button does not have a "Done" button on the screen (ie no button to close the window without a selection)

The "-addCmd" callback is triggered whenever a source is selected from the widget. If the widget is transient the widget will be closed after the first add is triggered.

The "-onDestroy" callback is triggered when the "Done" button is pressed.

The "-upDate" method is triggered whenever the contents of the catalog widget are refreshed/updated.

It makes more sense for this widget to work like Tk::FileSelect when used in transient mode since we want to get the answer back rather than enter an event loop.

The "-customColumns" method can be used to add additional columns to the display. This is an array of hashes specifying the title, width and generator function for each column. This generating function will be called with an Astro::Catalog::Item and must return a string of the given width.

    -customColumns => [{
        title     => 'Example',
        width     => 7,
        generator => sub {
            my $item = shift;
            return sprintf('%7s', 'test');
        }},
    ]

Data manipulation functions

Catalog

Returns and sets the Astro::Catalog object.

    $catalog = $cat->Catalog();
    $cat->Catalog(new Astro::Catalog(...));
AddCommand

Returns and sets the AddCommand callback code for the catalog

    $addCommand = $cat->AddCommand();
    $cat->AddCommand($addCommand);
UpDate

Returns and sets the UpDate callback code for the catalog

    $update = $cat->UpDate();
    $cat->UpDate($update);

Called whenever the contents of the text widget are redisplayed. The first argument will be the current object.

Reset

Returns and sets the onDestroy callback code for the catalog

    $reset = $cat->Reset();
    $cat->Reset($reset);
Toplevel

Returns and sets the name of the Toplevel

    $toplevel = $cat->Toplevel();
    $cat->Toplevel($top);
Transient

Returns and sets whether the widget should be destroyed after the next Add.

    $toplevel = $cat->Transient();
    $cat->Transient($top);
Text

Returns and sets the name of the Text

    $text = $cat->Text();
    $cat->Text($text);
RefLabel

Configure the text displayed in the reference label widget. Usually a summary of the reference position.

    $self->RefLabel

Returns a reference to a scalar that can be used to associate the value with a widget.

CatClass

Returns and sets the name of the CatClass

    $class = $cat->CatClass();
    $cat->CatClass($class);
Selected

Returns the Selected array or the indexed value of this array

    @selected = $cat->Selected();
    $value = $cat->Selected($index);
file

Returns and sets the File name

    $file = $cat->file();
    $cat->file($filename);
makeCatalog

makeCatalog creates a window that displays the contents of a catalog and allows the user to select as many entries as the user wishes.

    $catalog = $cat->makeCatalog();
    $catalog = $cat->makeCatalog($selected);
destroy

Remove the widget from display. Leaves calling the Reset handler to the DESTROY method.

DESTROY

Object destructor. Triggers when the object is destroyed. Guarantees to destroy the Toplevel widget and does trigger the onDestroy callback.

fillWithSourceList

Fills a text widget with the list of current sources

    $cat->fillWithSourceList();
    $cat->fillWithSourceList($text, $selected, $task, $index);
    $cat->fillWithSourceList($text, $selected, $task);
    $cat->fillWithSourceList($text, $selected);

Also triggers the UpDate method.

color

Returns a color from @COLOR_LIST and increments the latter's index

    $color = $cat->color();
error

Displays an error message in Tk

    $cat->error('Error message');
inswt

inswt inserts text into a given text widget and applies one or more tags to that text.

Parameters: $text - Text to insert (it's inserted at the "insert" mark) $args - One or more tags to apply to text. If this is empty then all tags are removed from the text.

    $cat->inswt($text, $args);
getSource

getSource prompts the user to enter source coords and name and filters the catalog based on the input provided.

Takes the new top level widget to use, and the search button to be re-activated when this window closes.

    $obj = $cat->getSource($toplevel, $search_button);
isWithin

isWithin returns a boolean value as to whether an element is within the array specified.

    $obj = $cat->isWithin($element, @array);
remove

Removes the item passed from the array specified.

    $obj = $cat->remove($element, @array);

SEE ALSO

Astro::Catalog, Astro::Catalog::Item, Astro::Coords

COPYRIGHT

Copyright (C) 2013 Science & Technology Facilities Council. Copyright (C) 1999-2002,2004 Particle Physics and Astronomy Research Council. All Rights Reserved.

AUTHOR

Major subroutines and layout originally designed by Casey Best (University of Victoria) with modifications to create independent composite widget by Tim Jenness and Pam Shimek (University of Victoria)

Revamped for Astro::Catalog by Tim Jenness.