Maximize window on Mac

BlitzMax Forums/BlitzMax Programming/Maximize window on Mac

GfK(Posted 2011) [#1]
I've managed to add the + icon to my window by modifying glgraphics.macos.m and changing
style=NSTitledWindowMask|NSClosableWindowMask;
	
to
style=NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask;
	
that works, but when I click it, the window changes to the desktop size, with the game window at the original size in the top left corner.

What I want want to do is detect the + being clicked, and set my game to fullscreen. I did it for Magicville but I cannot work out how. I think it was a further module tweak but I can't find anything.


GfK(Posted 2011) [#2]
Well, after downloding Magicville to check it turns out I *hadn't* got it working for that.

However, it now works. For anybody else who cares about such pedantry, to get the zoom button to function in MacOS you need to edit brl.mod/glgraphics.mod/glgraphics.macos.m >

First, find this code:
style=NSTitledWindowMask|NSClosableWindowMask;
...and change it to:
style=NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask;

This will add the minimize and zoom buttons to the window.

Next, find this code (starting at line 37)
-(BOOL)windowShouldClose:(id)sender{
	bbSystemEmitEvent( BBEVENT_APPTERMINATE,&bbNullObject,0,0,0,0,&bbNullObject );
	return NO;
}

AFTER this code, add the following:
-(void) windowDidMiniaturize:(NSNotification *) note {
	bbSystemEmitEvent( BBEVENT_APPSUSPEND,&bbNullObject,0,0,0,0,&bbNullObject );
}
-(void) windowDidDeminiaturize:(NSNotification *) note {
	bbSystemEmitEvent( BBEVENT_APPRESUME,&bbNullObject,0,0,0,0,&bbNullObject );
}
-(void) windowDidResize:(NSNotification *) note {
	bbSystemEmitEvent( BBEVENT_WINDOWSIZE,&bbNullObject,0,0,0,0,&bbNullObject );
}
Note, the first two functions there were added by Grable/Grey Alien but since you'll want to minimise your app as well, you might as well add those functions in now.

Once you've done that, save the file and go into MaxIDE and rebuild modules.

Clicking the Zoom button will now generate an EVENT_WINDOWSIZE event which you can trap, and change graphics modes.


GfK(Posted 2011) [#3]
Could somebody move this into module tweaks please? Also be nice if this was put into an official build of Blitzmax, so I don't have to keep redoing it each update (this stuff is a fairly standard requirement for casual games).


matt!(Posted 2011) [#4]
Thanks for this!

I'm using it to double the window size when the user clicks maximise. I set graphics size in my EVENT_WINDOWSIZE code, which constrains the size of the maximised window.

I just need a way to disable the animation when maximising the window...


GfK(Posted 2011) [#5]
I think thats an OS setting so pretty much down to the user?


matt!(Posted 2011) [#6]
I can't find any such setting in Mac OS X?

Let me know if you think I should start a new thread about it...

But here's some sample code to show the issue




matt!(Posted 2011) [#7]
In Objective-C you can choose whether or not to have a window resize animated or not. I assume something like this is in the bowels of BMX?

[mainWindow
    setFrame:[mainWindow frameRectForContentRect:[[mainWindow screen] frame]]
    display:YES
    animate:YES];