From 603f1cfe306b89c0c35db880d4d316e2582db13d Mon Sep 17 00:00:00 2001 From: betateilchen Date: Tue, 10 Feb 2015 11:09:21 +0000 Subject: [PATCH] 55_InfoPanel.pm: added direct link to circle,ellipse,rect git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@7931 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/55_InfoPanel.pm | 88 ++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 34 deletions(-) diff --git a/fhem/FHEM/55_InfoPanel.pm b/fhem/FHEM/55_InfoPanel.pm index a1d6b7436..3cd553c48 100644 --- a/fhem/FHEM/55_InfoPanel.pm +++ b/fhem/FHEM/55_InfoPanel.pm @@ -58,8 +58,9 @@ sub btIP_itemText; sub btIP_itemTextBox; sub btIP_itemTime; sub btIP_itemTrash; -sub btIP_findTarget; + sub btIP_color; +sub btIP_findTarget; sub btIP_xy; sub btIP_changeColor; sub btIP_FileRead; @@ -164,7 +165,7 @@ sub btIP_readLayout($) { my ($err, @layoutfile) = FileRead($filename); if($err) { Log 1, "InfoPanel $name: $err"; - $hash->{fhem}{layout}= ("text 0.1 0.1 'Error: $err'"); + $hash->{fhem}{layout} = "text ERROR 50 50 \"Error on reading layout!\""; } else { $hash->{fhem}{layout} = join("\n", @layoutfile); while($hash->{fhem}{layout} =~ m/\@include/ ) { @@ -198,14 +199,12 @@ sub btIP_readLayout($) { sub btIP_itemArea { my ($id,$x1,$y1,$x2,$y2,$link,%params)= @_; $id = ($id eq '-') ? createUniqueId() : $id; - my $width = $x2 - $x1; - my $height = $y2 - $y1; - my $target; - ($link,$target) = btIP_findTarget($link); - - my $output = "\n"; - $output .= "\n"; - $output .= "\n"; + + my $oldrgb = $params{rgb}; + $params{rgb} = '00000000'; + my $output = btIP_itemRect($id,$x1,$y1,$x2,$y2,0,0,1,0,$link,%params); + $params{rgb} = $oldrgb; + return $output; } @@ -238,9 +237,13 @@ sub btIP_itemButton { } sub btIP_itemCircle { - my ($id,$x,$y,$r,$filled,$stroked,%params)= @_; + my ($id,$x,$y,$r,$filled,$stroked,$link,%params)= @_; $id = ($id eq '-') ? createUniqueId() : $id; - my $output = "\n" if($link && length($link)); + $output .= " 0 || $stroked > 0) { $output .= "style=\""; if($filled > 0) { @@ -257,6 +260,7 @@ sub btIP_itemCircle { $output .= "style=\"fill:none; stroke-width:0; \" "; } $output .= "/>\n"; + $output .= "\n" if($link && length($link)); return $output; } @@ -268,9 +272,13 @@ sub btIP_itemDate { } sub btIP_itemEllipse { - my ($id,$x,$y,$rx,$ry,$filled,$stroked,%params)= @_; + my ($id,$x,$y,$rx,$ry,$filled,$stroked,$link,%params)= @_; $id = ($id eq '-') ? createUniqueId() : $id; - my $output = "\n" if($link && length($link)); + $output .= " 0 || $stroked > 0) { $output .= "style=\""; if($filled > 0) { @@ -287,6 +295,7 @@ sub btIP_itemEllipse { $output .= "style=\"fill:none; stroke-width:0; \" "; } $output .= "/>\n"; + $output .= "\n" if($link && length($link)); return $output; } @@ -438,11 +447,15 @@ sub btIP_itemPlot { } sub btIP_itemRect { - my ($id,$x1,$y1,$x2,$y2,$rx,$ry,$filled,$stroked,%params)= @_; + my ($id,$x1,$y1,$x2,$y2,$rx,$ry,$filled,$stroked,$link,%params)= @_; $id = ($id eq '-') ? createUniqueId() : $id; + my $target; + ($link,$target) = btIP_findTarget($link); my $width = $x2 - $x1; my $height = $y2 - $y1; - my $output = "\n" if($link && length($link)); + $output .= " 0 || $stroked > 0) { $output .= "style=\""; if($filled > 0) { @@ -459,6 +472,7 @@ sub btIP_itemRect { $output .= "style=\"fill:none; stroke-width:0; \" "; } $output .= "/>\n"; + $output .= "\n" if($link && length($link)); return $output; } @@ -579,14 +593,6 @@ $data = ''. ##### Helper -sub btIP_findTarget { - my ($link) = shift; - my $target = 'secret'; - $target = '_top' if $link =~ s/^-//; - $target = '_blank' if $link =~ s/^\+//; - return ($link,$target); -} - sub btIP_color { my ($rgb)= @_; my $alpha = 1; @@ -598,6 +604,14 @@ sub btIP_color { return (hex("$d[0]$d[1]"),hex("$d[2]$d[3]"),hex("$d[4]$d[5]"),$alpha); } +sub btIP_findTarget { + my ($link) = shift; + my $target = 'secret'; + $target = '_top' if $link =~ s/^-//; + $target = '_blank' if $link =~ s/^\+//; + return ($link,$target); +} + sub btIP_xy { my ($x,$y,%params)= @_; @@ -792,7 +806,7 @@ sub btIP_evalLayout($$@) { if($line=~ s/\\$//) { $cont= $line; undef $line; } next unless($line); $cont= ""; - #Debug "$name: evaluating >$line<"; + Debug "$name: evaluating >$line<"; # split line into command and definition my ($cmd, $def)= split("[ \t]+", $line, 2); @@ -842,11 +856,12 @@ sub btIP_evalLayout($$@) { } when("circle") { - ($id,$x1,$y1,$r1,$filled,$stroked)= split("[ \t]+", $def, 6); + ($id,$x1,$y1,$r1,$filled,$stroked,$link)= split("[ \t]+", $def, 7); ($x1,$y1)= btIP_xy($x1,$y1,%params); $filled //= 0; $stroked //= 0; - $svg .= btIP_itemCircle($id,$x1,$y1,$r1,$filled,$stroked,%params); + $link = AnalyzePerlCommand(undef,$link); + $svg .= btIP_itemCircle($id,$x1,$y1,$r1,$filled,$stroked,$link,%params); } when("date") { @@ -858,11 +873,12 @@ sub btIP_evalLayout($$@) { } when("ellipse") { - ($id,$x1,$y1,$r1,$r2,$filled,$stroked)= split("[ \t]+", $def, 7); + ($id,$x1,$y1,$r1,$r2,$filled,$stroked,$link)= split("[ \t]+", $def, 8); ($x1,$y1)= btIP_xy($x1,$y1,%params); $filled //= 0; $stroked //= 0; - $svg .= btIP_itemEllipse($id,$x1,$y1,$r1,$r2,$filled,$stroked,%params); + $link = AnalyzePerlCommand(undef,$link); + $svg .= btIP_itemEllipse($id,$x1,$y1,$r1,$r2,$filled,$stroked,$link,%params); } when("font") { @@ -934,14 +950,15 @@ sub btIP_evalLayout($$@) { } when("rect") { - ($id,$x1,$y1,$x2,$y2,$r1,$r2,$filled,$stroked)= split("[ \t]+", $def, 9); + ($id,$x1,$y1,$x2,$y2,$r1,$r2,$filled,$stroked,$link)= split("[ \t]+", $def, 10); ($x1,$y1)= btIP_xy($x1,$y1,%params); ($x2,$y2)= btIP_xy($x2,$y2,%params); $params{xx} = $x; $params{yy} = $y; $filled //= 0; # set 0 as default (not filled) $stroked //= 0; # set 0 as default (not stroked) - $svg .= btIP_itemRect($id,$x1,$y1,$x2,$y2,$r1,$r2,$filled,$stroked,%params); + $link = AnalyzePerlCommand(undef,$link); + $svg .= btIP_itemRect($id,$x1,$y1,$x2,$y2,$r1,$r2,$filled,$stroked,$link,%params); } when("rgb"){ @@ -1328,7 +1345,7 @@ Please read stroke-width = defines stroke width to draw around the circle. Default = 0
+ link = URL to be linked to item


  • date <id> <x> <y>
    @@ -1347,7 +1365,7 @@ Please read
    stroke-width = defines stroke width to draw around the ellipse. Default = 0
    + link = URL to be linked to item


  • font <font-family>
    @@ -1440,7 +1459,7 @@ Please read
    stroke-width = defines stroke width to draw around the rectangle. Default = 0
    + link = URL to be linked to item


  • rgb <{rgb[a]}>