think ive found a bug in wxgrid

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
james28909
Knows some wx things
Knows some wx things
Posts: 39
Joined: Mon Jul 01, 2019 8:27 pm

think ive found a bug in wxgrid

Post by james28909 » Sat Aug 03, 2019 3:56 pm

i created a frame of a set size.
on this frame i set a panel of default position and default size.

i placed a grid to fill up the window and then set the column/row label sizes to 0.

added another panel on top of the first panel with a height thats just enough to fill where the col labels should go on the first grid. then i set another grid on this second panel that is the same width as the original grid, and a height thats proportional to "fill in" where the first grids col labels would be.

i have hidden the col labels of the second grid as well. this second grid acts as column labels.

both of the grids have a width of ~200 cells, each cell is 180 pixels in width.

the problem: the second grid that is placed on second panel, above the first grid, stops scrolling way before the first grid stops scrolling.

to fix this i have to manually force a resize event.

Code: Select all

package MyApp;

sub OnInit(
my $frame = MyFrame->new(
    undef, -1, 'something interesting',
    [ 0, 0 ],
     [1100,500],
);
)

package MyFrame;
sub new(
	my( $class ) = shift;
    my( $this ) = $class->SUPER::new( @_ );
	
my $panel = Wx::Panel->new( $this, -1, wxDefaultPosition, wxDefaultSize);
my $panel2 = Wx::Panel->new( $panel, -1, [200, 10], [900, 41]);


my $grid = Wx::Grid->new($panel, -1, [ 200,50 ], [ 1100, 518 ]);
my $grid2 = Wx::Grid->new( $panel2, -1, [0, 0], [ 900, 60]); 

$grid->SetDefaultColSize(180);
$grid2->SetDefaultColSize(180);

$grid->SetColLabelSize(0);
$grid2->SetColLabelSize(0);

my $cols = 200;

$grid->CreateGrid(1, $cols);
$grid2->CreateGrid(1, $cols);

#i have to force a size event to make the second grid ($grid2) scroll-able all the way to the end
$grid2->SetColSize(0, 180);
)
once i add the last line '$grid2->SetColSize(x, y);' the second grid scrolls all the way to the end fine. if i remove the last line, the second grid stops short, even though there is more to show, and the first grid keeps scrolling. its like the scroll range of $grid2 is not the same... even though they are grids of the same width, and on the same panel.

also, please do not pay to much attention to the sizes, what i am trying to accomplish is hiding the scrollbars, since there is no way to hide them and still have a scrollable window (that i know of)

if i can make it any more clear just let me know. i could make a short video of the problem. i spent 6-7 hours chasing this problem down.

User avatar
doublemax
Moderator
Moderator
Posts: 14083
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: think ive found a bug in wxgrid

Post by doublemax » Sat Aug 03, 2019 5:51 pm

Please post at least a screenshot and explain again why you need two grids for this instead of one.
Use the source, Luke!

james28909
Knows some wx things
Knows some wx things
Posts: 39
Joined: Mon Jul 01, 2019 8:27 pm

Re: think ive found a bug in wxgrid

Post by james28909 » Sat Aug 03, 2019 7:39 pm

Image

EDIT:
https://youtu.be/5O8Qq0BlETs?t=46 - (turn down your volume)
notice that the scrollbar stops/doesnt scroll unless i resize the 'fake' column label. once i do that (at 1:16 in the video), i can scroll all the way to the end of the grid.

also, i forgot to mention that the scroll events (EVT_SCROLLWIN_*) from each grid are synced with each other. so if you scroll one grid it will scroll the other. (which i am having issues getting to work in WSL ubuntu with xserver, but works fine in windows)

and the reason i did this was so i could have different color cells in the main grid, and i could color the row labels and column labels different colors than the main grid. i also had pictures to add to the labels as well and could not find any documented method for wxperl to take over the default renderer, and i am not a seasoned skilled developer so i could not figure it out myself, so i had to make this work.

but tbh, it seems that the second grid would have the same properties as thwe first grid. grid 2 would reach the end of the scroll area and the main grid would keep scrolling. i could resize one of grid2's 'fake' column label/header, and that would set the scroll range to its correct size. then i pragmatically resized grid2 column size, which fixed the issue.

