im prepareing version 0.95
coming to the nitty gritty of tie objects a plan to add callbacks to tie
additional subs to the FETCH and STORE. from the future doc:


=head1 SYNOPSIS

        use Tie::Wx::Widget;

        tie $tiedwidget, Tie::Wx::Widget, $widget;

        say $tiedwidget;       # instead of say $widgetref->GetValue;

        $tiedwidget = 7;       # instead of $widgetref->SetValue(7);

        untie $tiedwidget;     # now $tiedwidget is a normal scalar again (not 
required)


=head1 CALLBACKS

Often are the widget values couples with each other. For instance in
L<App::Spirograph> is a slider which max value is dependent on the value
of another slider. Once you know this, why keep track of it and change
the range by hand any given time?

        tie $tslider,
                Tie::Wx::Widget,
                $slider,
                sub { $subslider->SetRange(1,$_) };

The complete API is:

        tie $tiedwidget,
                Tie::Wx::Widget,
                $widget,
                &$do_when_assign,
                &$do_when_retrieve;

if you have any idea what to fix or add. please let me know.
this is just the beginning :)

=head1 WARNINGS

Your program will C<die>, if you don't provide a proper Wx widget,
that has a GetValue and SetValue method, or the callbacks are no proper
coderef. Unless you init with:

        use Tie::Wx::Widget 'warn_mode';

or do later:

        Tie::Wx::Widget::warn_mode();

Then will be called C<warn> instead of C<die>.
But you can switch anytime back with:

        Tie::Wx::Widget::die_mode();

Wich has only effect for all variables tied afterwards.
Because if the Wx ref is not good, there will be no tying anyway.


=head1 INTERNALS

        # how to get a reference to the Tie::Wx::Widget object ?
        $tieobject = tie $tiedwidget, Tie::Wx::Widget, $widget;
        $tieobject = tied $tiedwidget;

        # now you even can:
        $tieobject->FETCH()
        # aka:
        $tieobject->{'widget'}->GetValue;
        # or do any other method on the wx object
        $tieobject->{'w'}->Show(0);
        # works too (hides the widget)
        $tieobject->STORE(7);

        # doesn't do anything
        $tieobject->DESTROY()

herbert aka lichtkind

Am 29.05.2011 23:39, schrieb herbert breunung:
> hello friendly guys,
> the idea should be self explenatory.
> from the docs:
> 
> 
>     use Tie::Wx::Widget;
> 
>     tie $tiedwidget, Tie::Wx::Widget, $widgetref;
> 
>     # instead of say $widgetref->GetValue;
>     say  $tiedwidget;
> 
>     # instead of $widgetref->SetValue('7');
>       $tiedwidget = 7;
> 
>     untie $tiedwidget;
> 
> hope you like and use it.
> more will come.
> 
> sir lichtkind
> 

Reply via email to