Back to index

libsfml  1.6+dfsg2
Public Member Functions
sfPrivImportedWindow Class Reference

Class for creating SFML windows from Cocoa windows /////////////////////////////////////////////////////////. More...

#import <GLKit.h>

Inheritance diagram for sfPrivImportedWindow:
Inheritance graph
[legend]
Collaboration diagram for sfPrivImportedWindow:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(id) - initWithWindow:settings:
 Returns a new SFML window handler with the given window and parameters /////////////////////////////////////////////////////////.
(NSWindow *) - window
 Return a reference to the internal Cocoa window /////////////////////////////////////////////////////////.
(sfPrivGLView *) - view
 Return a reference to the internal Cocoa OpenGL view /////////////////////////////////////////////////////////.
(void) - setDelegate:
 Sets as the window delegate /////////////////////////////////////////////////////////.
(sf::priv::WindowImplCocoa *) - delegate
 Returns the window delegate /////////////////////////////////////////////////////////.
(void) - setPosition:
 Forward call to set the window position on screen /////////////////////////////////////////////////////////.
(void) - setSize:
 Forward call to set the window size /////////////////////////////////////////////////////////.
(NSPoint) - mouseLocation
 Return the mouse location relative to the internal window /////////////////////////////////////////////////////////.
(BOOL) - mouseInside
 Return whether the mouse is on our window /////////////////////////////////////////////////////////.
(void) - show:
 Close or open the window /////////////////////////////////////////////////////////.
(void) - enableVerticalSync:
 Forward call to en/disable the OpenGL view vertical synchronization /////////////////////////////////////////////////////////.
(void) - setActive:
 Forward 'setActive' call the the OpenGL view /////////////////////////////////////////////////////////.
(void) - flushBuffer
 Forward call to flush the OpenGL view /////////////////////////////////////////////////////////.
(void) - dealloc [implementation]
(void) - setWindow: [implementation]
 Registers a reference to the internal Cocoa window /////////////////////////////////////////////////////////.
(void) - putOpenGLView: [implementation]
 Registers the the OpenGL view and adds it to its parent container /////////////////////////////////////////////////////////.
(void) - setView: [implementation]
 Registers a reference to the internal Cocoa OpenGL view /////////////////////////////////////////////////////////.
(void) - windowDidBecomeMain: [implementation]
 Notification method receiver when the window gains focus /////////////////////////////////////////////////////////.
(void) - windowDidResignMain: [implementation]
 Notification method receiver when the window loses focus /////////////////////////////////////////////////////////.
(void) - windowWillClose: [implementation]
 Notification method receiver when the window closes /////////////////////////////////////////////////////////.

Detailed Description

Class for creating SFML windows from Cocoa windows /////////////////////////////////////////////////////////.

Definition at line 206 of file GLKit.h.


Member Function Documentation

- (void) dealloc [implementation]

Reimplemented in sfPrivImportedView, and sfPrivOwnedWindow.

Definition at line 507 of file GLKit.mm.

{
       NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
       // Remove the notification observer
       [[NSNotificationCenter defaultCenter] removeObserver:self];
       
       // Close the window
       [self show:false];
       
       // Release the window and view
       [[self view] removeFromSuperviewWithoutNeedingDisplay];
       
       [self setWindow:nil];
       [self setView:nil];
       [self setDelegate:nil];
       
       [super dealloc];
       [localPool release];
}

Here is the call graph for this function:

Here is the caller graph for this function:

- sf:

Returns the window delegate /////////////////////////////////////////////////////////.

Definition at line 627 of file GLKit.mm.

{
       return [[self view] delegate];
}

Here is the call graph for this function:

- (void) enableVerticalSync: (bool)  flag

Forward call to en/disable the OpenGL view vertical synchronization /////////////////////////////////////////////////////////.

Definition at line 718 of file GLKit.mm.

                          :(bool)flag
{
       NSAssert([self view] != nil, @"expected valid OpenGL view");
       [[self view] enableVerticalSync:flag];
}

Here is the call graph for this function:

- (void) flushBuffer

Forward call to flush the OpenGL view /////////////////////////////////////////////////////////.

Definition at line 736 of file GLKit.mm.

{
       NSAssert([self view] != nil, @"expected valid OpenGL view");
       [[self view] flushBuffer];
}

Here is the call graph for this function:

