All pastes #757796 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-01 16:52 UTC
rendered paste body
**************************code for the window class*************************************************************
*******************************I removed some useless stuff *********************************************************

#the basic window class, from which every window will be derived.

package Window;
use Moose;
extends (qw(Object));

#position for x in pixel
has 'x' => (
	is => 'rw',
 	required =>1,
	isa => 'Num',
	default => 0
);

#position for y in pixel
has 'y' => (
	is => 'rw',
 	required =>1,
	isa => 'Num',
	default=> 0
);


#widgets list
has 'content' => (
	is =>'rw',
	required =>0,
	isa => 'ArrayRef'
);

#return value for the window, once set it will close it.
has 'answer' => (
	is => 'rw',
	required => 0,
	isa => 'Any'
);

#constructor.
sub BUILD {
	my ( $self )  = @_ ;
	#every window get a close button.
        my $widget = new Widget name =>"close",
                        type => "icon",
                        x    => 0,
                        y    => 0,
                        img  => 'close',
                        xsize => 16,
                        ysize => 16 ; #useless again.
			window => $self;


        my $wt;
        push @$wt,$widget;
	$self->content( $wt );
	
}



#show the full window
sub show($) {

}


return 1;






*******************************code for the widget class ************************************************************
*******************************I removed some useless stuff *********************************************************
package Widget;
use Moose;
#use graphic;
extends (qw(Object));

has 'x' => (
        is => 'rw',
        required =>1,
        isa => 'Num',
        default => 0
);
has 'y' => (
        is => 'rw',
        required =>1,
        isa => 'Num',
        default=> 0
);

has 'window' => (
        is  => 'rw',
        isa => 'CodeRef',
        default => undef
);