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;
============================================================