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

XUL::Gui - render cross platform gui applications with firefox from perl

VERSION

Version 0.14

SYNOPSIS

    use XUL::Gui;
    start Label 'hello, world!';


    use XUL::Gui;
    start Window title => "XUL::Gui's long hello",
        GroupBox(
            Caption('XUL'),
            Button( label=>'click me', oncommand=> sub {shift->label = 'ouch'} ),
            Button( type=>'menu', label=>'menu button',
                MenuPopup map {MenuItem label=>$_} qw/first second third/
            ),
            TextBox( FILL ),
            ProgressMeter(mode=>'undetermined'),
        ),
        GroupBox(
            Caption('HTML too'),
            TABLE( border=>1, TR map {TD $_} 'one', I('two'), B('three'), U('four'), SUP('five') ),
            HR,
            P('all the HTML tags are in CAPS'),
        );

DESCRIPTION

this module exposes the entire functionality of mozilla firefox's rendering engine to perl by providing all of the XUL and HTML tags as functions and allowing you to interact with those objects directly from perl. gui applications created with this toolkit are cross platform, fully support CSS styling, inherit firefox's rich assortment of web technologies (browser, canvas and video tags, flash and other plugins), and are even easier to write than HTML.

this module is written in pure perl, and only depends upon core modules, making it easy to distribute your application.

this module is presented for preview only and is under active development. this code is currently in beta, use in production enviroments at your own risk

the code will be considered production ready, and interfaces finalized at version 0.25

all XUL and HTML objects in perl are exact mirrors of their javascript counterparts and can be acted on as such. developer.mozilla.com is the official source of documentation.

this documentation is a work in progress

EXPORT

    all functions listed here are exported by default, this may change in the future

    all XUL tags: (also exported as Titlecase)
        Action ArrowScrollBox Assign BBox Binding Bindings Box Broadcaster BroadcasterSet Browser Button Caption
        CheckBox ColorPicker Column Columns Command CommandSet Conditions Content DatePicker Deck Description Dialog
        DialogHeader DropMarker Editor Grid Grippy GroupBox HBox IFrame Image Key KeySet Label ListBox ListCell ListCol
        ListCols ListHead ListHeader ListItem Member Menu MenuBar MenuItem MenuList MenuPopup MenuSeparator Notification
        NotificationBox Observes Overlay Page Panel Param PopupSet PrefPane PrefWindow Preference Preferences ProgressMeter
        Query QuerySet Radio RadioGroup Resizer RichListBox RichListItem Row Rows Rule Scale Script ScrollBar ScrollBox
        ScrollCorner Separator Spacer SpinButtons Splitter Stack StatusBar StatusBarPanel StringBundle StringBundleSet Tab
        TabBox TabPanel TabPanels Tabs Template TextBox TextNode TimePicker TitleBar ToolBar ToolBarButton ToolBarGrippy
        ToolBarItem ToolBarPalette ToolBarSeparator ToolBarSet ToolBarSpacer ToolBarSpring ToolBox ToolTip Tree TreeCell
        TreeChildren TreeCol TreeCols TreeItem TreeRow TreeSeparator Triple VBox Where Window Wizard WizardPage

    all HTML tags: (also exported as html_lowercase)
        A ABBR ACRONYM ADDRESS APPLET AREA AUDIO B BASE BASEFONT BDO BGSOUND BIG BLINK BLOCKQUOTE BODY BR BUTTON CANVAS
        CAPTION CENTER CITE CODE COL COLGROUP COMMENT DD DEL DFN DIR DIV DL DT EM EMBED FIELDSET FONT FORM FRAME FRAMESET
        H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME ILAYER IMG INPUT INS ISINDEX KBD LABEL LAYER LEGEND LI LINK LISTING MAP
        MARQUEE MENU META MULTICOL NOBR NOEMBED NOFRAMES NOLAYER NOSCRIPT OBJECT OL OPTGROUP OPTION P PARAM PLAINTEXT PRE
        Q RB RBC RP RT RTC RUBY S SAMP SCRIPT SELECT SMALL SOURCE SPACER SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD
        TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR VIDEO WBR XML XMP

    widget extends server Code quit buffered alert now cached noevents dialog zip attribute hashif gui
    tag object delay run function XUL FLEX FIT FILL genid doevents trace mapn apply toggle lf start

