diff --git a/fhem/FHEM/55_InfoPanel.pm b/fhem/FHEM/55_InfoPanel.pm index 8db79e13b..cd48cef88 100644 --- a/fhem/FHEM/55_InfoPanel.pm +++ b/fhem/FHEM/55_InfoPanel.pm @@ -5,14 +5,12 @@ # forked from 02_RSS.pm by Dr. Boris Neubert # ############################################## -# $Id: $ +# $Id: 55_InfoPanel.pm 7910 2015-02-07 18:29:59Z betateilchen $ package main; use strict; use warnings; -use MIME::Base64; -use Image::Info qw(image_info dim); #use Data::Dumper; use feature qw/switch/; @@ -24,6 +22,8 @@ my @cmd_valign= qw(tvalign ivalign); my @valid_valign = qw(auto baseline middle center hanging); my @valid_halign = qw(start middle end); +my $useImgTools = 1; + no if $] >= 5.017011, warnings => 'experimental::smartmatch'; # we can @@ -58,6 +58,7 @@ sub btIP_itemText; sub btIP_itemTextBox; sub btIP_itemTime; sub btIP_itemTrash; +sub btIP_findTarget; sub btIP_color; sub btIP_xy; sub btIP_changeColor; @@ -81,12 +82,22 @@ sub btIP_getURL; sub InfoPanel_Initialize($) { my ($hash) = @_; - $hash->{DefFn} = "btIP_Define"; - $hash->{UndefFn} = "btIP_Undef"; - #$hash->{AttrFn} = "btIP_Attr"; - $hash->{AttrList} = "autoreread:1,0 bgcenter:1,0 bgcolor bgdir bgopacity refresh size title tmin"; - $hash->{SetFn} = "btIP_Set"; - $hash->{NotifyFn} = "btIP_Notify"; + + eval "use MIME::Base64"; + $useImgTools = 0 if($@); + Log3(undef,4,"InfoPanel: MIME::Base64 missing.") unless $useImgTools; + eval "use Image::Info qw(image_info dim)"; + $useImgTools = 0 if($@); + Log3(undef,4,"InfoPanel: Image::Info missing.") unless $useImgTools; + + $hash->{DefFn} = "btIP_Define"; + $hash->{UndefFn} = "btIP_Undef"; + #$hash->{AttrFn} = "btIP_Attr"; + $hash->{SetFn} = "btIP_Set"; + $hash->{NotifyFn} = "btIP_Notify"; + $hash->{AttrList} = "autoreread:1,0 bgcolor refresh size title"; + $hash->{AttrList} .= " bgcenter:1,0 bgdir bgopacity tmin" if $useImgTools; + return undef; } @@ -190,10 +201,12 @@ sub btIP_itemArea { my $width = $x2 - $x1; my $height = $y2 - $y1; - my $target = 'secret'; - $target = '_top' if $link =~ s/^-//; - $target = '_blank' if $link =~ s/^\+//; +# my $target = 'secret'; +# $target = '_top' if $link =~ s/^-//; +# $target = '_blank' if $link =~ s/^\+//; + my $target = btIP_findTarget($link); + my $output = "\n"; $output .= "\n"; $output .= "\n"; @@ -208,10 +221,12 @@ sub btIP_itemButton { my ($r,$g,$b,$a) = btIP_color($params{boxcolor}); $text = AnalyzePerlCommand(undef,$text); $link = AnalyzePerlCommand(undef,$link); - my $target = 'secret'; - $target = '_top' if $link =~ s/^-//; - $target = '_blank' if $link =~ s/^\+//; +# my $target = 'secret'; +# $target = '_top' if $link =~ s/^-//; +# $target = '_blank' if $link =~ s/^\+//; + my $target = btIP_findTarget($link); + my $output = "\n"; $output .= " 0 || $stroked > 0) { + $output .= "style=\""; + if($filled > 0) { + my ($r,$g,$b,$a) = btIP_color($params{rgb}); + $output .= "fill:rgb($r,$g,$b); fill-opacity:$a; "; + } + if($stroked > 0) { + my ($r,$g,$b,$a) = btIP_color($params{rgb}); + $output .= "stroke:rgb($r,$g,$b); stroke-width:$stroked; "; + $output .= "fill:none; " if ($filled == 0); + } + $output .= "\" "; } $output .= "/>\n"; return $output; @@ -452,10 +482,8 @@ sub btIP_itemTextBox { my $color = substr($params{rgb},0,6); $link =~ s/"//g; - my $target = 'secret'; - $target = '_top' if $link =~ s/^-//; - $target = '_blank' if $link =~ s/^\+//; - + my $target = btIP_findTarget($link); + my ($d,$output); if(defined($params{boxcolor})) { @@ -495,6 +523,7 @@ sub btIP_itemTime { } sub btIP_itemTrash { + return unless $useImgTools; my ($id,$x,$y,$scale,$fgcolor,$bgcolor,%params)= @_; $id = ($id eq '-') ? createUniqueId() : $id; @@ -533,6 +562,14 @@ $data = ''. ##### Helper +sub btIP_findTarget { + my ($link) = shift; + my $target = 'secret'; + $target = '_top' if $link =~ s/^-//; + $target = '_blank' if $link =~ s/^\+//; + return $target; +} + sub btIP_color { my ($rgb)= @_; my $alpha = 1; @@ -724,7 +761,7 @@ sub btIP_evalLayout($$@) { my ($id,$x,$y,$x1,$y1,$x2,$y2,$r1,$r2); my ($scale,$inline,$boxwidth,$boxheight,$boxcolor); - my ($text,$link,$imgtype,$srctype,$arg,$format); + my ($text,$link,$imgtype,$srctype,$arg,$format,$filled,$stroked); my $cont= ""; foreach my $line (@layout) { @@ -782,7 +819,7 @@ sub btIP_evalLayout($$@) { } when("buttonpanel"){ - $defs{$params{name}}{fhem}{div} = "
". "