- (id) initWithWindow: (NSWindow *)  aWindow
settings: (sf::WindowSettings&)  someSettings 

Returns a new SFML window handler with the given window and parameters /////////////////////////////////////////////////////////.

Definition at line 1007 of file GLKit.mm.

                    :(NSWindow *)aWindow
                     settings:(sf::WindowSettings&)someSettings
{
       self = [super init];
       
       if (self) {
              [self setWindow:aWindow];
              
              // Make the OpenGL view
              sf::VideoMode mode([[[self window] contentView] frame].size.width,
                                             [[[self window] contentView] frame].size.height);
              sfPrivGLView *newView = [[sfPrivGLView alloc]
                                             initWithFrame:[[[self window] contentView] frame]
                                             mode:mode
                                             settings:someSettings];
              
              if (!newView) {
                     std::cerr << "Unable to create the OpenGL view" << std::endl;
                     [self autorelease];
                     return nil;
              }
              
              [self putOpenGLView:[newView autorelease]];
              
              [[self window] setAcceptsMouseMovedEvents:YES];
       }
       
       return self;
}

Here is the call graph for this function:

- (BOOL) mouseInside

Return whether the mouse is on our window /////////////////////////////////////////////////////////.

Definition at line 674 of file GLKit.mm.

{
       NSAssert([self window] != nil, @"expected valid window");
       NSAssert([self view] != nil, @"expected valid OpenGL view");
       
       BOOL flag = NO;
       
       if ([[self window] isVisible]) {
              NSPoint relativeToWindow = [[self window] mouseLocationOutsideOfEventStream];
              NSPoint relativeToView = [[self view] convertPoint:relativeToWindow fromView:nil];
              
              if (NSPointInRect (relativeToView, [[self view] bounds]))
              {
                     flag = YES;
              }
       }
       
       return flag;
}

Here is the call graph for this function:

- (NSPoint) mouseLocation

Return the mouse location relative to the internal window /////////////////////////////////////////////////////////.

Definition at line 660 of file GLKit.mm.

{
       NSAssert([self view] != nil, @"expected valid window");
       
       NSPoint windowPoint = [[self window] convertScreenToBase:[NSEvent mouseLocation]];
       NSPoint viewPoint = [[self view] convertPoint:windowPoint fromView:[[[self window] contentView] superview]];
       
       viewPoint.y = [[self view] frame].size.height - viewPoint.y;
       return viewPoint;
}

Here is the call graph for this function:

- (void) putOpenGLView: (sfPrivGLView *)  aView [implementation]

Registers the the OpenGL view and adds it to its parent container /////////////////////////////////////////////////////////.

Reimplemented in sfPrivImportedView.

Definition at line 586 of file GLKit.mm.

                     :(sfPrivGLView *)aView
{
       [self setView:aView];
       
       // Finish setting up the view and window
       // Add the view to our window and tell it to the view
       [[[self window] contentView] addSubview:[self view]];
       [[self view] finishInitialization];
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) setActive: (bool)  flag

Forward 'setActive' call the the OpenGL view /////////////////////////////////////////////////////////.

Definition at line 727 of file GLKit.mm.

                 :(bool)flag
{
       NSAssert([self view] != nil, @"expected valid OpenGL view");
       [[self view] setActive:flag];
}

Here is the call graph for this function:

- (void) setDelegate: (sf::priv::WindowImplCocoa *)  aDelegate

Sets as the window delegate /////////////////////////////////////////////////////////.

Definition at line 619 of file GLKit.mm.

                   :(sf::priv::WindowImplCocoa *)aDelegate
{
       [[self view] setDelegate:aDelegate];
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) setPosition: (NSPoint)  pos

Forward call to set the window position on screen /////////////////////////////////////////////////////////.

Reimplemented in sfPrivImportedView, and sfPrivOwnedWindow.

Definition at line 635 of file GLKit.mm.

                   :(NSPoint)pos
{
       NSAssert([self window] != nil, @"expected valid window");
       
       // Flip Y and set window position
       pos.y = [[[self window] screen] frame].size.height - pos.y;
       [[self window] setFrameTopLeftPoint:pos];
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) setSize: (NSSize)  size

Forward call to set the window size /////////////////////////////////////////////////////////.

Reimplemented in sfPrivImportedView, and sfPrivOwnedWindow.

