Ticket #18 (closed defect)

Opened 10 years ago

Last modified 7 years ago

wxGrid's window calculates the content size incorrectly

Reported by: anonymous Owned by:
Priority: normal Milestone:
Component: GUI-generic Version:
Keywords: Cc: signwriting, vadz, neis
Blocked By: Patch: no
Blocking:

Description

Bug#: 71
Product: .wxWindows
Version: current CVS
Platform: All
OS/Version: All
Status: ASSIGNED
Resolution:
Severity: normal
Priority: P2
Component: generic
AssignedTo: mbedward@…
ReportedBy: GregNoel@san.rr.com
URL:
Summary: A wxGrid's window calculates the content size incorrectly

The window underlying a wxGrid thinks the content is about sixteen
pixels larger than it actually is, so it is not possible to create a
wxGrid that exactly fits a surrounding panel. When one tries to do
that, scrollbars appear, even though they are not needed.

To reproduce, apply the patch below to samples/newgrid/griddemo.cpp
(all the patch does is change the size of the sample grid from 100x100
to 10x10) and compile it.

Run the program and try to resize the window so that it just surrounds
the grid. (If your screen is small, use the menu to turn off the grid
labels and select autoresize to shrink the grid as much as possible.)
If you sneak up on the grid from the right, a scrollbar will appear on
the bottom when the edge of the display area is about sixteen pixels
from the grid. A scrollbar will also appear on the right when the
window is about sixteen pixels below the bottom of the grid.

Because of this, a wxGrid cannot be used for a self-sizing display
that automatically fits itself in a panel. The scrollbars should only
be displayed when the grid cannot shrink itself enough. To make this
work correctly now takes some trickery and makes the uses of sizers
impractical.
--- griddemo.cpp Fri May 19 10:09:14 2000
+++ bugdemo.cpp Sun May 28 14:31:18 2000
@@ -206,7 +206,7 @@

// this will create a grid and, by default, an associated grid
// table for strings

- grid->CreateGrid( 100, 100 );
+ grid->CreateGrid( 10, 10 );

grid->SetRowSize( 0, 60 );
grid->SetCellValue( 0, 0, "Ctrl+Home\nwill go to\nthis cell" );

@@ -218,8 +218,8 @@

grid->SetCellValue( 0, 5, "Press\nCtrl+arrow\nto skip

over\ncells" );

- grid->SetRowSize( 99, 60 );
- grid->SetCellValue( 99, 99, "Ctrl+End\nwill go to\nthis cell" );
+ grid->SetRowSize( 9, 60 );
+ grid->SetCellValue( 9, 9, "Ctrl+End\nwill go to\nthis cell" );

grid->SetCellValue(2, 2, "red");

The patch is below:

Change History

Changed 9 years ago by signwriting

I just uploaded patch#412132 that fixes this bug.

Changed 8 years ago by anonymous

Logged In: NO

Don't know, if this ist related to the above, but
the wxGrid Margins are set to (50,50) by default.
Thus, to have a grid which doesn't have a scrollbar
(horizontal in my case), even if the contents would fit into
the available space you have to call wxGrid.SetMargins(0,0).

Perhaps one could set the defaults to (0,0)?

As I read in comp.soft-sys.wxwindows, the same problem
is/was in wxWindows itself, message attached:

Vadim Zeitlin <zeitlin@…> writes:

SU> Also, I wonder what the reason is for having
SU>'m_extraWidth' and `m_extraHeight' set to 50 in grid.cpp.
SU> This makes scrollbars appear
SU> when the window is large enough so that they are not
SU> needed. I changed this to 0 in my local sources and I'm
SU> quite happy with the result. Does this break anything
SU>else?

I don't have any idea - I tried to find out who did this and
why and it seems that this code was there (in a completely
different form but still) since the very first wxGrid
revision (i.e. ~200 revisions ago). If you're sure that this
doesn't break anything else and if noone objects, I think we
should remove this.

The `SetMargins()' function changes these values, and of
course someone might be using that function (one has to if
one wants to set them to 0). Changing the default to 0
seems reasonable, I think.

[--snip--]

Staffan

Changed 7 years ago by vadz

This was apparently fixed a long, long time ago.

Note: See TracTickets for help on using tickets.