special semi-modal dialog

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
spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

special semi-modal dialog

Post by spectrum » Wed Oct 21, 2009 4:49 pm

Hello All,

i am looking for a special dialog, but maybe there is already some chance, or an easy way to implement it:

If you loow at Wireshark, there are some warning popup dialogs (done trough gtk), for example if you write a wrong filter in the filter bar, an error dialog popup.

These dialogs allow the interface below to be updated, so i suppose the main loop still process events like OnIdle.
At the same time they are modal, so no actions in the GUI below are allowed.

As far as i know, wxWidgets ShowModal() block other frame events, and main frame OnIdle() is no more processed.

I am trying to implement something like this, using KillFocus events, to avoid to click on other windows, anyway it is resulting quite hard and i don't think it is the right way to do this.

Any help is really appreciated.
Angelo
spectrum

DavidHart
Site Admin
Site Admin
Posts: 4008
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart » Thu Oct 22, 2009 9:24 am

Hi Angelo,

I don't know if wxWindowDisabler blocks the event loop too, but it would be worth trying.

Regards,

David

spartygw
Knows some wx things
Knows some wx things
Posts: 37
Joined: Mon Jul 07, 2008 4:19 pm
Location: georgia, usa

Post by spartygw » Tue Oct 27, 2009 6:36 pm

Yeah, I think you can do what you want with a combination of a dialog-derived class and doing:

Code: Select all


MyDialog *myDialog = new MyDialog();

while (someJobNotYetComplete)
{
  wxYieldIfNeeded();
  myDialog->Pulse();
  wxYieldIfNeeded();  
}
The constructor of the MyDialog class would have this at the end:

Code: Select all

  m_WinDisabler = new wxWindowDisabler(this);
  Show();
  Enable();
  wxDialog::Update();
Then delete the m_WinDisabler in the dtor. The condition for the while loop would presumably be some variable set if you were waiting on work being done in the background. This is just the scenario that I needed. It sounds like your problem might be even easier to solve.

I got this idea and from another post a while back, so someone else deserves the credit.

I use it in my app to update my custom progress dialog while still drawing the main GUI with updates behind it (but not allowing user input to muck with it).

Good luck.
-gw

spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

Post by spectrum » Wed Oct 28, 2009 6:58 pm

many thanks,

anyway, wxWindowsDisabler block the main frame loop.
Every kind of for/while loop will not make the main loop to return.
And i need it to return since i have to enter the MainFrame::OnIdle where i process some GUI updates.

So i have found only one solution actually, let me know if you see some ctitical points:

I derive from wxDialog, in constructor i collect all the childrens into a wxWindowList, i connect all the children kill_focus events to a single static OnLostFocus, from there,
if the window that trigger the KillFocus is not in the children list, i move the focus back to the dialog.

Then i do a Show() without blocking with any loop, and return.
And it act like a modal dialog.

regards,
spectrum

Post Reply