Fl

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    - Expanded export tags/values (get them all with :enum, of course):
        - :event - handle(...) event values are now exported now
        - :default - This tag is exported by default. I'll note these as the
            list grows
    - New demo scripts:
        - eg/double_click.pl - Custom button widget that detects double clicks
        - eg/drag_and_drop.pl - Example of clipboard access and drag and drop
    - New widgets:
        - Fl::Progress - Typical progress bar
        - Fl::InputChoice - Input widget and menu button rolled into one
        - Fl::Menu - Base class for all widgets that have a menu
        - Fl::MenuButton - Button that pops up a menu when pushed
        - Fl::HtmlView - Simple HTML viewer
    - New demo scripts:
        - eg/progress.pl - Demos using a Fl::Progress bar to keep user up to date on background progress
        - eg/input_choice.pl - Demos using Fl::InputChoice and enabling/disabling widgets
    - Some tests require a working DISPLAY on X11

0.99.11 2016-06-04T15:18:01Z

    - New widgets:
        - Fl::Tabs - "File card tabs" interface

MANIFEST  view on Meta::CPAN

lib/Fl/HorFillSlider.pod
lib/Fl/HorNiceSlider.pod
lib/Fl/HorSlider.pod
lib/Fl/HorValueSlider.pod
lib/Fl/HtmlView.pod
lib/Fl/Input.pod
lib/Fl/InputChoice.pod
lib/Fl/IntInput.pod
lib/Fl/LightButton.pod
lib/Fl/LineDial.pod
lib/Fl/Menu.pod
lib/Fl/MenuButton.pod
lib/Fl/MultilineInput.pod
lib/Fl/MultilineOutput.pod
lib/Fl/NiceSlider.pod
lib/Fl/Output.pod
lib/Fl/Progress.pod
lib/Fl/RadioButton.pod
lib/Fl/RadioLightButton.pod
lib/Fl/RadioRoundButton.pod
lib/Fl/RepeatButton.pod
lib/Fl/ReturnButton.pod

lib/Fl/Enumerations.pod  view on Meta::CPAN

The end key.

=item FL_Print

The print (or print-screen) key.

=item FL_Insert

The insert key.

=item FL_Menu

The menu key.

=item FL_Help

The 'help' key on Mac keyboards

=item FL_Num_Lock

The num lock key.

lib/Fl/Enumerations.pod  view on Meta::CPAN

export_constant("FL_Home",           "keyboard");
export_constant("FL_Left",           "keyboard");
export_constant("FL_Up",             "keyboard");
export_constant("FL_Right",          "keyboard");
export_constant("FL_Down",           "keyboard");
export_constant("FL_Page_Up",        "keyboard");
export_constant("FL_Page_Down",      "keyboard");
export_constant("FL_End",            "keyboard");
export_constant("FL_Print",          "keyboard");
export_constant("FL_Insert",         "keyboard");
export_constant("FL_Menu",           "keyboard");
export_constant("FL_Help",           "keyboard");
export_constant("FL_Num_Lock",       "keyboard");
export_constant("FL_KP",             "keyboard");
export_constant("FL_KP_Enter",       "keyboard");
export_constant("FL_KP_Last",        "keyboard");
export_constant("FL_F",              "keyboard");
export_constant("FL_F_Last",         "keyboard");
export_constant("FL_Shift_L",        "keyboard");
export_constant("FL_Shift_R",        "keyboard");
export_constant("FL_Control_L",      "keyboard");

lib/Fl/InputChoice.pod  view on Meta::CPAN

class 'Fl::InputChoice';
isa 'Fl::Group';
include 'FL/Fl_Input_Choice.H';
widget_type 'Fl_Input_Choice';

=pod

=head1 NAME

Fl::InputChoice - Combination of the Input Widget and a Menu Button

=head1 Description

The Fl::InputChoice is a combination of the input widget and a menu button.

=for html <center><img src="http://www.fltk.org/doc-1.3/input_choice.jpg" /></center>

The user can either type into the input area, or use the menu button chooser
on the right to choose an item which loads the input area with the selected
text.

