(I posted this to wx-users about 2 days ago, but getting no response yet, thought I'd try here.)
I am using wxWizard for the first time and haven't been able to figure something out.
I have a Wizard where the first page offers the user a choice using radio buttons. The first page derives from wxWizardPage (not Simple). Some of the choices should have additional pages, some should not. The default option does, so a Next button shows initially.
When the user clicks an option that has no further pages, I modify my virtual GetNext method to return NULL. The user clicks Next, and the Wizard closes as expected. Unfortunately, the button label on "Next" does not change to "Finish" like I would like it to. I don't see any way to force a refresh of the current page layout.
Any suggestions? Is this something that could/should be added somehow?
Thanks very much in advance!
wxWizard dynamically changing current page to last page Topic is solved
Hi Kevin,
I see what you mean. There's nothing built-in to do this, and the button itself is private so you can't change the label by hand. The label is normally set in wxWizard::ShowPage() which is public, so at first I thought you could just call it in your radiobutton handler to re-show the same page; but there is a wxASSERT checking for this.
Short of writing your own wizard, or patching wxWidgets, the only way I can see that should work is to create a second 'first' page, duplicating the real one but with no 'next' page. In the radiobutton handler artificially press the correct radiobutton, then call ShowPage() with this fake page. You might get a flicker, but the button label should change to Finish.
Untested, of course.
Regards,
David
I see what you mean. There's nothing built-in to do this, and the button itself is private so you can't change the label by hand. The label is normally set in wxWizard::ShowPage() which is public, so at first I thought you could just call it in your radiobutton handler to re-show the same page; but there is a wxASSERT checking for this.
Short of writing your own wizard, or patching wxWidgets, the only way I can see that should work is to create a second 'first' page, duplicating the real one but with no 'next' page. In the radiobutton handler artificially press the correct radiobutton, then call ShowPage() with this fake page. You might get a flicker, but the button label should change to Finish.
Untested, of course.
Regards,
David
-
- Filthy Rich wx Solver
- Posts: 236
- Joined: Sat Sep 04, 2004 1:49 pm
- Location: Ohio, USA
- Contact:
I'm perfectly willing to work on a patch to allow this if it seems like something reasonable to do. We know that the parent of a wxWizardPage is a wxWizard, so a method could be added to wxWizard like RefreshNextFinish or something like that, and then in the Page code you could just call that method on the Parent.
Thanks a lot for the reply!
Thanks a lot for the reply!
-
- Filthy Rich wx Solver
- Posts: 236
- Joined: Sat Sep 04, 2004 1:49 pm
- Location: Ohio, USA
- Contact:
The solution came to me this morning out of the blue:
Maybe this will be of use to someone else in the future.
Code: Select all
wxWindow* NextButton = FindWindowById(wxID_FORWARD, GetParent());
if (GetNext() == NULL)
{
NextButton->SetLabel(_("&Finish"));
}
else
{
NextButton->SetLabel(_("&Next >"));
}