Discussion:
Grid layouts
Tim Burgess
2014-07-15 11:34:39 UTC
Permalink
Hi,

I'm porting a QT application to WX, so I'm obviously encountering the odd
class that has no equivalent. I've come across a grid where each grid
element contains a button.

I can sort of reproduce this using nested sizers to get the appropriate
layout (I looked at wxGrid but it didn't seem to support use of a button for
its cell contents and, anyhow, it's poor in terms of accessibility), but
referencing the buttons poses a question, given that the entire grid
contains 100 cells:

Do I need to define 100 separate ID values for the buttons - using wxID_ANY
is obviously convenient, but then doesn't allow me to determine which was
pressed when my event handler is triggered. Am I missing a trick here?

Best wishes.
Tim Burgess
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
'Catalin' via wx-users
2014-07-15 11:40:22 UTC
Permalink
Hello,
Post by Tim Burgess
Do I need to define 100 separate ID values for the buttons - using wxID_ANY
is obviously convenient, but then doesn't allow me to determine which was
pressed when my event handler is triggered. Am I missing a trick here?
It's probably not the best approach to use so many buttons, but may be the quickest..

You can create each button using wxID_ANY and it will still have a unique id which you can get afterwards and store somewhere.

Regards,
C
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Tim Burgess
2014-07-15 12:00:56 UTC
Permalink
OK,

So if I call button->GetID() immediately after creation then store the value I should be good to go?

I agree that I don't like this UI design (all of my users are keyboard-oriented, so pressing Tab a possible 99 times is horrendous), but I want to get the functionality correct against the original application before doing any redesign work, so I'll live with it for now.

Thanks for the information.

Best wishes.
Tim Burgess


-----Original Message-----
From: wx-***@googlegroups.com [mailto:wx-***@googlegroups.com]
Sent: 15 July 2014 12:40
To: wx-***@googlegroups.com
Subject: Re: Grid layouts

Hello,
Post by Tim Burgess
Do I need to define 100 separate ID values for the buttons - using
wxID_ANY is obviously convenient, but then doesn't allow me to
determine which was pressed when my event handler is triggered. Am I missing a trick here?
It's probably not the best approach to use so many buttons, but may be the quickest..

You can create each button using wxID_ANY and it will still have a unique id which you can get afterwards and store somewhere.

Regards,
C

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
'Catalin' via wx-users
2014-07-15 12:25:49 UTC
Permalink
Post by Tim Burgess
So if I call button->GetID() immediately after creation then store the value
I should be good to go?
Yes.

Regards,
C
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Eric Jensen
2014-07-15 12:37:12 UTC
Permalink
Hello Tim,

Tuesday, July 15, 2014, 1:34:39 PM, you wrote:

TB> I can sort of reproduce this using nested sizers to get the appropriate
TB> layout (I looked at wxGrid but it didn't seem to support use of a button for
TB> its cell contents and, anyhow, it's poor in terms of accessibility),
Instead of nested sizers, you also could have used wxFlexGridSizer or
wxGridBagSizer.

TB> Do I need to define 100 separate ID values for the buttons - using wxID_ANY
TB> is obviously convenient, but then doesn't allow me to determine which was
TB> pressed when my event handler is triggered. Am I missing a trick here?
I would have used a fixed range of IDs for the buttons, e.g. starting
with wxID_HIGHEST+5000. Then you can easily calculate the position of
a button inside the grid using the ID.

Eric
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Tim Burgess
2014-07-15 14:44:35 UTC
Permalink
That's great - thanks.


Best wishes.
Tim Burgess

-----Original Message-----
From: wx-***@googlegroups.com [mailto:wx-***@googlegroups.com] On Behalf
Of Eric Jensen
Sent: 15 July 2014 13:37
To: Tim Burgess
Subject: Re: Grid layouts

Hello Tim,

Tuesday, July 15, 2014, 1:34:39 PM, you wrote:

TB> I can sort of reproduce this using nested sizers to get the
TB> appropriate layout (I looked at wxGrid but it didn't seem to support
TB> use of a button for its cell contents and, anyhow, it's poor in
TB> terms of accessibility),
Instead of nested sizers, you also could have used wxFlexGridSizer or
wxGridBagSizer.

TB> Do I need to define 100 separate ID values for the buttons - using
TB> wxID_ANY is obviously convenient, but then doesn't allow me to
TB> determine which was pressed when my event handler is triggered. Am I
missing a trick here?
I would have used a fixed range of IDs for the buttons, e.g. starting with
wxID_HIGHEST+5000. Then you can easily calculate the position of a button
inside the grid using the ID.

Eric


--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...