The application can directly access both the internal Fl::Input and
Fl::MenuButton widgets respectively using the input() and menubutton()
accessor methods.

A full example of this widget can be found in C<eg/input_choice.pl>

=head1 Methods

Fl::InputChoice inherits from Fl::Group and Fl::Widget. On top of that, it
exposes the following methods...

=head2 new(...)

lib/Fl/InputChoice.pod  view on Meta::CPAN

    definitions => [{required => [[qw[int event]]], returns  => 'int'  }
    ]
};

=pod

=head2 add(...)

Add an item to the menu.

You can access the more complex C<<Fl::MenuButton->add()>> methods (setting
callbacks, userdata, etc.) via C<menubutton()>.

Example:

    my $choice = Fl::InputChoice->new(100,10,120,25,"Fonts");
    my $mb = $choice->menubutton(); # use Fl::InputChoice's Fl::MenuButton
    $mb->add("Helvetica", 0, \&MyFont_CB); # use Fl::MenuButton's add() methods
    $mb->add("Courier",   0, \&MyFont_CB);
    $mb->add("More..",    0, \&FontDialog_CB);

=cut

xs {name        => 'add',
    definitions => [
        {required => [['const char *', 's']]}
    ]
};

lib/Fl/InputChoice.pod  view on Meta::CPAN

    ]
};

=pod

=head2 menu(...)

    my $mn_item = $ic_a->menu( );
    $ic_b->menu( $mn_item );

Gets or sets the Fl_Menu_Item array used for the menu.

=cut

xs {name        => 'menu',
    definitions => [
        {c_args   => '(const Fl_Menu_Item *) mnu->cp_ctx',required  => [['Fl_Menu_Item *', 'mnu']]},
        {returns   => 'const Fl_Menu_Item *'}
    ]
};

=pod

=head2 menubutton( )

    my $mn_btn = $ic_a->menubutton( );

Returns a pointer to the internal Fl::MenuButton widget.

This can be used to access any of the methods of the menu button, e.g.

    my $choice = Fl::InputChoice->(100, 10, 120, 25, "Choice:");
    ...
    # Print all the items in the choice menu
    for ( my $t = 0; $t < $choice->menubutton()->size(); $t++ ) {
        my $item = $choice->menubutton->menu->[$t];
        printf("item %d -- label=%s\n", $t, $item->label ? $item->label : '(Null)');
    }

=cut

xs {name        => 'menubutton',
    definitions => [
        {returns=> 'Fl_Menu_Button *'}
    ]
};

=pod

=head2 resize( ... )

    $ic_a->menubutton( int x, int y, int w, int h );

Resizes the Fl::Group widget and all of its children.

lib/Fl/Menu.pod  view on Meta::CPAN

class 'Fl::Menu';
isa 'Fl::Widget';
include 'FL/Fl_Menu.H';
widget_type 'Fl_Menu_';

=pod

=head1 NAME

Fl::Menu - Base Class of all Widgets that Have a Menu

=head1 Description

Currently Fl.pm provides you with Fl::MenuButton, Fl::MenuBar, and Fl::Choice.

The class contains a pointer to an array of structures of type Fl::MenuItem.
The array may either be supplied directly by the user program, or it may be
"private": a dynamically allocated array managed by the Fl::Menu.

=head1 Methods

Fl::Menu inherits from Fl::Widget. On top of that, it exposes the following
methods...

=cut

xs {name        => 'DESTROY',
    definitions => [{returns => 'void'}]
};

=pod

lib/Fl/Menu.pod  view on Meta::CPAN


=pod

=head2 clear( )

    $mnu_a->clear( );

Same as menu(undef), set the array pointer to null, indicating a zero-length
menu.

Menus must not be cleared during a callback to the same menu.

=cut

xs {name        => 'clear',
    definitions => [
            {returns  => 'void'}
    ]
};

=pod

lib/Fl/Menu.pod  view on Meta::CPAN


    $mnu_a->copy($menu_item);

Sets the menu array pointer with a copy of the menuitem that weill be
automatically deleted.

=cut