FUNCTIONS

mapn CODE NUMBER LIST

map over n elements at a time

    mapn {print "@_" if $_ % 2} 3 => 1..10;
    > 1 2 3
    > 7 8 9

zip LIST of ARRAYREF

    %hash = zip [qw/a b c/], [1..3];

apply CODE LIST

apply a function to a list and return that list

    print join ", " => apply {s/two/one/} "this two", "and that two";
    > this one, and that one

toggle TARGET OPT1 OPT2

alternate a variable between two states

    toggle $state => 0, 1;

attribute NAME

includes an attribute name if it exists, only workts inside of widgets

    attribute 'value'; # is syntactic sugar for
    exists $A{value} ? ( value => $A{value} ) : ()

object TAGNAME LIST

creates a gui proxy object, allows runtime addition of custom tags

    object('Label', value=>'hello') is the same as Label( value=>'hello' )

tag NAME

returns a CODEREF that generates proxy objects, allows for user defined tag functions

    *mylabel = tag 'label';

    \&mylabel == \&Label

widget CODE HASH

group tags together into common patterns, with methods and inheritance

    *MyWidget = widget {
        Hbox(
            Label( value=>'Labeled Button: ' ),
            Button( label=>'OK' )
        )
    }
    method => sub{ ... },
    method2 => sub{ ... };

    much more detail in XUL::Gui::Manual

extends CODE

indicate that a widget inherits from another widget or tag

    *MySubWidget = widget {extends MyWidget}
        submethod => sub{...};

    more details in XUL::Gui::Manual

Code JAVASCRIPT

executes its javascript at the moment it is written to the gui

run JAVASCRIPT

executes javascript immediately

function JAVASCRIPT

create a javascript function, useful for functions that need to be very fast, such as rollovers

    Button( label=>'click me', oncommand=> function q{
        alert('hello from javascript');
    })

XUL STRING

converts an XUL string to XUL::Gui objects

alert STRING

open an alert message box

server OBJECTS; or start OBJECTS

starts the http server, launches firefox

if OBJECT is a Window, that window is created, otherwise a default one is added, and the OBJECT is added to it. see SYNOPSYS and XUL::Gui::Manual for more details

the function will not return until the the gui quits

server and start are exactly the same, one will be removed at some point

quit

shuts down the server (causes a call to server or start to return at the end of the current event cycle)

trace LIST

carps LIST with object details, and then returns LIST unchanged

gui JAVASCRIPT

executes JAVASCRIPT

pragmatic blocks

the following functions all apply pragmas to their CODE blocks. in some cases, they also take a list. this list will be @_ when the CODE block executes. this is useful for sending in values from the gui, if you dont want to use a now{} block.

buffered CODE LIST

delays sending gui updates

    buffered {
        $ID{$_}->value = '' for qw/a bunch of labels/
    };

cached CODE

turns on caching of gets from the gui

now CODE

execute immediately, from inside a buffered or cached block

delay CODE LIST

delays executing its CODE until the next gui refresh

noevents CODE LIST

disable event handling

mapn CODE, NUMBER, LIST

force a gui update before an event handler finishes

METHODS

in addition to mirroring all of an object's existing javascript methods / attributes / and properties to perl, several default methods have been added to all objects

toXUL

returns an object as an XUL string

toJS

returns an object as a javascript string

removeChildren LIST

removes the children in LIST, or all children if none given

removeItems LIST

removes the items in LIST, or all items if none given

appendChildren LIST

appends the children in LIST

prependChild CHILD [INDEX]

inserts CHILD at INDEX in the parent's child list

appendItems LIST

append a list of items

replaceItems LIST

removes all items, then appends LIST

AUTHOR

Eric Strom, <ejstrom at gmail.com>

BUGS

Please report any bugs or feature requests to bug-xul-gui at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XUL-Gui. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc XUL::Gui

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2009 Eric Strom.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.