Fl
view release on metacpan or search on metacpan
- Begin work on custom widgets (undocumented alpha in this version)
- draw() can be overridden
- extends() creates inheratence trees and handles widget registration
- handle() handles specific events. Ugh... See the docs...
- 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
lib/Fl/ValueOutput.pod
lib/Fl/ValueSlider.pod
lib/Fl/Widget.pod
lib/Fl/Window.pod
minil.toml
t/00_compile.t
t/01_hello_world.t
t/02_fl_event_can_ok.t
t/03_fl_enumerations_can_ok.t
t/04_fl_color_can_ok.t
t/05_fl_clipboard_can_ok.t
t/21_fl_box.t
t/22_fl_button.t
t/23_fl_lightbutton.t
t/24_fl_checkbutton.t
t/25_fl_returnbutton.t
t/26_fl_repeatbutton.t
t/27_fl_roundbutton.t
t/28_fl_radioroundbutton.t
t/29_fl_radiobutton.t
t/30_fl_radiolightbutton.t
lib/Fl/Clipboard.pod view on Meta::CPAN
include 'FL/Fl.H';
=pod
=head1 NAME
Fl::Clipboard - Global Copy/Cut/Paste Functions
=head1 Synopsis
use Fl qw[:clipboard];
=head1 Description
This file contains functions related to text copying, cutting, and pasting.
All functions can be imported with the C<:clipboard> import tag.
=pod
=head1 Methods
Here we go...
=head2 C<clipboard_contains(...)>
my $text = Fl::clipboard_contains(Fl::clipboard_plain_text);
Returns non 0 if the clipboard contains data matching type. Supported types
are C<text/plain> and C<image>.
=cut
xs {name => 'Fl::clipboard_contains',
definitions => [{required => [['const char *', 'type']], returns => 'int' }
],
export => [qw[clipboard]]
};
=pod
=head2 C<copy(...)>
Fl::copy('words');
Fl::copy($raw, 1);
Fl::copy($stuff, $destination);
Copies the data pointed in C<$stuff> to the selection buffer
(C<$destination == 0>) or the clipboard (C<$destination == 1>).
The selection buffer is used for middle-mouse pastes and for drag-and-drop
selections. The clipboard is used for traditional copy/cut/paste operations.
=cut
xs {name => 'Fl::copy',
definitions => [{
required => [['const char *', 'stuff']],
optional => [[qw[int destination], ' 0']],
c_args => 'stuff, strlen(stuff), destination, Fl::clipboard_plain_text',
returns => 'void'
}
],
export => [qw[clipboard]]
};
=pod
=head2 C<dnd( )>
Fl::dnd( );
Initiate a Drag And Drop operation.
The selection buffer should be filled with relevant data before calling this
method. Fl will then initiate the system wide drag and drop handling. Dropped
data will be marked as text.
Create a selection first using C<Fl::copy(...)>.
=cut
xs {name => 'Fl::dnd',
definitions => [{ returns => 'int' }],
export => [qw[clipboard]]
};
=pod
=head2 C<paste(...)>
Fl::paste( $widget, $source );
Fl::paste( $widget, $source, $type );
Pastes the data from the selection buffer (C<$source == 0>) or the clipboard
(C<$source is 1>) into receiver.
If C<$source == 1>, the optional C<$type> argument indicates what type of data
is requested from the clipboard. At present, C<text/plain> (requesting text
data) and C<image> (requesting image data) are possible. Set things up so the
handle function of the receiver widget will be called with an C<FL_PASTE>
event some time in the future if the clipboard does contain data of the
requested type. During processing of this event, and if type is C<text/plain>,
the text data from the specified source are in C<Fl::event_text()> with UTF-8
encoding, and the number of characters in C<Fl::event_length()>. If type is
C<image>,C<Fl::event_clipboard()> returns an Fl::Image object. The receiver
should be prepared to be called directly by this, or for it to happen later,
or possibly not at all. This allows the window system to take as long as
necessary to retrieve the paste buffer (or even to screw up completely)
without complex and error-prone synchronization code in Fl.
The selection buffer is used for middle-mouse pastes and for drag-and-drop
selections. The clipboard is used for traditional copy/cut/paste operations.
Platform details for image data:
=over
=item Unix/Linux platform: Image data in PNG or BMP formats are recognized.
Requires linking with the fltk_images library.
=item MSWindows platform: Both bitmap and vectorial (Enhanced metafile) data
from clipboard can be pasted as image data.
=item Mac OS X platform: Both bitmap (TIFF) and vectorial (PDF) data from
clipboard can be pasted as image data.
=back
=cut
xs {name => 'Fl::paste',
definitions => [{
required => [['Fl_Widget *', 'receiver'], [qw[int source]]],
optional => [['const char *', 'type', 'Fl::clipboard_plain_text']],
c_args => '* receiver->cp_ctx, source, type',
returns => 'void' }],
export => [qw[clipboard]]
};
=pod
=head2 C<selection(...)>
Fl::selection( $widget, $text );
Changes the current selection.
lib/Fl/Clipboard.pod view on Meta::CPAN
C<event_text()>). The C<selection_owner()> widget is set to the passed owner.
=cut
xs {name => 'Fl::selection',
definitions => [{
required => [['Fl_Widget *', 'owner'], ['const char *', 'text']],
optional => [['int', 'len', 'strlen(text)']],
c_args => '* owner->cp_ctx, text, len',
returns => 'void' }],
export => [qw[clipboard]]
};
# TODO:
# Fl::add_clipboard_notify(...)
=pod
=head1 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.
lib/Fl/Enumerations.pod view on Meta::CPAN
=item FL_SHORTCUT - The user pressed a shortcut key.
=item FL_DEACTIVATE - The widget has been deactivated.
=item FL_ACTIVATE - The widget has been activated.
=item FL_HIDE - The widget has been hidden.
=item FL_SHOW - The widget has been shown.
=item FL_PASTE - The widget should paste the contents of the clipboard.
=item FL_SELECTIONCLEAR - The widget should clear any selections made for the clipboard.
=item FL_MOUSEWHEEL - The horizontal or vertical mousewheel was turned.
=item FL_DND_ENTER - The mouse pointer entered a widget dragging data.
=item FL_DND_DRAG - The mouse pointer was moved dragging data.
=item FL_DND_LEAVE - The mouse pointer left a widget still dragging data.
=item FL_DND_RELEASE - Dragged data is about to be dropped.
lib/Fl/Input.pod view on Meta::CPAN
<table width="90%" border="1" summary="Fl::Input platform specific keyboard bindings.">
<tr>
<td nowrap="NOWRAP" width="1%"><b> Windows/Linux </b> </td><td nowrap="NOWRAP" width="1%"><b> Mac </b> </td><td nowrap="NOWRAP"><p class="starttd"><b> Function </b></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td nowrap="NOWRAP"><b> ^A </b> </td><td nowrap="NOWRAP"><b> Command-A </b> </td><td><p class="starttd"><b>Selects all text in the widget.</b></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td nowrap="NOWRAP"><b> ^C </b> </td><td nowrap="NOWRAP"><b> Command-C </b> </td><td><p class="starttd"><b>Copy the current selection to the clipboard.</b></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td nowrap="NOWRAP"><b> ^I </b> </td><td nowrap="NOWRAP"><b> ^I </b> </td><td><p class="starttd"><b>Insert a tab.</b></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td nowrap="NOWRAP"><b> ^J </b> </td><td nowrap="NOWRAP"><b> ^J </b> </td><td><p class="starttd"><b>Insert a Line Feed.</b> <br/>
(Similar to literal 'Enter' character)</p>
<p class="endtd"></p>
lib/Fl/Input.pod view on Meta::CPAN
<tr>
<td nowrap="NOWRAP"><b> ^L </b> </td><td nowrap="NOWRAP"><b> ^L </b> </td><td><p class="starttd"><b>Insert a Form Feed.</b></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td nowrap="NOWRAP"><b> ^M </b> </td><td nowrap="NOWRAP"><b> ^M </b> </td><td><p class="starttd"><b>Insert a Carriage Return.</b></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td nowrap="NOWRAP"><b> ^V,<br/>
Shift-Insert </b> </td><td nowrap="NOWRAP"><b> Command-V </b> </td><td><p class="starttd"><b>Paste the clipboard.</b> <br/>
(Macs keyboards don't have "Insert" keys, but if they did, Shift-Insert would work)</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td nowrap="NOWRAP"><b> ^X,<br/>
Shift-Delete </b> </td><td nowrap="NOWRAP"><b> Command-X,<br/>
Shift-Delete </b> </td><td><p class="starttd"><b>Cut.</b> <br/>
Copy the selection to the clipboard and delete it. (If there's no selection, Shift-Delete acts like Delete)</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td nowrap="NOWRAP"><b> ^Z </b> </td><td nowrap="NOWRAP"><b> Command-Z </b> </td><td><p class="starttd"><b>Undo.</b> <br/>
This is a single-level undo mechanism, but all adjacent deletions and insertions are concatenated into a single "undo". Often this will undo a lot more than you expected.</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td nowrap="NOWRAP"><b> Shift-^Z </b> </td><td nowrap="NOWRAP"><b> Shift-Command-Z </b> </td><td><p class="starttd"><b>Redo.</b> <br/>
Currently same behavior as ^Z. Reserved for future multilevel undo/redo.</p>
lib/Fl/Input.pod view on Meta::CPAN
};
xs {name => 'handle',
definitions => [{required => [[qw[int event]]], returns => 'int' }
]
};
=pod
=head2 copy(...)
Put the current selection into the clipboard.
my $ok = $input->copy(1); # into clipboard #1
This function copies the current selection between C<mark()> and C<position()>
into the specified clipboard. This does not replace the old clipcoard contents
if C<position()> and C<mark()> are equal.
Clipboard C<0> maps to the current text selection and clipboard C<1> maps to
the OS's cut/paste clipboard.
Returns a true value if the selection was copied sucessfully.
See also C<Fl::copy(...)>.
=cut
xs {name => 'copy',
definitions => [{required => [[qw[int clipboard]]],
returns => 'int'
}
]
};
=pod
=head2 copy_cuts()
Copys the I<yank> buffer to the clipboard.
$input->copy_cuts();
This method copies all the previous contiguous cuts from the undo information
to the clipboard. This functions implements the ^K shortcut key.
Returns a false value if the clipboard is unchanged.
=cut
xs {name => 'copy_cuts',
definitions => [{returns => 'int'}]
};
=pod
=head2 cursor_color(...)
lib/Fl/Input.pod view on Meta::CPAN
returns => 'void'
},
{returns => 'Fl_Color'}
]
};
=pod
=head2 cut(...)
Deletes text from the widget I<without> storing it in the clipboard.
$input->cut();
Deletes the current selection.
$input->cut(24);
Deletes the next I<N> bytes (here, 24) rounded to characters before or after
the cursor. Negative numbers will cut characters to the left of the cursor.
$input->cut(20, 25);
Deletes all characters between indexs C<$a> and C<$b> (here, 20 and 25).
To use the clipboard, you may call C<copy()> first or C<copy_cuts()> after
this call.
Returns 0 if no data was cut.
=cut
xs {name => 'cut',
definitions => [{returns => 'int'},
{required => [['int', 'bytes']],
returns => 'int'
lib/Fl/Input.pod view on Meta::CPAN
Sets the curosr position and mark.
The above example is the same as callingC<position($p + 2, $p + 2)>.
$input->position($p + 2, 10);
Sets the index for both the cursor and mark.
The input widget maintains two pointers into the string. The position is where
the cursor is. The mark is the other end of the selected text. If they are
equal then there is no selection. Changing this does not affect the clipboard.
Use C<copy()> to do that.
The return value is zero if no positions were changed.
=cut
xs {name => 'position',
definitions => [{returns => 'int'},
{required => [['int', 'position']],
returns => 'int'
t/05_fl_clipboard_can_ok.t view on Meta::CPAN
use strict;
use warnings;
use Test::More 0.98;
use lib '../blib/', '../blib/lib', '../lib';
use Fl qw[:clipboard];
#
can_ok 'Fl', 'clipboard_contains';
can_ok 'Fl', 'copy';
can_ok 'Fl', 'dnd';
can_ok 'Fl', 'paste';
can_ok 'Fl', 'selection';
# Check :event import tag
can_ok 'main', 'clipboard_contains';
can_ok 'main', 'copy';
can_ok 'main', 'dnd';
can_ok 'main', 'selection';
#
done_testing;
( run in 2.604 seconds using v1.01-cache-2.11-cpan-84e82930d8c )