xs {name        => 'copy',
    definitions => [
            {required => [['Fl_Menu_Item *', 'm']],
             c_args   => '(const Fl_Menu_Item *) m',
             returns  => 'void'
            }
    ]
};

=pod

=head2 down_box( )

    my $box = $mnu_a->down_box($menu_item);

lib/Fl/Menu.pod  view on Meta::CPAN


Returns the index of the matching item or C<-1> if not found.

=cut

xs {name        => 'find_index',
    definitions => [
            {   required => [['const char *','pathname']],
                andif    => 'SvPOK(ST(1)) && !sv_isobject(ST(1))',
                returns  => 'int'},
            {   required => [['Fl_Menu_Item *','item']],
                c_args   => '(const Fl_Menu_Item *) item->cp_ctx',
                returns  => 'int'}

    ]
};

=pod

=head2 find_item(...)

    my $item = $mnu_a->find_item( 'File/Copy' );

Find the Fl::MenuItem for a given menu pathname, such as "Edit/Copy".

This method finds a menu item in the menu array, also traversing submenus, but
not submenu pointers.

    my $menubar = Fl::MenuBar->new(...);
    $menubar->add("File/&Open");
    $menubar->add("File/&Save");
    $menubar->add("Edit/&Copy");
    # ...
    my $item;
    if ( ( $item = (Fl_Menu_Item*) $menubar->find_item("File/&Open") ) ) {
        $item->labelcolor(FL_RED);
    }
    if ( ( $item = (Fl_Menu_Item*) $menubar->find_item("Edit/&Copy") ) ) {
        $item->labelcolor(FL_GREEN);
    }

To get the menu item's index, use find_index(...).

=cut

xs {name        => 'find_item',
    definitions => [
            {   required => [['const char *','pathname']],
                returns  => 'const Fl_Menu_Item *'}
    ]
};

=pod

=head2 global( )

    $mnu_a->global( );

Make the shortcuts for this menu work no matter what window has the focus when
you type it.

This is done by using Fl::add_handler(). This Fl::Menu widget does not have to
be visible (ie the window it is in can be hidden, or it does not have to be
put in a window at all).

Currently there can be only one global() menu. Setting a new one will replace
the old one. There is no way to remove the global() setting (so don't destroy
the widget!).

=cut

xs {name        => 'global',

lib/Fl/Menu.pod  view on Meta::CPAN


    sub my_menu_callback {
        if ( $menubar->item_pathname($name)) { # recently picked item
            if ( $name eq "File/&Open" ) { ... } # open invoked
            if ( $name eq "File/&Save" ) { ... } #  save invoked
            if ( $name eq "Edit/&Copy" ) { ... } #  copy invoked
        }
    }

    ...
    $menubar = Fl::MenuBar->new(...);
    $menubar->add("File/&Open", 0, \&my_menu_callback);
    $menubar->add("File/&Save", 0, \&my_menu_callback);
    $menubar->add("Edit/&Copy", 0, \&my_menu_callback);
    ...

=cut

xs {name        => 'item_pathname',
    definitions => [ {required => [['const char *', 'name']],
                     optional => [  ['Fl_Menu_Item *', 'finditem',    '0']
                     ],
                     returns => 'int',
                     c_args => '(char *) name, sizeof(name)-1, (const Fl_Menu_Item *) finditem'
                    } ]
};

=pod

=head2 menu(...)

    my $item = $mnu_a->menu( );

Returns a pointer to the array of Fl::MenuItems.

This will either be the value passed to menu($value) or the private copy.

    $menu_b->menu( $item );

Sets the menu array pointer directly.

If the old menu is private it is deleted. NULL is allowed and acts the same as
a zero-length menu. If you try to modify the array (with add(), replace(), or
remove()) a private copy is automatically done.

=cut

xs {name        => 'menu',
    definitions => [ {returns => 'const Fl_Menu_Item *'},
                     {  required => [['Fl_Menu_Item *', 'm']],
                        c_args   => '(const Fl_Menu_Item *) m',
                        returns  => 'void'}
                   ]
};

=pod

=head2 mode(...)

    $mnu_a->mode( $index, $flag );

Set the flags of item C<$index>.

For a list of flags, see Fl::MenuItem.

    my $flags  = $menu_b->mode( $ndex );

Get the flags of item C<$index>.

For a list of flags, see Fl::MenuItem.

=cut

xs {name        => 'mode',
    definitions => [ {  required => [['int', 'index'], ['int', 'fl']],
                        returns => 'void'},
                     {  required => [['int', 'index']],
                        returns  => 'int'}
                   ]
};

lib/Fl/Menu.pod  view on Meta::CPAN


=head2 mvalue(...)

    my $item = $mnu_a->mvalue( );

Returns a pointer to the last menu item that was picked.

=cut

xs {name        => 'mvalue',
    definitions => [ { returns  => 'const Fl_Menu_Item *' } ]
};

=pod

=head2 picked(...)

    my $item = $mnu_a->picked( $item );

When user picks a menu item, call this. It will do the callback.

=cut

xs {name        => 'picked',
    definitions => [
                     {  required => [['Fl_Menu_Item *', 'm']],
                        c_args   => '(const Fl_Menu_Item *) m',
                        returns  => 'const Fl_Menu_Item *' } ]
};

=pod

=head2 remove(...)

    $mnu_a->remove( $item );

Deletes item from the menu.

lib/Fl/Menu.pod  view on Meta::CPAN

                     {  required => [[qw[int index]], [qw[int shortuct]]],
                        returns  => 'void' } ]
};

=pod

=head2 size(...)

    my $ret = $mnu_a->size( );

This returns the number of Fl::MenuItem structures that make up the menu,
correctly counting submenus.

This includes the "terminator" item at the end. If the menu is NULL this
returns zero (an empty menu will return 1).

=cut

xs {name        => 'size',
    definitions => [
                     { returns  => 'int' } ]

lib/Fl/Menu.pod  view on Meta::CPAN


This searches the complete menu() for a shortcut that matches the entered key
value. It must be called for a FL_KEYBOARD or FL_SHORTCUT event.

If a match is found, the menu's callback will be called.

=cut

xs {name        => 'test_shortcut',
    definitions => [
                     { returns  => 'const Fl_Menu_Item *' } ]
};

=pod

=head2 text(...)

    my $title = $mnu_a->text( );

Returns the title of the last item chosen.

lib/Fl/Menu.pod  view on Meta::CPAN

It is zero initially. You can set it as an integer, or set it with a pointer
to a menu item. The set routines return non-zero if the new value is different
than the old one.

=cut

xs {name        => 'value',
    definitions => [
                    { returns => 'int' },
                    { returns => 'int', required => [['int', 'i']], andif => 'SvIOK(ST(1))' },
                    { returns => 'int', required => [['Fl_Menu_Item *', 'm']], c_args   => '(const Fl_Menu_Item *) m' }
                   ]
};

=pod

=head1 LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify

lib/Fl/MenuButton.pod  view on Meta::CPAN

class 'Fl::MenuButton';
isa 'Fl::Menu';
include 'FL/Fl_Menu_Button.H';
widget_type 'Fl_Menu_Button';

=pod

=head1 NAME

Fl::MenuButton - Button that Pops Up a Menu

=head1 Description

This is a button that when pushed pops up a menu (or hierarchy of menus)
defined by an array of Fl::MenuItem objects.

=for html <center><img src="http://www.fltk.org/doc-1.3/menu_button.png" /></center>

Normally any mouse button will pop up a menu and it is lined up below the
button as shown in the picture. However an Fl::MenuButton may also control a
pop-up menu. This is done by setting the type(). If type() is zero a normal
menu button is produced. If it is nonzero then this is a pop-up menu. The bits
in type() indicate what mouse buttons pop up the menu (see
Fl::MenuButton->popup_buttons).

The menu will also pop up in response to shortcuts indicated by putting a '&'
character in the label().

Typing the shortcut() of any of the menu items will cause callbacks exactly
the same as when you pick the item with the mouse. The '&' character in menu
item names are only looked at when the menu is popped up, however.

When the user picks an item off the menu, the item's callback is done with the
menu_button as the Fl::Widget argument. If the item does not have a callback
the menu_button's callback is done instead.

=head1 Methods

Fl::MenuButton inherits from Fl::Menu and Fl::Widget. On top of that, it
exposes the following methods...

=head2 new(...)

    my $ic_a = Fl::MenuButton->new(0, 0, 250, 500, 'Important Stuff');
    my $ic_b = Fl::MenuButton->new(0, 0, 250, 500);

The constructor creates a new widget using the given position, size, and
label.

The default boxtype is FL_UP_BOX.

The destructor removes the widget.

=cut

xs {name        => 'new',
    definitions => [
            {required => [[qw[int x]], [qw[int y]], [qw[int w]], [qw[int h]]],
             optional => [['const char *', 'label', ' 0']],
             returns  => 'Fl_Menu_Button *'
            }
    ]
};
xs {name        => 'DESTROY',
    definitions => [{returns => 'void'}]
};
xs {name        => 'draw',
    definitions => [{returns  => 'void' }
    ]
};

lib/Fl/MenuButton.pod  view on Meta::CPAN

Act exactly as though the user clicked the button or typed the shortcut key.

The menu appears, it waits for the user to pick an item, and if they pick one
it sets value() and does the callback or sets changed() as described above.
The menu item is returned or NULL if the user dismisses the menu.

=cut

xs {name        => 'popup',
    definitions => [
        {returns => 'const Fl_Menu_Item *'}
    ]
};

=pod

=head1 LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify

t/55_fl_menu.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More 0.98;
use lib '../blib/', '../blib/lib', '../lib';
use Fl;
# Virtual class so no new(...)
#
isa_ok 'Fl::Menu', 'Fl::Widget';
#
can_ok 'Fl::Menu', $_ for qw[add clear clear_submenu copy down_box
    find_index find_item global insert item_pathname menu mode mvalue picked
    remove replace shortcut size test_shortcut text textcolor textfont
    textsize value];
#
done_testing;

t/56_fl_menubutton.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More 0.98;
use lib '../blib/', '../blib/lib', '../lib';
use Fl;
#
my $mnubtn = new_ok 'Fl::MenuButton' => [100, 200, 340, 180], 'menu button w/o label';
my $mnubtn2 = new_ok
    'Fl::MenuButton' => [100, 200, 340, 180, 'title!'],
    'menu button w/ label';
#
isa_ok $mnubtn, 'Fl::Menu';
#
Fl::delete_widget($mnubtn2);
is $mnubtn2, undef, '$mnubtn2 is now undef';
undef $mnubtn;
is $mnubtn, undef, '$mnubtn is now undef';
#
done_testing;

xs/Fl_cxx.template  view on Meta::CPAN

                croak("{{arg.0}} is not an HASH reference");
            }
        } STMT_END;
        {%when 'Fl_Widget *' %}CTX * /*{{arg.0 | split: ' ' | first | replace: '_', '__'}}*/ {{arg.1}};
        if ( sv_isobject( ST({{st.position}}) ) || ( SvTYPE( SvRV( ST({{st.position}}) ) ) == SVt_PVMG ) ) {
            IV tmp = SvIV((SV*)SvRV(ST({{st.position}})));
            {{arg.1}} = INT2PTR(CTX * /*{{ arg.0 | split:' ' | first | replace:'_', '__'}}*/, tmp);
        }
        else
            croak("Expected object. Got a non-object?!");
        {%when 'Fl_Menu_Item *' %}CTX * /*{{arg.0 | replace: '_', | replace_first: 'Fl', 'Fl__' | replace: '\*',}}*/ {{arg.1}};
        if ( sv_isobject( ST({{st.position}}) ) || ( SvTYPE( SvRV( ST({{st.position}}) ) ) == SVt_PVMG ) ) {
            IV tmp = SvIV((SV*)SvRV(ST({{st.position}})));
            {{arg.1}} = INT2PTR(CTX */*{{ arg.0 | split:' ' | first | replace: '_', | replace_first: 'Fl', 'Fl__'}}*/, tmp);
        }
        else
            croak("Expected object. Got a non-object?!");
        {%when 'int'         %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'short'       %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'float'       %}{{arg | join: ' '}} = ({{arg.0}})SvNV(ST({{st.position}}));
        {%when 'double'      %}{{arg | join: ' '}} = ({{arg.0}})SvNV(ST({{st.position}}));

