line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::XUL::Window; |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# Copyright Philip Gwyn 2007-2010. All rights reserved. |
4
|
|
|
|
|
|
|
# Based on code Copyright 2003-2004 Ran Eilam. All rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
21
|
|
|
21
|
|
72
|
use strict; |
|
21
|
|
|
|
|
25
|
|
|
21
|
|
|
|
|
476
|
|
7
|
21
|
|
|
21
|
|
67
|
use warnings; |
|
21
|
|
|
|
|
19
|
|
|
21
|
|
|
|
|
387
|
|
8
|
21
|
|
|
21
|
|
56
|
use Carp; |
|
21
|
|
|
|
|
20
|
|
|
21
|
|
|
|
|
904
|
|
9
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
73
|
use POE::XUL::Node; |
|
21
|
|
|
|
|
21
|
|
|
21
|
|
|
|
|
437
|
|
11
|
21
|
|
|
21
|
|
6950
|
use POE::XUL::TWindow; |
|
21
|
|
|
|
|
41
|
|
|
21
|
|
|
|
|
488
|
|
12
|
21
|
|
|
21
|
|
88
|
use Scalar::Util qw( blessed ); |
|
21
|
|
|
|
|
20
|
|
|
21
|
|
|
|
|
1025
|
|
13
|
|
|
|
|
|
|
|
14
|
21
|
|
|
21
|
|
83
|
use constant DEBUG => 0; |
|
21
|
|
|
|
|
22
|
|
|
21
|
|
|
|
|
990
|
|
15
|
|
|
|
|
|
|
|
16
|
21
|
|
|
21
|
|
82
|
use base qw( POE::XUL::Node ); |
|
21
|
|
|
|
|
31
|
|
|
21
|
|
|
|
|
2795
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.0601'; |
19
|
|
|
|
|
|
|
our $CM; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
############################################################## |
22
|
5
|
|
|
5
|
0
|
32
|
sub is_window { 1 } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub import |
25
|
|
|
|
|
|
|
{ |
26
|
22
|
|
|
22
|
|
2987
|
my( $package ) = @_; |
27
|
22
|
|
|
|
|
38
|
my $caller = caller(); |
28
|
21
|
|
|
21
|
|
94
|
no strict 'refs'; |
|
21
|
|
|
|
|
28
|
|
|
21
|
|
|
|
|
6276
|
|
29
|
22
|
|
|
|
|
491
|
*{ $caller . "::Window" } = |
30
|
22
|
|
|
0
|
|
62
|
sub { return scalar $package->new( tag=>'Window', @_ ) }; |
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
############################################################## |
34
|
|
|
|
|
|
|
## DOM-like window.open( $name, $features ); |
35
|
|
|
|
|
|
|
sub open |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
1
|
|
my( $self, $winID, $features ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# TODO: make sure $winID doesn't already exist |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# popup_window will allocate a winID if one doesn't exist already |
42
|
0
|
|
|
|
|
|
$winID = $POE::XUL::Node::CM->popup_window( $winID, $features ); |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
return unless $INC{'POE/XUL/Application.pm'}; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $server = POE::XUL::Application::server(); |
47
|
0
|
0
|
|
|
|
|
return unless $server; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Create a temporary window to hold the events until 'connect' |
50
|
0
|
|
|
|
|
|
my $twindow = POE::XUL::TWindow->new( %$features, id => $winID ); |
51
|
0
|
|
|
|
|
|
$server->attach_subwindow( $twindow ); |
52
|
0
|
|
|
|
|
|
return $twindow; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
############################################################## |
56
|
|
|
|
|
|
|
## DOM-like window.close() |
57
|
|
|
|
|
|
|
sub close |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# carp "$self.close"; |
62
|
0
|
|
|
|
|
|
$POE::XUL::Node::CM->close_window( $self->id ); |
63
|
|
|
|
|
|
|
# this will cause a close instruction, which closes then window |
64
|
|
|
|
|
|
|
# which will provoke 'disconnect' request, which is where the |
65
|
|
|
|
|
|
|
# window is finnaly GCed |
66
|
0
|
|
|
|
|
|
$self->closed( 1 ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
############################################################## |
70
|
|
|
|
|
|
|
sub getElementById |
71
|
|
|
|
|
|
|
{ |
72
|
0
|
|
|
0
|
1
|
|
my( $self, $id ) = @_; |
73
|
0
|
0
|
|
|
|
|
return $id if blessed $id; # act like prototype's $() |
74
|
0
|
0
|
|
|
|
|
croak "getElementById may only be invoked on a Window" |
75
|
|
|
|
|
|
|
unless $self->is_window; |
76
|
0
|
|
|
|
|
|
return $POE::XUL::Node::CM->getElementById( $id ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
*node = \&getElementById; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
############################################################## |
81
|
|
|
|
|
|
|
sub dispose |
82
|
|
|
|
|
|
|
{ |
83
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
84
|
0
|
|
|
|
|
|
my $id = $self->id; |
85
|
0
|
|
|
|
|
|
$self->SUPER::dispose; |
86
|
0
|
0
|
|
|
|
|
return unless $POE::XUL::Node::CM; |
87
|
0
|
|
|
|
|
|
$POE::XUL::Node::CM->unregister_window( $self ); |
88
|
0
|
|
|
|
|
|
$self->{attributes} = {}; |
89
|
0
|
|
|
|
|
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
*destroy = \&dispose; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |