From 883b36c770e33019be141dda283bb9ac311e365b Mon Sep 17 00:00:00 2001 From: betateilchen <> Date: Wed, 11 Feb 2015 01:04:47 +0000 Subject: [PATCH] 55_InfoPanel.pm: code cleanup added: item "counter" changed: reuse standard elements changed: commandref updated git-svn-id: https://svn.fhem.de/fhem/trunk@7933 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/55_InfoPanel.pm | 55 +++++++++++++++++------------- fhem/contrib/InfoPanel/demo.layout | 9 ++++- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/fhem/FHEM/55_InfoPanel.pm b/fhem/FHEM/55_InfoPanel.pm index 3cd553c48..a6c9d6650 100644 --- a/fhem/FHEM/55_InfoPanel.pm +++ b/fhem/FHEM/55_InfoPanel.pm @@ -26,14 +26,6 @@ my $useImgTools = 1; no if $] >= 5.017011, warnings => 'experimental::smartmatch'; -# we can -# use vars qw(%FW_types); # device types, -# use vars qw($FW_RET); # Returned data (html) -# use vars qw($FW_wname); # Web instance -# use vars qw($FW_subdir); # Sub-path in URL for extensions, e.g. 95_FLOORPLAN -# use vars qw(%FW_pos); # scroll position -# use vars qw($FW_cname); # Current connection name - #sub InfoPanel_Initialize($); sub btIP_Define($$); sub btIP_Undef($$); @@ -93,7 +85,6 @@ sub InfoPanel_Initialize($) { $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"; @@ -213,26 +204,23 @@ sub btIP_itemButton { $id = ($id eq '-') ? createUniqueId() : $id; my $width = $x2 - $x1; my $height = $y2 - $y1; - my ($r,$g,$b,$a) = btIP_color($params{boxcolor}); $text = AnalyzePerlCommand(undef,$text); $link = AnalyzePerlCommand(undef,$link); - my $target; - ($link,$target) = btIP_findTarget($link); - - my $output = "\n"; - $output .= "\n"; + + my $oldrgb = $params{rgb}; + $params{rgb} = $params{boxcolor}; + my $output = btIP_itemRect($id,$x1,$y1,$x2,$y2,$rx,$ry,1,0,$link,%params); + $params{rgb} = $oldrgb; my $oldhalign = $params{thalign}; my $oldvalign = $params{tvalign}; $params{thalign} = "middle"; $params{tvalign} = "middle"; - $output .= btIP_itemText($id."_text",($x1+$x2)/2,($y1+$y2)/2,$text,%params); + my $textoutput .= btIP_itemText("${id}_text",($x1+$x2)/2,($y1+$y2)/2,$text,%params); $params{thalign} = $oldhalign; $params{tvalign} = $oldvalign; - $output .= "\n"; + $output =~ s/<\/a>/$textoutput<\/a>/; return $output; } @@ -264,6 +252,12 @@ sub btIP_itemCircle { return $output; } +sub btIP_itemCounter { + my ($id,$x,$y,%params)= @_; + $id = ($id eq '-') ? createUniqueId() : $id; + return btIP_itemText($id,$x,$y,$defs{$params{name}}{fhem}{counter},%params); +} + sub btIP_itemDate { my ($id,$x,$y,%params)= @_; $id = ($id eq '-') ? createUniqueId() : $id; @@ -344,7 +338,6 @@ sub btIP_itemImg { ($width,$height,$mimetype,$data) = _btIP_imgData($data,$scale); } -# $output = "\n"; $output = "\n"; $output .= "\n"; return $output; @@ -422,7 +415,7 @@ sub btIP_itemPlot { $svgdata =~ s/<\/svg>/<\/svg>/; (undef,undef,undef,$svgdata) = _btIP_imgData($svgdata,1); - $output = "\n"; + $output = "\n"; $output .= "\n"; } else { @@ -454,8 +447,8 @@ sub btIP_itemRect { my $width = $x2 - $x1; my $height = $y2 - $y1; my $output = ""; - $output .= "\n" if($link && length($link)); - $output .= "\n" if($link && length($link)); + $output .= " 0 || $stroked > 0) { $output .= "style=\""; if($filled > 0) { @@ -864,6 +857,14 @@ sub btIP_evalLayout($$@) { $svg .= btIP_itemCircle($id,$x1,$y1,$r1,$filled,$stroked,$link,%params); } + when("counter") { + ($id,$x,$y)= split("[ \t]+", $def, 3); + ($x,$y)= btIP_xy($x,$y,%params); + $params{xx} = $x; + $params{yy} = $y; + $svg .= btIP_itemCounter($id,$x,$y,%params); + } + when("date") { ($id,$x,$y)= split("[ \t]+", $def, 3); ($x,$y)= btIP_xy($x,$y,%params); @@ -1357,6 +1358,14 @@ Please read +# +counter - 710 75 # Text rechtsbündig ausgeben @@ -272,4 +279,4 @@ textboxalign justify # textbox - 210 50 180 50 "http://www.fhem.de" "Ich bin eine Textbox und wenn man mich anklickt geht es direkt zu www.fhem.de" -# +# \ No newline at end of file