| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################# |
|
2
|
|
|
|
|
|
|
## Name: lib/Wx/DemoModules/wxHtmlDynamic.pm |
|
3
|
|
|
|
|
|
|
## Purpose: Dynamically generated HTML (via Wx::FsHandler) |
|
4
|
|
|
|
|
|
|
## Author: Mattia Barbon |
|
5
|
|
|
|
|
|
|
## Modified by: |
|
6
|
|
|
|
|
|
|
## Created: 18/04/2002 |
|
7
|
|
|
|
|
|
|
## RCS-ID: $Id: wxHtmlDynamic.pm 3129 2011-11-21 22:07:47Z mdootson $ |
|
8
|
|
|
|
|
|
|
## Copyright: (c) 2002, 2006 Mattia Barbon |
|
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or |
|
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself |
|
11
|
|
|
|
|
|
|
############################################################################# |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1520
|
use Wx::Html; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Wx::FS; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Wx::DemoModules::wxHtmlDynamic; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use strict; |
|
19
|
|
|
|
|
|
|
use base qw(Wx::Panel); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Wx qw(:sizer); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
|
24
|
|
|
|
|
|
|
my( $class, $parent ) = @_; |
|
25
|
|
|
|
|
|
|
my $panel = $class->SUPER::new( $parent, -1 ); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Wx::FileSystem::AddHandler( Wx::DemoModules::wxHtmlDynamic::FSHandler->new ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $sizer = Wx::BoxSizer->new( wxVERTICAL ); |
|
30
|
|
|
|
|
|
|
my $htmlwin = Wx::HtmlWindow->new( $panel, -1 ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$sizer->Add( $htmlwin, 1, wxGROW ); |
|
33
|
|
|
|
|
|
|
$panel->SetSizer( $sizer ); |
|
34
|
|
|
|
|
|
|
$htmlwin->LoadPage( "my://foo.bar/baz" ); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return $panel; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub add_to_tags { 'windows/html' } |
|
40
|
|
|
|
|
|
|
sub title { 'Dynamic html' } |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
package Wx::DemoModules::wxHtmlDynamic::FSHandler; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use strict; |
|
45
|
|
|
|
|
|
|
use base qw(Wx::PlFileSystemHandler); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use IO::Scalar; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new { |
|
50
|
|
|
|
|
|
|
my $class = shift; |
|
51
|
|
|
|
|
|
|
my $this = $class->SUPER::new( @_ ); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return $this; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub CanOpen { |
|
57
|
|
|
|
|
|
|
my $file = $_[1]; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return scalar( $file =~ m{^my://} ); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# no findfirst/findnext, not needed for this example |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @f; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub OpenFile { |
|
67
|
|
|
|
|
|
|
my( $this, $fs, $location ) = @_; |
|
68
|
|
|
|
|
|
|
my $loc = $location; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$loc =~ s{^my://}{}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $text = join '', |
|
73
|
|
|
|
|
|
|
map { qq{}.( $loc ne $_ ? $_ : 'Here' ).qq{ } } |
|
74
|
|
|
|
|
|
|
( 'foo.bar/baz', 'Here, there, everywhere', |
|
75
|
|
|
|
|
|
|
'Somewhere else', 'A galaxy far, far away' ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $string = <
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$loc |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$loc |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Something useful here
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Links: |
|
88
|
|
|
|
|
|
|
$text |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
EOT |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $mimetype = 'text/html'; |
|
95
|
|
|
|
|
|
|
my $fh = IO::Scalar->new( \$string ); |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# we could also pass a charset as part of |
|
98
|
|
|
|
|
|
|
# the mimetype and use IO::String or open |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# my $mimetype = 'text/html; charset=utf-8'; |
|
101
|
|
|
|
|
|
|
# my $fh = IO::String->new( $string ); |
|
102
|
|
|
|
|
|
|
# open my $fh, '<', \$string; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# If our mimetype is 'text/html' and we use some other tied method, |
|
105
|
|
|
|
|
|
|
# it must implement $fh->sref that returns a reference to the |
|
106
|
|
|
|
|
|
|
# underlying scalar OR we must pass a charset as part of the mimetype. |
|
107
|
|
|
|
|
|
|
# This is because of the way the HTMLParser requests the size of the |
|
108
|
|
|
|
|
|
|
# input 'file' if no charset is given. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $f = Wx::PlFSFile->new( $fh, $location, $mimetype, '' ); |
|
111
|
|
|
|
|
|
|
return $f; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |