Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 14, 2007, 10:56 AM   #1
Darkroom
Guest
 
Join Date: Dec 2006
Location: Montréal, Canada
welcome to errorville... population me... (code snippet / please help)

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
Darkroom is offline   0 Reply With Quote
Old Nov 14, 2007, 11:50 AM   #2
kainjow
Demi-God (Moderator emeritus)
 
kainjow's Avatar
 
Join Date: Jun 2000
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];
kainjow is offline   0 Reply With Quote
Old Nov 14, 2007, 11:51 AM   #3
glennyboiwpg
macrumors 6502
 
Join Date: Feb 2007
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.
glennyboiwpg is offline   0 Reply With Quote
Old Nov 14, 2007, 11:58 AM   #4
kainjow
Demi-God (Moderator emeritus)
 
kainjow's Avatar
 
Join Date: Jun 2000
Also, you need to pay attention to compiler warnings. They alone should tell you that this code won't work.
kainjow is offline   0 Reply With Quote
Old Nov 14, 2007, 01:38 PM   #5
Darkroom
Thread Starter
Guest
 
Join Date: Dec 2006
Location: 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]
Darkroom is offline   0 Reply With Quote
Old Nov 14, 2007, 01:54 PM   #6
kainjow
Demi-God (Moderator emeritus)
 
kainjow's Avatar
 
Join Date: Jun 2000
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.

Last edited by kainjow; Nov 14, 2007 at 02:00 PM.
kainjow is offline   0 Reply With Quote
Old Nov 15, 2007, 12:34 AM   #7
Darkroom
Thread Starter
Guest
 
Join Date: Dec 2006
Location: 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.
Darkroom is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Welcome to USA! Welcome to the 3rd World, Home of low wage, no benefit jobs. Ugg Politics, Religion, Social Issues 161 Apr 25, 2011 09:49 AM
Bad Company 2 Beta - Who is with me???! (Codes available!) SchneiderMan Console Games 13 Nov 19, 2009 07:41 PM
Did you get a Glossy/ Matted Screen MBP? (Will buy MBP today, please help) MiniMini MacBook Pro 84 Jul 3, 2009 01:42 PM
Let me be first to say...Welcome to Canada! dornoforpyros Politics, Religion, Social Issues 9 Nov 4, 2004 12:47 AM


All times are GMT -5. The time now is 08:14 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC