Back to index

libsfml  1.6+dfsg2
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
sf::priv::WindowImplCocoa Class Reference

WindowImplCocoa is the Cocoa implementation of WindowImpl /////////////////////////////////////////////////////////. More...

#include <WindowImplCocoa.hpp>

Inheritance diagram for sf::priv::WindowImplCocoa:
Inheritance graph
[legend]
Collaboration diagram for sf::priv::WindowImplCocoa:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 WindowImplCocoa ()
 Default constructor (creates a dummy window to provide a valid OpenGL context)
 WindowImplCocoa (WindowHandle Handle, WindowSettings &params)
 Construct the window implementation from an existing control.
 WindowImplCocoa (VideoMode Mode, const std::string &Title, unsigned long WindowStyle, WindowSettings &params)
 Create the window implementation.
 ~WindowImplCocoa ()
 Destructor.
void HandleNotifiedEvent (Event &eventRef)
 Handle an event sent by the default NSNotificationCenter /////////////////////////////////////////////////////////.
void HandleKeyDown (void *eventRef)
 Event handling for every event type. 'eventRef' is a NSEvent. /////////////////////////////////////////////////////////.
void HandleKeyUp (void *eventRef)
 Handle a key up event (NSEvent) /////////////////////////////////////////////////////////.
void HandleModifierKey (void *eventRef)
 Handle a key modifier event [Command, Option, Control, Shift] /////////////////////////////////////////////////////////.
void HandleMouseDown (void *eventRef)
 Handle a mouse down event (NSEvent) /////////////////////////////////////////////////////////.
void HandleMouseUp (void *eventRef)
 Handle a mouse up event (NSEvent) /////////////////////////////////////////////////////////.
void HandleMouseMove (void *eventRef)
 Handle a mouse move event (NSEvent) /////////////////////////////////////////////////////////.
void HandleMouseWheel (void *eventRef)
 Handle a mouse wheel event (NSEvent) /////////////////////////////////////////////////////////.
void AddListener (WindowListener *Listener)
 Add a listener to the window.
void RemoveListener (WindowListener *Listener)
 Remove a listener from the window.
void Initialize ()
 Initialize window's states that can't be done at construction.
unsigned int GetWidth () const
 Get the client width of the window.
unsigned int GetHeight () const
 Get the client height of the window.
void SetJoystickThreshold (float Threshold)
 Change the joystick threshold, ie. the value below which no move event will be generated.
void DoEvents ()
 Process incoming events from operating system.

Static Public Member Functions

static bool IsContextActive ()
 Check if there's an active context on the current thread.
static bool IsTextEvent (void *event)
 Return whether 'ev' must be considered as a TextEntered event /////////////////////////////////////////////////////////.
static WindowImplNew ()
 Create a new window depending on the current OS.
static WindowImplNew (VideoMode Mode, const std::string &Title, unsigned long WindowStyle, WindowSettings &Params)
 Create a new window depending on the current OS.
static WindowImplNew (WindowHandle Handle, WindowSettings &Params)
 Create a new window depending on to the current OS.

Protected Member Functions

void SendEvent (const Event &EventToSend)
 Send an event to listeners (for derived classes only)

Static Protected Member Functions

static int EvaluateConfig (const VideoMode &Mode, const WindowSettings &Settings, int ColorBits, int DepthBits, int StencilBits, int Antialiasing)
 Evaluate a pixel format configuration. This functions can be used by implementations that have several valid formats and want to get the best one.

Protected Attributes

unsigned int myWidth
 Internal width of the window.
unsigned int myHeight
 Internal height of the window.

Private Member Functions

virtual void Display ()
 see WindowImpl::Display
virtual void ProcessEvents ()
 see WindowImpl::ProcessEvents
virtual void SetActive (bool Active=true) const
 see WindowImpl::MakeActive
virtual void UseVerticalSync (bool Enabled)
 see WindowImpl::UseVerticalSync
virtual void ShowMouseCursor (bool Show)
 see WindowImpl::ShowMouseCursor
virtual void SetCursorPosition (unsigned int Left, unsigned int Top)
 see WindowImpl::SetCursorPosition
virtual void SetPosition (int Left, int Top)
 see WindowImpl::SetPosition
