1 | # +-----------------------------------------------------------------------+ |
---|
2 | # | pLoader - a Perl photo uploader for Piwigo | |
---|
3 | # +-----------------------------------------------------------------------+ |
---|
4 | # | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org | |
---|
5 | # +-----------------------------------------------------------------------+ |
---|
6 | # | This program is free software; you can redistribute it and/or modify | |
---|
7 | # | it under the terms of the GNU General Public License as published by | |
---|
8 | # | the Free Software Foundation | |
---|
9 | # | | |
---|
10 | # | This program is distributed in the hope that it will be useful, but | |
---|
11 | # | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
12 | # | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
13 | # | General Public License for more details. | |
---|
14 | # | | |
---|
15 | # | You should have received a copy of the GNU General Public License | |
---|
16 | # | along with this program; if not, write to the Free Software | |
---|
17 | # | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
18 | # | USA. | |
---|
19 | # +-----------------------------------------------------------------------+ |
---|
20 | package Uploader::GUI::wxHtmlWindow; |
---|
21 | |
---|
22 | use strict; |
---|
23 | use Wx::Html; |
---|
24 | use base qw(Wx::Dialog); |
---|
25 | use Wx qw/ |
---|
26 | wxTheApp |
---|
27 | wxDefaultSize |
---|
28 | wxDefaultPosition |
---|
29 | wxALIGN_CENTER_VERTICAL |
---|
30 | wxALL |
---|
31 | wxVERTICAL |
---|
32 | wxLIST_AUTOSIZE |
---|
33 | wxDEFAULT_DIALOG_STYLE |
---|
34 | wxMAXIMIZE_BOX |
---|
35 | wxMINIMIZE_BOX |
---|
36 | wxRESIZE_BORDER |
---|
37 | wxSTAY_ON_TOP |
---|
38 | wxGROW |
---|
39 | /; |
---|
40 | |
---|
41 | sub new { |
---|
42 | my ($class, $params) = @_; |
---|
43 | |
---|
44 | my $this = $class->SUPER::new( |
---|
45 | undef, |
---|
46 | -1, |
---|
47 | $params->{caption}, |
---|
48 | wxDefaultPosition, |
---|
49 | wxDefaultSize, |
---|
50 | wxDEFAULT_DIALOG_STYLE| |
---|
51 | wxMAXIMIZE_BOX| |
---|
52 | wxMINIMIZE_BOX| |
---|
53 | wxSTAY_ON_TOP| |
---|
54 | wxRESIZE_BORDER |
---|
55 | ); |
---|
56 | $this->{sizev} = Wx::BoxSizer->new( wxVERTICAL ); |
---|
57 | |
---|
58 | $this->{html} = Wx::HtmlWindow->new( |
---|
59 | $this, |
---|
60 | -1, |
---|
61 | wxDefaultPosition, |
---|
62 | $params->{size}, |
---|
63 | ); |
---|
64 | |
---|
65 | |
---|
66 | $this->{html}->SetPage( |
---|
67 | $params->{html} |
---|
68 | ); |
---|
69 | |
---|
70 | # layout |
---|
71 | $this->{sizev}->Add( $this->{html}, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 2 ); |
---|
72 | $this->SetSizer( $this->{sizev} ); |
---|
73 | $this->{sizev}->SetSizeHints( $this ); |
---|
74 | |
---|
75 | Wx::Event::EVT_HTML_LINK_CLICKED( $this, $this->{html}, \&OnHtmlLinkClicked); |
---|
76 | |
---|
77 | return $this; |
---|
78 | } |
---|
79 | |
---|
80 | sub InitHrefCallbacks { |
---|
81 | my ( $self, $callbacks ) = @_; |
---|
82 | |
---|
83 | $callbacks ||={}; |
---|
84 | $self->{HrefCallbacks} = $callbacks ; |
---|
85 | } |
---|
86 | |
---|
87 | sub OnHtmlLinkClicked { |
---|
88 | my ( $self, $event ) = @_; |
---|
89 | |
---|
90 | my $href = $event->GetLinkInfo->GetHref, "\n"; |
---|
91 | |
---|
92 | $self->{HrefCallbacks}->{$href}->() if exists $self->{HrefCallbacks}->{$href}; |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | 1; |
---|
97 | |
---|