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

NAME

LibUI::Window - Top-Level Window

SYNOPSIS

    use LibUI ':all';
    use LibUI::Window;
    Init( { Size => 1024 } ) && die;
    my $window = LibUI::Window->new( 'Hi', 320, 100, 0 );
    $window->onClosing(
        sub {
            Quit();
            return 1;
        },
        undef
    );
    $window->show;
    Main();

DESCRIPTION

A LibUI::Window object represents a top-level window.

A window contains exactly one child control that occupies the entire window. A LibUI::Window is a subclass of LibUI::Control and can NOT be a child of another LibUI::Control.

Functions

Many of the LibUI::Window methods should be regarded as mere hints. The underlying system may override these or even choose to ignore them completely. This is especially true for many Unix systems.

new( ... )

    my $w = LibUI::Window->new( $title, $width, $height, $hasMenubar );

Creates a new LibUI::Window.

Expected parameters include:

$title

Window title text

$width

Window width

$height

Window height

$hasMenubar

Boolean value indicating whether or no the window should display a menu bar

title( ... )

    my $title = $w->title( );

Returns the window title.

setTitle( ... )

    $w->setTitle( '.../lib/Readonly.pm - SciTE' );

Sets the window title.

This method is merely a hint and may be ignored on unix platforms.

contentSize( ... )

    my ( $w_, $h_ ) = $w->contentSize( );
    warn sprintf 'Window size: %d * %d', $w_, $h_;

Gets the window content size.

The content size does NOT include window decorations like menus or title bars.

setContentSize( ... )

    $w->setContentSize( 1024, 720 );

Sets the window content size.

The content size does NOT include window decorations like menus or title bars. This method is merely a hint and may be ignored by the system.

fullscreen( ... )

    my $fs = $w->fullscreen( $w );

Returns whether or not the window is full screen.

Returns a true value if full screen; an untrue value otherwise.

setFullscreen( ... )

    $w->setFullscreen( 1 );

Sets whether or not the window is full screen.

A true value to make the window full screen, an untrue value otherwise.

This method is merely a hint and may be ignored by the system.

onContentSizeChanged( ... )

    $w->onContentSizeChanged(
        sub {
            my ($wnd, $data) = @_;
            my ( $w, $h );
            uiWindowContentSize( $wnd, $w, $h );
            warn sprintf 'Window size: %d * %d', $w_, $h_;
        },
        undef
    );

Registers a callback for when the window content size is changed.

Only one callback can be registered at a time.

onClosing( ... )

    $w->onClosing(
        sub {
            my ($wnd, $data) = @_;
            my ( $w_, $h_ );
            warn 'Goodbye...';
            return 1;
        },
        undef
    );

Registers a callback for when the window is to be closed.

Your callback should return a boolean value:

true to destroy the window
false to abort closing and keep the window alive and visible

Only one callback can be registered at a time.

onFocusChanged( ... )

    $w->onFocusChanged(
        sub {
            my ($wnd, $data) = @_;
            warn uiWindowFocused($wnd) ? 'Focus' : 'Lost focus';
        },
        undef
    );

Registers a callback for when the window focus changes.

Only one callback can be registered at a time.

focused( ... )

    my $focused = $w->focused( );

Returns whether or not the window is focused. True if the window is focused, otherwise false.

borderless( ... )

    my $borderless = $w->borderless( );

Returns whether or not the window is borderless. True if the window is borderless, otherwise false.

setBorderless( ... )

    $w->setBorderless( 1 );

Sets whether or not the window is borderless. A true value to make the window borderless, otherwise false.

This method is merely a hint and may be ignored by the system.

setChild( ... )

    $w->setChild( $box );

Sets the window's child. The child must be a subclass of LibUI::Context.

margined( ... )

    my $margin = $w->margined( );

Returns whether or not the window has a margin. True if the window has a margin, otherwise false.

setMargined( ... )

    $w->setMargined( 1 );

Sets whether or not the window has a margin. True to set a window margin, otherwise false.

The margin size is determined by the OS defaults.

resizeable( ... )

    my $can_resize = $w->resizeable( );

Returns whether or not the window is user resizable. True if the window can be resized, otherwise false.

setResizeable( ... )

    $w->setResizeable( 0 );

Sets whether or not the window is user resizable. True to make the window resizable, otherwise false.

This method is merely a hint and may be ignored by the system.

Dialog Functions

These methods launch platform-dependant dialogs.

openFile( )

    my $path = $w->openFile();

File chooser dialog window to select a single file.

File paths are separated by the underlying OS's file path separator.

openFolder( )

    my $directory = $w->openFolder();

Folder chooser dialog window to select a single folder.

File paths are separated by the underlying OS's file path separator.

saveFile( )

    my $path = $w->saveFile();

Save file dialog window.

The user is asked to confirm overwriting existing files, should the chosen file path already exist on the system.

File paths are separated by the underlying OS's file path separator.

msgBox( ... )

    $w->msgBox( 'MsgBox Demonstration', 'This works!' );

Message box dialog window.

A message box displayed in a new window indicating a common message.

Expected parameters include:

$title

Dialog window title text.

$description

Dialog message text.

msgBoxError( ... )

    $w->msgBoxError( 'Oh, no!', 'This is broken!' );

Error message box dialog window.

A message box displayed in a new window indicating an error. On some systems this may invoke an accompanying sound.

Expected parameters include:

$title

Dialog window title text.

$description

Dialog message text.

LICENSE

Copyright (C) Sanko Robinson.

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

AUTHOR

Sanko Robinson <sanko@cpan.org>