virtual void SetSize (unsigned int Width, unsigned int Height)
 /see WindowImpl::SetSize
virtual void Show (bool State)
 see WindowImpl::Show
virtual void EnableKeyRepeat (bool Enabled)
 see WindowImpl::EnableKeyRepeat
virtual void SetIcon (unsigned int Width, unsigned int Height, const Uint8 *Pixels)
 see WindowImpl::SetIcon

Private Attributes

sfPrivWindowRef myWrapper
 My own part starts here ! /////////////////////////////////////////////////////////.
bool myUseKeyRepeat
bool myMouseIn
float myWheelStatus

Detailed Description

WindowImplCocoa is the Cocoa implementation of WindowImpl /////////////////////////////////////////////////////////.

Definition at line 50 of file WindowImplCocoa.hpp.


Constructor & Destructor Documentation

Default constructor (creates a dummy window to provide a valid OpenGL context)

Default constructor (creates a dummy window to provide a valid OpenGL context) /////////////////////////////////////////////////////////.

/////////////////////////////////////////////////////////

Definition at line 64 of file WindowImplCocoa.mm.

                                 :
myWrapper(nil),
myUseKeyRepeat(false),
myMouseIn(false),
myWheelStatus(0.0f)
{
       [sfPrivAppController sharedController];
       
    // Create the shared OpenGL context
       if ([sfPrivGLContext sharedContext]) {
              // Then we make it the current active OpenGL context
              SetActive();
       } else {
              std::cerr << "Unable to make the main shared OpenGL context" << std::endl;
       }
}

Here is the call graph for this function:

sf::priv::WindowImplCocoa::WindowImplCocoa ( WindowHandle  Handle,
WindowSettings params 
)

Construct the window implementation from an existing control.

Create the window implementation from an existing control /////////////////////////////////////////////////////////.

Parameters:
Handle: Platform-specific handle of the control
Params: Creation parameters

Note: the NSWindow object must not be defered ! /////////////////////////////////////////////////////////

Definition at line 85 of file WindowImplCocoa.mm.

                                                                            :
myWrapper(NULL),
myUseKeyRepeat(false),
myMouseIn(false),
myWheelStatus(0.0f)
{
       if (Handle) {
              // Classical window import
              if ([(id)Handle isKindOfClass:[NSWindow class]]) {
                     myWrapper = [[sfPrivImportedWindow alloc]
                                           initWithWindow:(NSWindow *)Handle
                                           settings:params];
              }
              // Qt "window" import
              else if ([(id)Handle isKindOfClass:[NSView class]]) {
                     myWrapper = [[sfPrivImportedView alloc]
                                           initWithView:(NSView *)Handle
                                           settings:params];
              } else {
                     std::cerr 
                     << "Cannot import this Window Handle because it is neither"
                     << "a <NSWindow *> nor <NSView *> object"
                     << "(or any of its subclasses). You gave a <" 
                     << [[(id)Handle className] UTF8String]
                     << "> object."
                     << std::endl;
                     
              }

              if (myWrapper) {
                     [myWrapper setDelegate:this];
                     
                     // initial mouse state
                     myMouseIn = [myWrapper mouseInside];
                     
                     // We set the myWidth and myHeight members to the correct values
                     myWidth = (int) [[myWrapper view] frame].size.width;
                     myHeight = (int) [[myWrapper view] frame].size.height;
              } else {
                     std::cerr << "Failed to make the public window" << std::endl;
              }
       } else {
              std::cerr
              << "Invalid null handle given to "
              << "Window::Window(WindowHandle Handle, const WindowSettings& Params)"
              << std::endl;
       }
}
sf::priv::WindowImplCocoa::WindowImplCocoa ( VideoMode  Mode,
const std::string &  Title,
unsigned long  WindowStyle,
WindowSettings params 
)

Create the window implementation.

Create the window implementation /////////////////////////////////////////////////////////.

Parameters:
Mode: Video mode to use
Title: Title of the window
WindowStyle: Window style
Params: Creation parameters

/////////////////////////////////////////////////////////

Definition at line 138 of file WindowImplCocoa.mm.

                                                                                                                          :
