wxPropertyGrid - Scrollbars block the grid!

BlitzMax Forums/Brucey's Modules/wxPropertyGrid - Scrollbars block the grid!

Gabriel(Posted 2008) [#1]
I don't know if anyone else is using this, but I've been fighting with it for a week and it's still kicking my ass. I add more properties to the grid than will fit in the height of it. So it adds a scrollbar for me to use, which is very helpful. Unfortunately, that scrollbar covers the far right end of the grid, meaning that the little dropdown widget and the little button with .. two dots to open a requester of some kind are completely covered and I can't use them.

I don't need sizers for my application ( fixed res ) so I don't know if they're required, but I tried getting my head around them and it only made matters worse. ( The property grid wasn't taking up anything like the space available to it, it was too small to use. That was just by copying the sizer from Brucey's PG example which is part of the mod.

Does anyone know how to deal with these scrollbars and stop them blocking the end of the grid with all the important widgets in?


Brucey(Posted 2008) [#2]
If you run the sample and make the window smaller, does it exhibit the same problem?

On Mac, when the scrollbar appears, the controls adjust themselves so that, for example, a browse button shifts to the left a bit.


Glenn Dodd(Posted 2008) [#3]
i am just off to work but if you send me a picture of the screen i might be able to sus out a solution.

Cheers
Glenn


Gabriel(Posted 2008) [#4]
If you run the sample and make the window smaller, does it exhibit the same problem?

No, that's what I don't understand. Your demo doesn't exhibit the problem, but i cannot find any code in your demo which I haven't copied across. I know yours is filling up a window and mine is just sat inside a frame, but I can't see any of your code I have missed. I guess there must be something though.

i am just off to work but if you send me a picture of the screen i might be able to sus out a solution.

No problem, here's a screenshot of it.



As you can see the right hand edge of the dropdown is underneath the scrollbar.


If it helps, when I add all the properties, I call refresh to ensure that it has all the properties accounted for and then I call GetBestSize() and it gives me 60, 58 which is not remotely big enough for all the properties. I assume this is why it resizes too small when I add a sizer or even call Fit() on it. I'm not sure why this should be. It has lots of properties as you can see.


Glenn Dodd(Posted 2008) [#5]
are you sure you have all of these?

that is all i can see that might impact the scrollbar functionality.
but i am just a beginner so it is bound to be something else.

Cheers
Glenn


Brucey(Posted 2008) [#6]
Feel free to send me (or post here) the snippet of code where you create the property grid on its parent control.

I'm thinking that perhaps you might be able to do the following :

Create a wxPanel (in the place where you currently have your property grid)
To that, add a wxBoxSizer.
To the sizer, add your property grid using something along the lines of :

sizer.Add(propertygrid, 1, wxEXPAND | wxALL, 0)

which means, completely fill the parent's child area, with zero border width.

Assuming your wxPanel is "placed" on the form using x,y, w, h.


Just an idea.


Gabriel(Posted 2008) [#7]
Glenn: I believe that's unconnected to the Property Grid itself. The PG's styles are set elsewhere. I tried removing those lines from Brucey's example, and it still works where mine doesn't.

Brucey: well I've revised and fiddled with this code dozens of times, but here's how it is currently, with my attempt to add the sizer as you suggested above. It's not helping though, so if you can see what I've done wrong, that'd be great.

Local Sizer:wxBoxSizer = New wxBoxSizer.Create(wxHORIZONTAL) 
		
PropertyGridPanel = wxPanel.CreatePanel(DevApp.LevelPanel, Null, TVR + ((CW - TVR) / 2) - 160, 80, 310, 500, wxPG_BOLD_MODIFIED | wxPG_SPLITTER_AUTO_CENTER | wxPG_AUTO_SORT | wxPG_SPLITTER_AUTO_CENTER | wxPG_DEFAULT_STYLE) 
PropertyGrid = wxPropertyGrid.CreatePropertyGrid(PropertyGridPanel, wxID_PropertyGrid, 0, 0, 250, 450) 
		PropertyGrid.SetExtraStyle(wxPG_EX_HELP_AS_TOOLTIPS | wxPG_EX_NATIVE_DOUBLE_BUFFERING) 
PropertyGrid.SetFont(DevApp.MainGUIFont) 
		
Sizer.add(PropertyGrid, 1, wxEXPAND | wxALL, 0) 
PropertyGridPanel.SetSizer(Sizer) 
Sizer.SetSizeHints(PropertyGrid) 



DavidDC(Posted 2008) [#8]
Would it be sacrilege to suggest trying it without sizers in this instance?


Gabriel(Posted 2008) [#9]
Originally it was without sizers, and it didn't work like that either. I don't need sizers specifically, only if they're the only way to make the property grid display properly. I'll take anything that works.


DavidDC(Posted 2008) [#10]
Interesting. And you've tried it using sizers only as well? No fixed dimensions?


Gabriel(Posted 2008) [#11]
I tried but it didn't size correctly. I was getting it sized at 60x56 or something, nowhere near big enough. So quite possibly I was doing something wrong.


DavidDC(Posted 2008) [#12]
I'm just wondering if you are unknowingly trespassing on a min-gadget-width boundary. Have you tried making the grid really wide and seeing if the problem still exists?


Gabriel(Posted 2008) [#13]
It's not that. Brucey's property grid sample works when the property grid is much, much narrower than mine.


DavidDC(Posted 2008) [#14]
Yes, quite right. Playing with the sample reveals that you can indeed resize to a very small width and still have it draw correctly. When you tried all sizers (creating with -1,-1,-1,-1) did it at least draw correctly?


Gabriel(Posted 2008) [#15]
Nope, that was what I meant earlier about the 60x56 size. When I get the recommended minimum size, I get those same values. Which makes me wonder if that is part of the problem. If it really *was* 60 pixels wide, there wouldn't be enough room. But I don't know why it thinks it only needs to be that wide. It's got a lot of stuff in it.


Brucey(Posted 2008) [#16]
Here's a runnable example that replicates the problem :



It appears that the property grid wants some kind of size event/info, which it's not getting for whatever reason (with or without the sizer).
If you collapse and expand the node though, it then works as expected.

Just need to find a way to inject it with some kind of "hey you, you need to update yourself!" event.


Gabriel(Posted 2008) [#17]
Thanks for the example, Brucey. It's good to know that it's not just me. Indeed it seems that wxPropertyGrid doesn't like being in a panel. Or perhaps it works best when it has a frame to itself.

You're right about collapsing and expanding a node. Even if you have several categories, expanding and contracting any one of them will do it. Problem is, doing that in code doesn't have the same effect as doing it manually. It's a bit of a puzzle, this one. I've played with it for hours and I can't seem to get it to know when it needs to update itself.


Brucey(Posted 2008) [#18]
Ah haaaa....

Can you try the following "hack" for me please?

Open up propgrid.cpp (wxpropgrid.mod/src/), and head down to about line 9592, which looks like :
    // Check min sizes
    if ( timeSinceCreation >= 750 )

And change the 750 to 0.

Build Modules, try your code again, and let me know how it goes.

Thanks :-)


DavidDC(Posted 2008) [#19]
Looks like a fix here on Leopard :-) Nice work Brucey!


Gabriel(Posted 2008) [#20]
Yep, confirmed working on Windows too. Thanks heaps, Brucey!


Brucey(Posted 2008) [#21]
Great :-)

Now I need to find out what platform that "hack" was intended for... hopefully none of our three platforms.