xs/Fl_cxx.template  view on Meta::CPAN

                    {%when 'Fl_Window *' %}
                        CTX * ctx;
                        Newx(ctx, 1, CTX);
                        ctx->cp_ctx    = (Fl_Widget *) RETVAL;
                        {
                            SV * RETVALSV;
                            RETVALSV = sv_newmortal();
                            sv_setref_pv(RETVALSV, object2package(ctx), (void*)ctx);
                            ST(0) = RETVALSV;
                        }
                    {%when 'Fl_Menu_Button *' %}
                        CTX * ctx;
                        Newx(ctx, 1, CTX);
                        ctx->cp_ctx    = (Fl_Widget *) RETVAL;
                        {
                            SV * RETVALSV;
                            RETVALSV = sv_newmortal();
                            sv_setref_pv(RETVALSV, object2package(ctx), (void*)ctx);
                            ST(0) = RETVALSV;
                        }
                    {%when 'const Fl_Menu_Item *' %}
                        CTX * ctx;
                        Newx(ctx, 1, CTX);
                        ctx->cp_ctx    = (Fl_Widget *) RETVAL;

                        {
                            SV * RETVALSV;
                            RETVALSV = sv_newmortal();
                            sv_setref_pv(RETVALSV, object2package(ctx), (void*)ctx);
                            ST(0) = RETVALSV;
                        }