myWrapper(NULL),
myUseKeyRepeat(false),
myMouseIn(false),
myWheelStatus(0.0f)
{
    // Create a new window with given size, title and style
       // First we define some objects used for our window
       NSString *title = [NSString stringWithCString:(Title.c_str()) ? (Title.c_str()) : ""
                                                                       encoding:NSASCIIStringEncoding];
       
       // We create the window
       myWrapper = [[sfPrivOwnedWindow alloc]
                             initWithVideoMode:Mode
                             settings:params
                             style:WindowStyle
                             title:title];
       
       
       
       if (myWrapper)
       {
              [myWrapper setDelegate:this];
              
              // initial mouse state
              myMouseIn = [myWrapper mouseInside];
              
              // We set the myWidth and myHeight members to the correct values
              myWidth = Mode.Width;
              myHeight = Mode.Height;
       } else {
              std::cerr << "Failed to make the public window" << std::endl;
       }
}

Destructor.

Destructor /////////////////////////////////////////////////////////.

/////////////////////////////////////////////////////////

Definition at line 177 of file WindowImplCocoa.mm.

{
       // Release the window wrapper
       [myWrapper release];
}

Member Function Documentation

void sf::priv::WindowImpl::AddListener ( WindowListener *  Listener) [inherited]

Add a listener to the window.

Add a listener to the window /////////////////////////////////////////////////////////.

Parameters:
Listener: Listener to add

/////////////////////////////////////////////////////////

Definition at line 106 of file WindowImpl.cpp.

{
    if (Listener)
        myListeners.insert(Listener);
}
void sf::priv::WindowImplCocoa::Display ( ) [private, virtual]

see WindowImpl::Display

/see sfWindowImpl::Display /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 544 of file WindowImplCocoa.mm.

{
       // Forward flush call to the window
       [myWrapper flushBuffer];
}
void sf::priv::WindowImpl::DoEvents ( ) [inherited]

Process incoming events from operating system.

Process incoming events from operating system /////////////////////////////////////////////////////////.

/////////////////////////////////////////////////////////

Definition at line 167 of file WindowImpl.cpp.

{
    // Read the joysticks state and generate the appropriate events
    ProcessJoystickEvents();

    // Let the derived class process other events
    ProcessEvents();
}

Here is the call graph for this function:

void sf::priv::WindowImplCocoa::EnableKeyRepeat ( bool  Enabled) [private, virtual]

see WindowImpl::EnableKeyRepeat

/see sfWindowImpl::EnableKeyRepeat /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 663 of file WindowImplCocoa.mm.

{
       myUseKeyRepeat = Enabled;
}
int sf::priv::WindowImpl::EvaluateConfig ( const VideoMode &  Mode,
const WindowSettings Settings,
int  ColorBits,
int  DepthBits,
int  StencilBits,
int  Antialiasing 
) [static, protected, inherited]

Evaluate a pixel format configuration. This functions can be used by implementations that have several valid formats and want to get the best one.

Evaluate a pixel format configuration. This functions can be used by implementations that have several valid formats and want to get the best one /////////////////////////////////////////////////////////.

Parameters:
Mode: Requested video mode
Settings: Requested additionnal settings
ColorBits: Color bits of the configuration to evaluate
DepthBits: Depth bits of the configuration to evaluate
StencilBits: Stencil bits of the configuration to evaluate
Antialiasing: Antialiasing level of the configuration to evaluate
Returns:
Score of the configuration : the lower the better

/////////////////////////////////////////////////////////

Definition at line 203 of file WindowImpl.cpp.

{
    return abs(static_cast<int>(Mode.BitsPerPixel          - ColorBits))   +
           abs(static_cast<int>(Settings.DepthBits         - DepthBits))   +
           abs(static_cast<int>(Settings.StencilBits       - StencilBits)) +
           abs(static_cast<int>(Settings.AntialiasingLevel - Antialiasing));
}

Here is the caller graph for this function:

unsigned int sf::priv::WindowImpl::GetHeight ( ) const [inherited]

Get the client height of the window.

Get the client height of the window /////////////////////////////////////////////////////////.

Returns:
Height of the window in pixels

/////////////////////////////////////////////////////////

Definition at line 148 of file WindowImpl.cpp.

{
    return myHeight;
}
unsigned int sf::priv::WindowImpl::GetWidth ( ) const [inherited]

Get the client width of the window.

