Back to index

libsfml  1.6+dfsg2
Public Member Functions | Protected Attributes
sfPrivImportedView Class Reference

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

#import <GLKit.h>

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

List of all members.

Public Member Functions

(id) - initWithView:settings:
 Returns a new SFML window handler with the given view and parameters /////////////////////////////////////////////////////////.
(void) - dealloc [implementation]
(void) - putOpenGLView: [implementation]
 Registers the the OpenGL view and adds it to its parent container /////////////////////////////////////////////////////////.
(void) - setPosition: [implementation]
 Forward call to set the window position on screen /////////////////////////////////////////////////////////.
(void) - setSize: [implementation]
 Forward call to set the window size /////////////////////////////////////////////////////////.
(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 /////////////////////////////////////////////////////////.
(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) - setWindow: [implementation]
 Registers a reference to the internal Cocoa window /////////////////////////////////////////////////////////.
(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 /////////////////////////////////////////////////////////.

Protected Attributes

NSView * parentView

Detailed Description

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

Definition at line 221 of file GLKit.h.


Member Function Documentation

- (void) dealloc [implementation]

Reimplemented from sfPrivWindow.

Definition at line 1072 of file GLKit.mm.

{
       [parentView release];
       [super dealloc];
}

Here is the call 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) initWithView: (NSView *)  aView
settings: (sf::WindowSettings&)  someSettings 

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

Definition at line 1043 of file GLKit.mm.

                  :(NSView *)aView
                settings:(sf::WindowSettings&)someSettings
{      
       self = [super init];
       if (self)
       {
              parentView = [aView retain];
              [self setWindow:[parentView window]];
              
              // Make the OpenGL view
              sf::VideoMode mode([parentView bounds].size.width,
                                             [parentView bounds].size.height);
              sfPrivGLView *newView = [[sfPrivGLView alloc]
                                             initWithFrame:[parentView bounds]
                                             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 from sfPrivWindow.

Definition at line 1081 of file GLKit.mm.

                     :(sfPrivGLView *)aView
{
       [self setView:aView];
       
       // Finish setting up the view and window
       NSRect originalFrame = [[self window] frame];
       NSRect tmpFrame = originalFrame;
       originalFrame.origin.x++;
       
       [[self window] setFrame:tmpFrame display:YES];
       [[self window] setFrame:originalFrame display:YES];
       
       
       // Add the view to our *parent view* and tell it to the view
       [parentView 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)  aPosition [implementation]

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

Reimplemented from sfPrivWindow.

Definition at line 1102 of file GLKit.mm.

                   :(NSPoint)aPosition
{
       std::cerr
       << "Warning: called Window::SetPosition() on a window imported from a widget. "
       << "This method has been disabled in this case and has no effect. "
       << "Directly use the widget if you want to move it."
       << std::endl;
}
- (void) setSize: (NSSize)  size [implementation]

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

Reimplemented from sfPrivWindow.

Definition at line 1114 of file GLKit.mm.

               :(NSSize)size
{
       std::cerr
       << "Warning: called Window::SetSize() on a window imported from a widget. "
       << "This method has been disabled in this case and has no effect. "
       << "Directly use the widget if you want to resize it."
       << std::endl;
}
- (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:


Member Data Documentation

- (NSView*) parentView [protected]

Definition at line 223 of file GLKit.h.


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