Fullscreen mode switching

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
AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Fullscreen mode switching

Post by AUser »

Hello,

I am having some trouble implementing a tri-state fullscreen mode in GTK.

The idea is to cycle between not-fullscreen, fullscreen with menu & statusbar, and fullscreen without menu and statusbar.

So I have code like this:

Code: Select all

void MainWindowFrame::OnViewFullscreen(wxCommandEvent &event)
{
unsigned int flags;
   switch(fullscreenState)
        {    
                case 0:
                {    
                        flags= wxFULLSCREEN_NOTOOLBAR | wxFULLSCREEN_NOTOOLBAR | wxFULLSCREEN_NOTOOLBAR;
                        ShowFullScreen(true,flags);
                        break;
                }
                case 1:
                {    
                        //ShowFullScreen(false);
                        //SendSizeEvent(); // PRocess the sizeing of the window
             ShowFullScreen(true);
                        break;
                }            
                case 2:
                        ShowFullScreen(false);
                        break;
		default:
			ASSERT(false);
	}


        fullscreenState++;
        fullscreenState%=3;
}
Now this works under one GTK box (Opensuse), most of the time (so it seems like some kind of event race??), if (and only if) I uncomment the ShowFullscreen(false).

On the other GTK box (Debian testing/experimental) it doesn't work at all in either case.

I have not tested this under any other systems.

I tried using delay timers to alter the behaviour (no apparent effect, good or bad), and I tried putting in the SendSizeEvent() call in the middle. I have also tried reversing case 0 and case 1 (adding the status/menu bar, rather than hiding it).

Any other ideas? I can use either fullscreen mode independently, I just can't switch between them. Perhaps someone has some good thoughts?



Thanks
AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser »

Hello again,

Just going to reply to myself here, a little.

My testing indicates the original method:

wxMac: works
wxMSW: Doesn't work
wxGTK: Works on some versions

So, thats not good. Let's try plan B:

I can call statusbar->Hide(), and it does the right thing. However, under GTK, calling TopMenubar->Hide(), does indeed hide the menu bar, but leaves a blanks space in its wake.

I can SetMenuBar(0), which does the right thing, but this has the downside of removing all the keyboard accellerators with it.

Is there any way to hide a menubar, without leaving a blank behind it??

Thanks
briceandre
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 672
Joined: Tue Aug 31, 2010 6:22 am
Location: Belgium

Post by briceandre »

You can add a menubar as any other controls, directly in a sizer.

I you choose this option, there are two kinds of sizers (wxBoxSizer, I am sure, and IIRC wxGridSizer) that can hide controls and resize like if they did not exist.

So, the simplest way is to change your app layout to put your toolbar in a wxBoxSizer. When you want it to disapear, you do :

Code: Select all

   sizer->Hide(menubar);
   sizer->Layout();
That's all...

BTW, did you try to perform a Layout after having invoked TopMenubar->Hide() ? Maybe it would also work...
Post Reply