again... both grids were on the same panel. both grids have a fixed size (which is very important because i am hiding the scroll bars from view). both grids were the same colspan (~200). but grid2 would stop scrolling well before all the data was shown, which a SetColSize (size event) fixed.

User avatar
doublemax
Moderator
Moderator
Posts: 14083
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: think ive found a bug in wxgrid

Post by doublemax » Sat Aug 03, 2019 11:17 pm

I'll have to build a running C++ sample to test this myself.
Use the source, Luke!

james28909
Knows some wx things
Knows some wx things
Posts: 39
Joined: Mon Jul 01, 2019 8:27 pm

Re: think ive found a bug in wxgrid

Post by james28909 » Sun Aug 04, 2019 3:00 pm

all it is, is a frame with a panel. grid on the first panel, then another panel with a grid on it on the first panel. the reason for this is to hide the scrollbars out of sight. im pretty sure it can be done other ways, but this is the way i went with it because i can easily customize the "fake" col header.

add a panel with a grid to the frame. turn off col and row labels so they dont show, then place a panel and grid on the original panel where the col and row label/headers go.

User avatar
doublemax
Moderator
Moderator
Posts: 14083
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: think ive found a bug in wxgrid

Post by doublemax » Sun Aug 04, 2019 9:57 pm

I tried to recreate that, but i'm getting all kind of weird redraw errors.

Code: Select all

my $panel2 = Wx::Panel->new( $panel, -1, [200, 10], [900, 41]);
my $grid2 = Wx::Grid->new( $panel2, -1, [0, 0], [ 900, 60]); 
Do i understand this correctly, you deliberately made the panel smaller than the grid so that the scrollbar gets clipped? That's really dirty ;)
Use the source, Luke!

james28909
Knows some wx things
Knows some wx things
Posts: 39
Joined: Mon Jul 01, 2019 8:27 pm

Re: think ive found a bug in wxgrid

Post by james28909 » Mon Aug 05, 2019 1:18 pm

yes that is what i did. ive been called alot of things, and dirty is def one of them ;)

im now facing a different issue, with GetCellSize, now. apparently ity is not supported/built into the lib i am using. ill make a new thread and explain the problem.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3466
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: think ive found a bug in wxgrid

Post by ONEEYEMAN » Mon Aug 05, 2019 2:26 pm

Hi,
james28909 wrote:
Sat Aug 03, 2019 7:39 pm
Image

EDIT:
https://youtu.be/5O8Qq0BlETs?t=46 - (turn down your volume)
notice that the scrollbar stops/doesnt scroll unless i resize the 'fake' column label. once i do that (at 1:16 in the video), i can scroll all the way to the end of the grid.

also, i forgot to mention that the scroll events (EVT_SCROLLWIN_*) from each grid are synced with each other. so if you scroll one grid it will scroll the other. (which i am having issues getting to work in WSL ubuntu with xserver, but works fine in windows)

and the reason i did this was so i could have different color cells in the main grid, and i could color the row labels and column labels different colors than the main grid. i also had pictures to add to the labels as well and could not find any documented method for wxperl to take over the default renderer, and i am not a seasoned skilled developer so i could not figure it out myself, so i had to make this work.
I believe the grid itself supports coloring cells and row/cols. So you don't need to have 2 grids just for that.
Now for the renderer - you could just look at C++ sample and do something similar. Are renderers for row and column labels available in wxPerl?
james28909 wrote:
Sat Aug 03, 2019 7:39 pm
but tbh, it seems that the second grid would have the same properties as thwe first grid. grid 2 would reach the end of the scroll area and the main grid would keep scrolling. i could resize one of grid2's 'fake' column label/header, and that would set the scroll range to its correct size. then i pragmatically resized grid2 column size, which fixed the issue.

again... both grids were on the same panel. both grids have a fixed size (which is very important because i am hiding the scroll bars from view). both grids were the same colspan (~200). but grid2 would stop scrolling well before all the data was shown, which a SetColSize (size event) fixed.
Thank you.

Post Reply