Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
hi there... i know some of you will look at this code and roll your eyes until they fall out, but it's the farthest i've come over the past several hours to making this code snippet make any sense to me, and at the risk of ridicule, i'm seeking help.

the window starts in full screen... i've simply created two IBActions (full screen mode and window mode) that i want to change the NSwindow's screen mode... simple right? yeahh... right...

Code:
#import "mainWindow.h"
#import <Carbon/Carbon.h>

@implementation mainWindow

- (id) initWithContentRect: (NSRect) contentRect
                 styleMask: (unsigned int) aStyle
                   backing: (NSBackingStoreType) bufferingType
                     defer: (BOOL) flag
	{
    self = [super initWithContentRect: contentRect
							styleMask: NSBorderlessWindowMask
                              backing: bufferingType
                                defer: flag];

    
	SetSystemUIMode(kUIModeAllHidden, 0);
	[self setFrame:[[NSScreen mainScreen] visibleFrame] display:YES animate:NO];
	SetSystemUIMode(kUIModeAllSuppressed, 0);

    
    return self;
}

- (IBAction)goWindowMode:(id)sender {
		   [super initWithContentRect: contentRect
							styleMask: NSResizableWindowMask | NSMiniaturizableWindowMask
                              backing: bufferingType
                                defer: flag];

    
	SetSystemUIMode(kUIModeNormal, 0);
	[self setFrame:[[NSWindow mainWindow] visibleFrame] display:YES animate:NO];
 

}

- (IBAction)goFullScreenMode:(id)sender {

}


@end
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Code:
- (IBAction)goWindowMode:(id)sender {
		   [super initWithContentRect: contentRect
							styleMask: NSResizableWindowMask | NSMiniaturizableWindowMask
                              backing: bufferingType
                                defer: flag];

    
	SetSystemUIMode(kUIModeNormal, 0);
	[self setFrame:[[NSWindow mainWindow] visibleFrame] display:YES animate:NO];
 

}

First, you are calling [super initWithContentRect...] here. This is only to be used in an init... method, like you use it above. It is used to initialize the class using the super class's initialization method. Using it anywhere else is incorrect.

Second, when you're changing the window frame, you're just setting it to be full screen again. You need to create a new NSRect and set it to that. For example:
Code:
[self setFrame:NSMakeRect(50, 50, 200, 200) display:YES animate:NO];
 

glennyboiwpg

macrumors 6502
Feb 16, 2007
262
0
I've never programmed for the mac (I'm a Java junkie) but I'm guessing a screenshot of the error (Or stacktrace, if Objective-c has those) would be helpeful for those who actually know objective-c.


Good Luck.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Also, you need to pay attention to compiler warnings. They alone should tell you that this code won't work.
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
Code:
- (IBAction)goWindowMode:(id)sender {
		   styleMask: NSResizableWindowMask | NSMiniaturizableWindowMask
                              }

if i write this, in trying to tell the style mask to switch from it's initial NSBorderlessWindowMask, it says it hasn't been declared... like, i just don't understand how i can write it any way else... i've been searching online and thru the docs all afternoon to no avail...

but thanks for the following code example:

Code:
[self setFrame:NSMakeRect(50, 50, 200, 200) display:YES animate:NO];
[/QUOTE]
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
You can't change the styleMask once the window has been created. I'd suggest creating a separate window for your full screen window, and use the setContentView: method to synchronize the content views of both windows.

See Apple's example at /Developer/Examples/Quartz/Core Image/FunHouse. They manage two NSWindowControllers - one for full screen, and one for normal.
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
oh ok... that kinda makes sense then... i was just hoping that the style mask could be dynamically changed thru if/else statements or something... thanks for the help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.