xs/Fl_ext.cxx  view on Meta::CPAN

#include <FL/Fl_Return_Button.H>
#include <FL/Fl_Round_Button.H>
#include <FL/Fl_Toggle_Button.H>
#include <FL/Fl_Widget.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Secret_Input.H>
#include <FL/Fl_Float_Input.H>
#include <FL/Fl_Int_Input.H>
#include <FL/Fl_Multiline_Input.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Input_Choice.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Scrollbar.H>

void         _cache( const char * ptr, const char * cls );
void         _cache( void       * ptr, const char * cls );
const char * _cache( const char * ptr );
const char * _cache( void       * ptr );
void  _delete_cache( void       * ptr );
void  _delete_cache( const char * ptr );

const char * object2package (CTX * w) {

xs/Fl_ext.cxx  view on Meta::CPAN

     else if ( dynamic_cast<Fl_Button               *>(w) ) { package = "Fl::Button"; }
     else if ( dynamic_cast<Fl_Window               *>(w) ) { package = "Fl::Window"; }
     else if ( dynamic_cast<Fl_Group                *>(w) ) { package = "Fl::Group";  }
     else if ( dynamic_cast<Fl_Chart                *>(w) ) { package = "Fl::Chart";  }

     else if ( dynamic_cast<Fl_Multiline_Input      *>(w) ) { package = "Fl::MultilineInput";  }
     else if ( dynamic_cast<Fl_Int_Input            *>(w) ) { package = "Fl::IntInput";  }
     else if ( dynamic_cast<Fl_Float_Input          *>(w) ) { package = "Fl::FloatInput";  }
     else if ( dynamic_cast<Fl_Secret_Input         *>(w) ) { package = "Fl::SecretInput";  }
     else if ( dynamic_cast<Fl_Input                *>(w) ) { package = "Fl::Input";  }
     else if ( dynamic_cast<      Fl_Menu_Item      *>(w) ||
               dynamic_cast<const Fl_Menu_Item      *>(w) ) { package = "Fl::MenuItem";  }
     else if ( dynamic_cast<Fl_Input_Choice         *>(w) ) { package = "Fl::InputChoice";  }
     else if ( dynamic_cast<Fl_Menu_Button          *>(w) ) { package = "Fl::MenuButton";  }
     else if ( dynamic_cast<Fl_Scrollbar            *>(w) ) { package = "Fl::Scrollbar";  }

     return package;
}



( run in 0.631 second using v1.01-cache-2.11-cpan-49f99fa48dc )