cocoa fullscreen with menubar

Discussion in 'Mac Programming' started by Darkroom, Oct 9, 2007.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    hi... i've searched for what i'm assuming should be easy cut+paste cocoa code, but i can't seem to find it...

    1) code that will allow my app to essentially start in fullscreen mode with menubar, but also have a key event (like "F" in Photoshop CS3) that will toggle the main window between fullscreen with menu bar, fullscreen, and window... (i don't need any resolution switching code, it's just for the main window)

    2) also, does anyone know how to make the main window fade in when it starts up? again, much like Adobe's CS3 apps that quickly fade in and fade out.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Check out this article from Apple. The function you want is SetSystemUIMode().

    There's an example of this at /Developer/Examples/Quartz/Core Image/FunHouse

    NSWindow has a method setAlphaValue: which takes a value from 0.0 to 1.0. You can use this, with a timer, to fade a window.
     
  3. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #3
    it seems i need to somehow declare kUIModeAllHidden and kUIModeNormal functions... ??? ...

    i've updated my code here so everyone can totally see what i'm doing wrong: http://www.imagectrl.com/LightTest.zip

    i don't believe i'm terribly far off, but of course, i probably am... and i'm still wondering if it's kinda dumb of me (or not) to have 2 seperate objects for the 2 different screen modes... like, i'm probably suppose to have only one object for the screen mode... right?
     
  4. Nutter macrumors 6502

    Joined:
    Mar 31, 2005
    Location:
    London, England
    #4
    You need to import the headers for Carbon, like so:

    Code:
    #import <Carbon/Carbon.h>
     
  5. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #5
    ok... including the carbon headers fixed my current errors... but now there is 1 "error" that i'm so not even understanding.

    i'm so lost... ridiculous...

    here's the updated code: http://www.imagectrl.com/LightTest.zip

    or...

    if anyone could write a super quick xcode that's simply a window with "full screen mode" / "window mode" menu items so that i can learn how to do it SetSystemUIMode() visually and send it to me, that would be perfect...
     
  6. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #6
    You need to add Carbon.framework to your project, and #import it via
    Code:
    #import <Carbon/Carbon.h>
    Then to go into full screen, use
    Code:
    SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
    To go back use
    Code:
    SetSystemUIMode(kUIModeNormal, 0);
    You also have to set the window's frame to be the screen's frame. Do this via the setFrame:display:animate: method, and you can get the screen's frame via the NSScreen class.
     
  7. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #7
    ok... the SetSystemUIMode seems to be working for me now... i had to add the carbon.framework file to make it work and not just write the include headers... now i'm trying to figure out making the window's frame become the screen's frame, and having no luck so far... any examples you could suggest?
     
  8. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #8
    am on on the right track here? or am i WAY off

    Code:
    - (IBAction)goFullScreenMode:(id)sender {
    	[NSWindow setFrame:[[NSScreen mainScreen] visibleFrame] display:YES animate:YES];
    	SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);    
    }
    
     
  9. cblackburn macrumors regular

    Joined:
    Jul 5, 2005
    Location:
    London, UK
    #9
    I did something like this once, you want to have a rifle through the documentation for a class called NSViewAnimation. Although this will limit your app to OS 10.4+, but these days I assume this is less and less a problem...

    Chris
     
  10. joaoferro99 macrumors member

    Joined:
    Feb 14, 2008
    Location:
    S. California
    #10
    Full ScreenMode?

    hi I am trying to learn how to put my window into full screen mode.
    what I want to do is similar to apple's registeration form - the one you would see right after OS installation.

    some textfields on it, some buttons on it.... and full screen without menu bar or launcher.

    any example?

    thx
     

Share This Page