Get the client width of the window /////////////////////////////////////////////////////////.

Returns:
Width of the window in pixels

/////////////////////////////////////////////////////////

Definition at line 139 of file WindowImpl.cpp.

{
    return myWidth;
}
void sf::priv::WindowImplCocoa::HandleKeyDown ( void *  eventRef)

Event handling for every event type. 'eventRef' is a NSEvent. /////////////////////////////////////////////////////////.

Handle a key down event (NSEvent) /////////////////////////////////////////////////////////.

Definition at line 218 of file WindowImplCocoa.mm.

{
       NSEvent *event = reinterpret_cast <NSEvent *> (eventRef);
       
       Event sfEvent;
       unichar chr = 0, rawchr = 0;
       unsigned long length = [[event characters] length];
       unsigned mods = [event modifierFlags];
       
       if (length) {
              chr = [[event characters] characterAtIndex:0];
              
              // Note : I got a crash (out of bounds exception) while typing so now I test...
              if ([[event charactersIgnoringModifiers] length])
                     rawchr = [[event charactersIgnoringModifiers] characterAtIndex:0];
              
              
              // Don't handle repeated events if we chose not to send them
              if (!myUseKeyRepeat && [event isARepeat])
                     return;
              
              // Is it also a text event ?
              if (IsTextEvent(event)) {
                     // buffer for the UTF-32 characters
                     Uint32 utf32Characters[2] = {0};
                     
                     // convert the characters
                     // note: using CFString in order to keep compatibility with Mac OS X 10.4
                     // (as NSUTF32StringEncoding is only being defined in Mac OS X 10.5 and later)
                     if (!CFStringGetCString ((CFStringRef)[event characters],
                                                                (char *)utf32Characters,
                                                                sizeof(utf32Characters),
                                                                kCFStringEncodingUTF32))
                     {
                            char asciiChar[3] = {0};
                            if ([[event characters] lengthOfBytesUsingEncoding:NSASCIIStringEncoding])
                                   [[event characters] getCString:asciiChar
                                                                       maxLength:3
                                                                        encoding:NSASCIIStringEncoding];
                            
                            std::cerr << "Error while converting character to UTF32 : \""
                            << asciiChar << "\"" << std::endl;
                     }
                     else
                     {
                            sfEvent.Type = Event::TextEntered;
                            sfEvent.Text.Unicode = utf32Characters[0];
                            
                            SendEvent(sfEvent);
                     }
              }
              
              // Anyway it's also a KeyPressed event
              sfEvent.Type = Event::KeyPressed;
              
              // Get the keys
              if (Key::Code(0) == (sfEvent.Key.Code = KeyForUnicode(rawchr))) {
                     sfEvent.Key.Code = KeyForVirtualCode([event keyCode]);
              }
              
              // Get the modifiers
              sfEvent.Key.Alt = mods & NSAlternateKeyMask;
              sfEvent.Key.Control = mods & NSControlKeyMask;
              sfEvent.Key.Shift = mods & NSShiftKeyMask;
              
              // Send the event
              SendEvent(sfEvent);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sf::priv::WindowImplCocoa::HandleKeyUp ( void *  eventRef)

Handle a key up event (NSEvent) /////////////////////////////////////////////////////////.

Definition at line 292 of file WindowImplCocoa.mm.

{
       NSEvent *event = reinterpret_cast <NSEvent *> (eventRef);
       
       Event sfEvent;
       unsigned mods = [event modifierFlags];
       unichar chr = 0, rawchr = 0;
       
       if ([[event characters] length]) {
              chr = [[event characters] characterAtIndex:0];
              
              if ([[event charactersIgnoringModifiers] length])
                     rawchr = [[event charactersIgnoringModifiers] characterAtIndex:0];
              
              sfEvent.Type = Event::KeyReleased;
              
              // Get the code
              if (Key::Code(0) == (sfEvent.Key.Code = KeyForUnicode(rawchr))) {
                     sfEvent.Key.Code = KeyForVirtualCode([event keyCode]);
              }
              
              // Get the modifiers
              sfEvent.Key.Alt = mods & NSAlternateKeyMask;
              sfEvent.Key.Control = mods & NSControlKeyMask;
              sfEvent.Key.Shift = mods & NSShiftKeyMask;
              
              // Send the event
              SendEvent(sfEvent);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Handle a key modifier event [Command, Option, Control, Shift] /////////////////////////////////////////////////////////.

Definition at line 327 of file WindowImplCocoa.mm.

{
       NSEvent *event = reinterpret_cast <NSEvent *> (eventRef);
       Event sfEvent;
       unsigned mods = [event modifierFlags];
       
       sfEvent.Type = Event::KeyPressed;
       
       // Get the code
       sfEvent.Key.Code = KeyForVirtualCode([event keyCode]);
       
       // Get the modifiers
       sfEvent.Key.Alt = mods & NSAlternateKeyMask;
       sfEvent.Key.Control = mods & NSControlKeyMask;
       sfEvent.Key.Shift = mods & NSShiftKeyMask;
       
       // Guess whether it's a pressed or released event
       // Note: this does not work fine is both left and right modifiers are pressed
       // I did not find any way to fix this.
       // TODO: fix handling of modifier flags for use of left and right key at the same time
       if (!(mods & NSAlternateKeyMask) &&
              (sfEvent.Key.Code == Key::LAlt || sfEvent.Key.Code == Key::RAlt)) {
              sfEvent.Type = Event::KeyReleased;
       }
       
       if (!(mods & NSControlKeyMask) &&
              (sfEvent.Key.Code == Key::LControl || sfEvent.Key.Code == Key::RControl)) {
              sfEvent.Type = Event::KeyReleased;
       }
       
       if (!(mods & NSShiftKeyMask) &&
              (sfEvent.Key.Code == Key::LShift || sfEvent.Key.Code == Key::RShift)) {
              sfEvent.Type = Event::KeyReleased;
       }
       
       if (!(mods & NSCommandKeyMask) &&
              (sfEvent.Key.Code == Key::LSystem || sfEvent.Key.Code == Key::RSystem)) {
              sfEvent.Type = Event::KeyReleased;
       }
       
       // Send the event
       SendEvent(sfEvent);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sf::priv::WindowImplCocoa::HandleMouseDown ( void *  eventRef)

Handle a mouse down event (NSEvent) /////////////////////////////////////////////////////////.

Definition at line 375 of file WindowImplCocoa.mm.

{
       NSEvent *event = reinterpret_cast <NSEvent *> (eventRef);
       Event sfEvent;
       
       // Get mouse position relative to the window
       NSPoint loc = [myWrapper mouseLocation];
       unsigned mods = [event modifierFlags];
       
       switch ([event type]) {
              case NSLeftMouseDown:
                     sfEvent.Type = Event::MouseButtonPressed;
                     
                     // Guess whether it's a mouse left or mouse right event
                     if (mods & NSControlKeyMask) {
                            sfEvent.MouseButton.Button = Mouse::Right;
                     } else {
                            sfEvent.MouseButton.Button = Mouse::Left;
                     }
                     
                     sfEvent.MouseButton.X = (int) loc.x;
                     sfEvent.MouseButton.Y = (int) loc.y;
                     
                     // Send the event
                     SendEvent(sfEvent);
                     break;
                     
              case NSRightMouseDown:
                     sfEvent.Type = Event::MouseButtonPressed;
                     sfEvent.MouseButton.Button = Mouse::Right;
                     
                     sfEvent.MouseButton.X = (int) loc.x;
                     sfEvent.MouseButton.Y = (int) loc.y;
                     
                     // Send the event
                     SendEvent(sfEvent);
                     break;
                     
              default:
                     break;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sf::priv::WindowImplCocoa::HandleMouseMove ( void *  eventRef)

Handle a mouse move event (NSEvent) /////////////////////////////////////////////////////////.

Definition at line 469 of file WindowImplCocoa.mm.

{
       Event sfEvent;
       NSPoint loc = [myWrapper mouseLocation];
       sfEvent.Type = Event::MouseMoved;
       
       sfEvent.MouseMove.X = (int) loc.x;
       sfEvent.MouseMove.Y = (int) loc.y;
       
       SendEvent(sfEvent);
       
       if ([myWrapper mouseInside] && !myMouseIn) {
              // If mouse IS inside but WAS not inside last time
              sfEvent.Type = Event::MouseEntered;
              myMouseIn = true;
              
              SendEvent(sfEvent);
       } else if (![myWrapper mouseInside] && myMouseIn) {
              // Is mouse WAS not inside but IS now inside
              sfEvent.Type = Event::MouseLeft;
              myMouseIn     = false;
              
              SendEvent(sfEvent);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sf::priv::WindowImplCocoa::HandleMouseUp ( void *  eventRef)

Handle a mouse up event (NSEvent) /////////////////////////////////////////////////////////.

Definition at line 422 of file WindowImplCocoa.mm.

{
       NSEvent *event = reinterpret_cast <NSEvent *> (eventRef);
       Event sfEvent;
       
       // Get mouse position relative to the window
       NSPoint loc = [myWrapper mouseLocation];
       unsigned mods = [event modifierFlags];
       
       switch ([event type]) {
              case NSLeftMouseUp:
                     sfEvent.Type = Event::MouseButtonReleased;
                     
                     // Guess whether it's a mouse left or mouse right event
                     if (mods & NSControlKeyMask) {
                            sfEvent.MouseButton.Button = Mouse::Right;
                     } else {
                            sfEvent.MouseButton.Button = Mouse::Left;
                     }
                     
                     sfEvent.MouseButton.X = (int) loc.x;
                     sfEvent.MouseButton.Y = (int) loc.y;
                     
                     // Send the event
                     SendEvent(sfEvent);
                     break;
                     
              case NSRightMouseUp:
                     sfEvent.Type = Event::MouseButtonReleased;
                     sfEvent.MouseButton.Button = Mouse::Right;
                     
                     sfEvent.MouseButton.X = (int) loc.x;
                     sfEvent.MouseButton.Y = (int) loc.y;
                     
                     // Send the event
                     SendEvent(sfEvent);
                     break;
                     
              default:
                     break;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Handle a mouse wheel event (NSEvent) /////////////////////////////////////////////////////////.

Definition at line 499 of file WindowImplCocoa.mm.

{
       NSEvent *event = reinterpret_cast <NSEvent *> (eventRef);
       
       // SFML uses integer values for delta but Cocoa uses float and it is mostly fewer than 1.0
       // Therefore I chose to add the float value to a 'wheel status' and
       // send a sf event only when it's greater than 1.0
       myWheelStatus += [event deltaY];
       
       if (fabs(myWheelStatus) > 1.0f) {
              // Make the event and send it
              Event sfEvent;
              sfEvent.Type = Event::MouseWheelMoved;
              sfEvent.MouseWheel.Delta = (int) myWheelStatus;
              SendEvent(sfEvent);
              
              // Remove as much integer units as the one that have been put in the event
              // (was a mistake to set this to 0)
              myWheelStatus -= (int) myWheelStatus;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Handle an event sent by the default NSNotificationCenter /////////////////////////////////////////////////////////.

Handle event sent by the default NSNotificationCenter /////////////////////////////////////////////////////////.

Definition at line 196 of file WindowImplCocoa.mm.

{
       // Set myWidth and myHeight to correct value if
       // window size changed
       switch (event.Type) {
              case Event::Resized:
                     myWidth = event.Size.Width;
                     myHeight = event.Size.Height;
                     break;
                     
              default:
                     break;
       }
       
       // And send the event
       SendEvent(event);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sf::priv::WindowImpl::Initialize ( ) [inherited]

Initialize window's states that can't be done at construction.

Initialize window's states that can't be done at construction /////////////////////////////////////////////////////////.

/////////////////////////////////////////////////////////

Reimplemented in sf::priv::WindowImplX11.

Definition at line 125 of file WindowImpl.cpp.

{
    // Initialize the joysticks
    for (unsigned int i = 0; i < Joy::Count; ++i)
    {
        myJoysticks[i].Initialize(i);
        myJoyStates[i] = myJoysticks[i].UpdateState();
    }
}

Here is the call graph for this function:

Check if there's an active context on the current thread.

Check if there's an active context on the current thread /////////////////////////////////////////////////////////.

Returns:
True if there's a context bound to the current thread

/////////////////////////////////////////////////////////

Reimplemented from sf::priv::WindowImpl.

Definition at line 187 of file WindowImplCocoa.mm.

{
       return ([NSOpenGLContext currentContext] != NULL);
}
bool sf::priv::WindowImplCocoa::IsTextEvent ( void *  event) [static]

Return whether 'ev' must be considered as a TextEntered event /////////////////////////////////////////////////////////.

Definition at line 524 of file WindowImplCocoa.mm.

{
       NSEvent *event = (NSEvent *)eventRef;
       bool res = false;
       
       if (event && [event type] == NSKeyDown && [[event characters] length]) {
              unichar code = [[event characters] characterAtIndex:0];
              
              // Codes from 0xF700 to 0xF8FF are non text keys (see NSEvent.h)
              // 0x35 is the Escape key
              if ([event keyCode] != 0x35 && (code < 0xF700 || code > 0xF8FF))
                     res = true;
       }
       
       return res;
}

Here is the caller graph for this function:

WindowImpl * sf::priv::WindowImpl::New ( ) [static, inherited]

Create a new window depending on the current OS.

Create a new window depending on the current OS /////////////////////////////////////////////////////////.

Returns:
Pointer to the created window

/////////////////////////////////////////////////////////

Definition at line 59 of file WindowImpl.cpp.

{
    return new WindowImplType();
}
WindowImpl * sf::priv::WindowImpl::New ( VideoMode  Mode,
const std::string &  Title,
unsigned long  WindowStyle,
WindowSettings Params 
) [static, inherited]

Create a new window depending on the current OS.

Create a new window depending on the current OS /////////////////////////////////////////////////////////.

Parameters:
Mode: Video mode to use
Title: Title of the window
WindowStyle: Window style
Params: Creation parameters
Returns:
Pointer to the created window

/////////////////////////////////////////////////////////

Definition at line 68 of file WindowImpl.cpp.

{
    return new WindowImplType(Mode, Title, WindowStyle, Params);
}
WindowImpl * sf::priv::WindowImpl::New ( WindowHandle  Handle,
WindowSettings Params 
) [static, inherited]

Create a new window depending on to the current OS.

Create a new window depending on the current OS /////////////////////////////////////////////////////////.

Parameters:
Handle: Platform-specific handle of the control
Params: Creation parameters
Returns:
Pointer to the created window

/////////////////////////////////////////////////////////

Definition at line 77 of file WindowImpl.cpp.

{
    return new WindowImplType(Handle, Params);
}
void sf::priv::WindowImplCocoa::ProcessEvents ( ) [private, virtual]

see WindowImpl::ProcessEvents

/see sfWindowImpl::ProcessEvents /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 554 of file WindowImplCocoa.mm.

{
       // Forward event handling call to the application controller
       [[sfPrivAppController sharedController] processEvents];
}

Here is the call graph for this function:

void sf::priv::WindowImpl::RemoveListener ( WindowListener *  Listener) [inherited]

Remove a listener from the window.

Remove a listener from the window /////////////////////////////////////////////////////////.

Parameters:
Listener: Listener to remove

/////////////////////////////////////////////////////////

Definition at line 116 of file WindowImpl.cpp.

{
    myListeners.erase(Listener);
}
void sf::priv::WindowImpl::SendEvent ( const Event EventToSend) [protected, inherited]

Send an event to listeners (for derived classes only)

Send an event to listeners /////////////////////////////////////////////////////////.

Parameters:
EventToSend: Event to send

/////////////////////////////////////////////////////////

Definition at line 189 of file WindowImpl.cpp.

{
    for (std::set<WindowListener*>::iterator i = myListeners.begin(); i != myListeners.end(); ++i)
    {
        (*i)->OnEvent(EventToSend);
    }
}

Here is the caller graph for this function:

void sf::priv::WindowImplCocoa::SetActive ( bool  Active = true) const [private, virtual]

see WindowImpl::MakeActive

/see sfWindowImpl::MakeActive /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 564 of file WindowImplCocoa.mm.

{
       // Forward the call to the window
       if (myWrapper)
              [myWrapper setActive:Active];
       else {
              // Or directly activate the shared OpenGL context if we're not using a window
              if (Active) {
                     if ([NSOpenGLContext currentContext] != [sfPrivGLContext sharedContext])
                            [[sfPrivGLContext sharedContext] makeCurrentContext];
              } else {
                     if ([NSOpenGLContext currentContext] == [sfPrivGLContext sharedContext])
                            [NSOpenGLContext clearCurrentContext];
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sf::priv::WindowImplCocoa::SetCursorPosition ( unsigned int  Left,
unsigned int  Top 
) [private, virtual]

see WindowImpl::SetCursorPosition

/see sfWindowImpl::SetCursorPosition /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 608 of file WindowImplCocoa.mm.

{
       NSPoint pos = NSMakePoint ((float) Left, (float) Top);
       
       if (myWrapper) {
              // Flip for SFML window coordinate system
              pos.y = [[myWrapper window] frame].size.height - pos.y;
              
              // Adjust for view reference instead of window
              pos.y -= [[myWrapper window] frame].size.height - [[myWrapper view] frame].size.height;
              
              // Convert to screen coordinates
              NSPoint absolute = [[myWrapper window] convertBaseToScreen:pos];
              
              // Flip screen coodinates
              absolute.y = [[NSScreen mainScreen] frame].size.height - absolute.y;
              
              // Move cursor
              CGDisplayMoveCursorToPoint([sfPrivAppController primaryScreen],
                                                           CGPointMake(absolute.x, absolute.y));
       }
}
void sf::priv::WindowImplCocoa::SetIcon ( unsigned int  Width,
unsigned int  Height,
const Uint8 *  Pixels 
) [private, virtual]

see WindowImpl::SetIcon

see WindowImpl::SetIcon /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 672 of file WindowImplCocoa.mm.

{
       // Nothing to do
}
void sf::priv::WindowImpl::SetJoystickThreshold ( float  Threshold) [inherited]

Change the joystick threshold, ie. the value below which no move event will be generated.

Change the joystick threshold, ie. the value below which no move event will be generated /////////////////////////////////////////////////////////.

Parameters:
Threshold: New threshold, in range [0, 100]

/////////////////////////////////////////////////////////

Definition at line 158 of file WindowImpl.cpp.

{
    myJoyThreshold = Threshold;
}
void sf::priv::WindowImplCocoa::SetPosition ( int  Left,
int  Top 
) [private, virtual]

see WindowImpl::SetPosition

/see sfWindowImpl::SetPosition /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 635 of file WindowImplCocoa.mm.

{
       [myWrapper setPosition:NSMakePoint(Left, Top)];
}
void sf::priv::WindowImplCocoa::SetSize ( unsigned int  Width,
unsigned int  Height 
) [private, virtual]

/see WindowImpl::SetSize

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 645 of file WindowImplCocoa.mm.

{
       [myWrapper setSize:NSMakeSize(Width, Height)];
}
void sf::priv::WindowImplCocoa::Show ( bool  State) [private, virtual]

see WindowImpl::Show

/see sfWindowImpl::Show /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 654 of file WindowImplCocoa.mm.

{
       [myWrapper show:State];
}
void sf::priv::WindowImplCocoa::ShowMouseCursor ( bool  Show) [private, virtual]

see WindowImpl::ShowMouseCursor

/see sfWindowImpl::ShowMouseCursor /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 595 of file WindowImplCocoa.mm.

{
       if (flag) {
              [NSCursor unhide];
       } else {
              [NSCursor hide];
       }
}
void sf::priv::WindowImplCocoa::UseVerticalSync ( bool  Enabled) [private, virtual]

see WindowImpl::UseVerticalSync

/see sfWindowImpl::UseVerticalSync /////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////

Implements sf::priv::WindowImpl.

Definition at line 585 of file WindowImplCocoa.mm.

{
       // Forward the call to the window
       [myWrapper enableVerticalSync:Enabled];
}

Member Data Documentation

unsigned int sf::priv::WindowImpl::myHeight [protected, inherited]

Internal height of the window.

Definition at line 277 of file WindowImpl.hpp.

Definition at line 197 of file WindowImplCocoa.hpp.

Definition at line 196 of file WindowImplCocoa.hpp.

Definition at line 198 of file WindowImplCocoa.hpp.

unsigned int sf::priv::WindowImpl::myWidth [protected, inherited]

Internal width of the window.

Definition at line 276 of file WindowImpl.hpp.

My own part starts here ! /////////////////////////////////////////////////////////.

Definition at line 195 of file WindowImplCocoa.hpp.


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