wxWizard dynamically changing current page to last page Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
KevinHock
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 236
Joined: Sat Sep 04, 2004 1:49 pm
Location: Ohio, USA
Contact:

wxWizard dynamically changing current page to last page

Post by KevinHock »

(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!
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

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
KevinHock
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 236
Joined: Sat Sep 04, 2004 1:49 pm
Location: Ohio, USA
Contact:

Post by KevinHock »

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!
KevinHock
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 236
Joined: Sat Sep 04, 2004 1:49 pm
Location: Ohio, USA
Contact:

Post by KevinHock »

The solution came to me this morning out of the blue:

Code: Select all

        wxWindow* NextButton = FindWindowById(wxID_FORWARD, GetParent());

        if (GetNext() == NULL)
        {
            NextButton->SetLabel(_("&Finish"));
        }
        else
        {
            NextButton->SetLabel(_("&Next >"));
        }
Maybe this will be of use to someone else in the future. :D
Post Reply