Skip Menu |

This queue is for tickets about the Prima CPAN distribution.

Report information
The Basics
Id: 98833
Status: resolved
Priority: 0/
Queue: Prima

People
Owner: Nobody in particular
Requestors: weisselberg [...] koeln.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Autosize of Prima::Grid confuses columns with rows [Patch]
Date: Fri, 12 Sep 2014 16:53:12 +0200
To: bug-Prima [...] rt.cpan.org
From: Wolfgang Weisselberg <weisselberg [...] koeln.de>
TL,DR: Instead of expanding column-widths for longer texts, the row-heights of the same index ... demonstration code patch appended. Unfortunately neither works for the '4ddddd'. Given the following code: ------------------------------------------------------------ #! /usr/bin/perl use Modern::Perl; use autodie qw/:all/; use Prima Application => { name => 'Pin-Eingabe', wantUnicodeInput => 1 }, qw/StdBitmap Buttons Label InputLine MsgBox/; use Prima::VB::VBLoader; use FindBin; our $binpath = "$FindBin::Bin"; Prima::VBLoad (File::Spec->catfile($binpath, 'test.fm'))-> execute; ------------------------------------------------------------ and the form (test.fm): ------------------------------------------------------------ # VBForm version file=1.2 builder=0,2 # [preload] sub { return ( 'Grid1' => { class => 'Prima::Grid', module => 'Prima::Grids', profile => { size => [ 268, 188], cells => [['1aaaaaaaaa', '1b', '1ccccccccc', '1d', ],['2a', '2b', '2c', '2d', ],['3a', '3b', '3c', '3d', ],['4a', '4b', '4c', '4ddddd', ],], origin => [ 0, 0], owner => 'Form1', columns => 0, name => 'Grid1', rows => 0, }}, 'Form1' => { class => 'Prima::Window', module => 'Prima::Classes', parent => 1, code => Prima::VB::VBLoader::GO_SUB(''), profile => { sizeDontCare => 0, size => [ 270, 189], originDontCare => 0, origin => [ 1085, 654], name => 'Form1', }}, ); } ------------------------------------------------------------ The result is (approximated in ASCII-Art): ++====================================++ ||+--+--+--+--+ ^|| ||| | | | | X|| ||| | | | | X|| ||| | | | | X|| ||| | | | | X|| |||1a|1b|1c|1d| X|| ||| | | | | X|| ||| | | | | X|| ||| | | | | X|| ||| | | | | X|| ||+--+--+--+--+ X|| |||2a|2b|2c|2d| X|| ||+--+--+--+--+ X|| ||| | | | | || ||| | | | | || ||| | | | | || ||| | | | | || |||3a|3b|3c|3d| || ||| | | | | || ||| | | | | v|| ++====================================++ instead of this (which is what happens with the patch and which I think is much more what's wanted): ++====================================++ ||+----------+--+-----------+--+ || |||1aaaaaaaaa|1b|1cccccccccc|1d| || ||+----------+--+-----------+--+ || |||2a |2b|2c |2d| || ||+----------+--+-----------+--+ || |||3a |3b|3c |3d| || ||+----------+--+-----------+--+ || |||4a |4b|4c |4d| || ||+----------+--+-----------+--+ || || || || || || || || || || || || || || || || || || || || || || || ++====================================++ PATCH: ============================================================ --- Prima/Grids.pm 2014-09-12 16:43:37.349772803 +0200 +++ Prima/Grids.pm.old 2014-09-12 16:13:32.382990873 +0200 @@ -2281,7 +2281,7 @@ sub on_measure { my ( $self, $column, $index, $sref) = @_; - if ( not $column) { + if ( $column) { $$sref = $self-> get_text_width( $self-> {cells}-> [0]-> [$index], 1); } else { $$sref = $self-> font-> height + 2; ============================================================
Subject: Re: [rt.cpan.org #98833] Autosize of Prima::Grid confuses columns with rows [Patch]
Date: Fri, 12 Sep 2014 17:40:34 +0200
To: Bugs in Prima via RT <bug-Prima [...] rt.cpan.org>
From: Wolfgang Weisselberg <weisselberg [...] koeln.de>
Improvement on the previous patch, now handles the '4ddddd'. Updated test.fm (size enlarged, so 4ddddd is not cut off so that the last displayed 'd' looks like a 'c'): ------------------------------------------------------------ # VBForm version file=1.2 builder=0,2 # [preload] sub { return ( 'Grid1' => { class => 'Prima::Grid', module => 'Prima::Grids', profile => { size => [ 368, 288], cells => [['1aaaaaaaaa', '1b', '1ccccccccc', '1d', ],['2a', '2b', '2c', '2d', ],['3a', '3b', '3c', '3d', ],['4a', '4b', '4c', '4ddddd', ],], origin => [ 0, 0], owner => 'Form1', columns => 0, name => 'Grid1', rows => 0, }}, 'Form1' => { class => 'Prima::Window', module => 'Prima::Classes', parent => 1, code => Prima::VB::VBLoader::GO_SUB(''), profile => { sizeDontCare => 0, size => [ 370, 289], originDontCare => 0, origin => [ 1085, 654], name => 'Form1', }}, ); } ------------------------------------------------------------ Patch (v2): ------------------------------------------------------------ --- Prima/Grids.pm.old 2014-09-12 16:13:32.382990873 +0200 +++ Prima/Grids.pm 2014-09-12 17:33:36.395850577 +0200 @@ -2253,6 +2253,7 @@ package Prima::Grid; use vars qw(@ISA); @ISA = qw(Prima::GridViewer); +use List::Util qw/max/; sub draw_cells { @@ -2281,8 +2282,12 @@ sub on_measure { my ( $self, $column, $index, $sref) = @_; - if ( $column) { - $$sref = $self-> get_text_width( $self-> {cells}-> [0]-> [$index], 1); + if ( not $column) { + $$sref = max( + map { + $self->get_text_width( $self->{cells}->[$_]->[$index], 1 ) + } 0 .. $#{ $self->{cells} } + ); } else { $$sref = $self-> font-> height + 2; } ------------------------------------------------------------ Mit freundlichen Grüßen, -Wolfgang Weisselberg
Fixed thank you! I'd like to ask you to check out the latest github version, to see if it works for you. /dk ps Thanks for a very detailed report, it was a pleasure reading it!