Definition at line 647 of file GLKit.mm.

               :(NSSize)size
{
       NSAssert([self window] != nil, @"expected valid window");
       
       [[self window] setFrame:NSMakeRect([[self window] frame].origin.x,
                                                                  [[self window] frame].origin.y,
                                                                  size.width, size.height)
                                   display:YES];
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) setView: (sfPrivGLView *)  aView [implementation]

Registers a reference to the internal Cocoa OpenGL view /////////////////////////////////////////////////////////.

Definition at line 599 of file GLKit.mm.

               :(sfPrivGLView *)aView
{
       if (myView != aView)
       {
              [myView release];
              myView = [aView retain];
       }
}

Here is the caller graph for this function:

- (void) setWindow: (NSWindow *)  aWindow [implementation]

Registers a reference to the internal Cocoa window /////////////////////////////////////////////////////////.

Definition at line 530 of file GLKit.mm.

                 :(NSWindow *)aWindow
{
       if (myWindow != aWindow)
       {
              NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
              
              // Drop the observers on the previously set window
              if ([self window]) {
                     [nc removeObserver:self 
                                            name:NSWindowDidBecomeMainNotification
                                          object:[self window]];
                     [nc removeObserver:self 
                                            name:NSWindowDidResignMainNotification
                                          object:[self window]];
                     [nc removeObserver:self 
                                            name:NSWindowWillCloseNotification
                                          object:[self window]];
              }
              
              [myWindow release];
              myWindow = [aWindow retain];
              
              // Set the new observers
              // We want to know when our window got the focus
              [nc addObserver:self
                        selector:@selector(windowDidBecomeMain:)
                               name:NSWindowDidBecomeMainNotification
                             object:[self window]];
              
              // We want to know when our window lost the focus
              [nc addObserver:self
                        selector:@selector(windowDidResignMain:)
                               name:NSWindowDidResignMainNotification
                             object:[self window]];
              
              // We want to know when the user closes the window
              [nc addObserver:self
                        selector:@selector(windowWillClose:)
                               name:NSWindowWillCloseNotification
                             object:[self window]];
              
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) show: (bool)  flag

Close or open the window /////////////////////////////////////////////////////////.

Reimplemented in sfPrivOwnedWindow.

Definition at line 697 of file GLKit.mm.

            :(bool)flag
{
       NSAssert([self window] != nil, @"expected valid window");
       
       if (flag && ![[self window] isVisible]) {
              // Wanna open the closed window
              
              // Show the window
              [[self window] makeKeyAndOrderFront:nil];
       } else if (!flag && [[self window] isVisible]) {
              // Wanna close the opened window
              
              // Close the window
              [[self window] close];
       }      
}

Here is the call graph for this function:

Here is the caller graph for this function:

Return a reference to the internal Cocoa OpenGL view /////////////////////////////////////////////////////////.

Definition at line 611 of file GLKit.mm.

{
       return [[myView retain] autorelease];
}

Here is the caller graph for this function:

Return a reference to the internal Cocoa window /////////////////////////////////////////////////////////.

Definition at line 577 of file GLKit.mm.

{
       return [[myWindow retain] autorelease];
}

Here is the caller graph for this function:

- (void) windowDidBecomeMain: (NSNotification *)  notification [implementation]

Notification method receiver when the window gains focus /////////////////////////////////////////////////////////.

Definition at line 745 of file GLKit.mm.

                           :(NSNotification *)notification
{
       sf::Event ev;
       ev.Type = sf::Event::GainedFocus;
       
       [[self view] pushEvent:ev];
}

Here is the call graph for this function:

- (void) windowDidResignMain: (NSNotification *)  notification [implementation]

Notification method receiver when the window loses focus /////////////////////////////////////////////////////////.

Definition at line 757 of file GLKit.mm.

                           :(NSNotification *)notification
{
       sf::Event ev;
       ev.Type = sf::Event::LostFocus;
       
       [[self view] pushEvent:ev];
}

Here is the call graph for this function:

- (void) windowWillClose: (NSNotification *)  notification [implementation]

Notification method receiver when the window closes /////////////////////////////////////////////////////////.

Definition at line 769 of file GLKit.mm.

                       :(NSNotification *)notification
{
       sf::Event ev;
       ev.Type = sf::Event::Closed;
       
       [[self view] pushEvent:ev];
}

Here is the call graph for this function:


The documentation for this class was generated from the following files: