Blender V2.61 - r43446
Public Member Functions | Protected Member Functions | Protected Attributes

GHOST_SystemCocoa Class Reference

#include <GHOST_SystemCocoa.h>

Inheritance diagram for GHOST_SystemCocoa:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 GHOST_SystemCocoa ()
 ~GHOST_SystemCocoa ()
virtual GHOST_TUns64 getMilliSeconds () const
virtual GHOST_TUns8 getNumDisplays () const
virtual void getMainDisplayDimensions (GHOST_TUns32 &width, GHOST_TUns32 &height) const
virtual GHOST_IWindowcreateWindow (const STR_String &title, GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, GHOST_TWindowState state, GHOST_TDrawingContextType type, const bool stereoVisual=false, const GHOST_TUns16 numOfAASamples=0, const GHOST_TEmbedderWindowID parentWindow=0)
virtual bool processEvents (bool waitForEvent)
GHOST_TUns8 handleQuitRequest ()
bool handleOpenDocumentRequest (void *filepathStr)
GHOST_TSuccess handleDraggingEvent (GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_WindowCocoa *window, int mouseX, int mouseY, void *data)
virtual GHOST_TSuccess getCursorPosition (GHOST_TInt32 &x, GHOST_TInt32 &y) const
virtual GHOST_TSuccess setCursorPosition (GHOST_TInt32 x, GHOST_TInt32 y)
virtual GHOST_TSuccess getModifierKeys (GHOST_ModifierKeys &keys) const
virtual GHOST_TSuccess getButtons (GHOST_Buttons &buttons) const
virtual GHOST_TUns8getClipboard (bool selection) const
virtual void putClipboard (GHOST_TInt8 *buffer, bool selection) const
GHOST_TSuccess handleWindowEvent (GHOST_TEventType eventType, GHOST_WindowCocoa *window)
GHOST_TSuccess handleApplicationBecomeActiveEvent ()
void notifyExternalEventProcessed ()
int toggleConsole (int action)

Protected Member Functions

virtual GHOST_TSuccess init ()
GHOST_TSuccess handleTabletEvent (void *eventPtr, short eventType)
GHOST_TSuccess handleMouseEvent (void *eventPtr)
GHOST_TSuccess handleKeyEvent (void *eventPtr)
GHOST_TSuccess setMouseCursorPosition (GHOST_TInt32 x, GHOST_TInt32 y)

Protected Attributes

GHOST_TUns64 m_start_time
bool m_outsideLoopEventProcessed
bool m_needDelayedApplicationBecomeActiveEventProcessing
GHOST_TUns32 m_pressedMouseButtons
GHOST_TUns32 m_modifierMask
bool m_ignoreWindowSizedMessages
GHOST_TInt32 m_cursorDelta_x
GHOST_TInt32 m_cursorDelta_y
bool m_hasMultiTouchTrackpad
bool m_isGestureInProgress

Detailed Description

Definition at line 52 of file GHOST_SystemCocoa.h.


Constructor & Destructor Documentation

GHOST_SystemCocoa::GHOST_SystemCocoa ( )
GHOST_SystemCocoa::~GHOST_SystemCocoa ( )

Destructor.

Definition at line 590 of file GHOST_SystemCocoa.mm.


Member Function Documentation

GHOST_IWindow * GHOST_SystemCocoa::createWindow ( const STR_String title,
GHOST_TInt32  left,
GHOST_TInt32  top,
GHOST_TUns32  width,
GHOST_TUns32  height,
GHOST_TWindowState  state,
GHOST_TDrawingContextType  type,
const bool  stereoVisual = false,
const GHOST_TUns16  numOfAASamples = 0,
const GHOST_TEmbedderWindowID  parentWindow = 0 
) [virtual]

Create a new window. The new window is added to the list of windows managed. Never explicitly delete the window, use disposeWindow() instead.

Parameters:
titleThe name of the window (displayed in the title bar of the window if the OS supports it).
leftThe coordinate of the left edge of the window.
topThe coordinate of the top edge of the window.
widthThe width the window.
heightThe height the window.
stateThe state of the window when opened.
typeThe type of drawing context installed in this window.
stereoVisualStereo visual for quad buffered stereo.
numOfAASamplesNumber of samples used for AA (zero if no AA)
parentWindowParent (embedder) window
Returns:
The new window (or 0 if creation failed).

Implements GHOST_ISystem.

Definition at line 729 of file GHOST_SystemCocoa.mm.

References GHOST_WindowManager::addWindow(), getMilliSeconds(), GHOST_IWindow::getValid(), GHOST_ASSERT, GHOST_kEventWindowActivate, GHOST_kEventWindowSize, GHOST_PRINT, GHOST_System::m_windowManager, GHOST_System::pushEvent(), and GHOST_WindowManager::setActiveWindow().

GHOST_TSuccess GHOST_SystemCocoa::getButtons ( GHOST_Buttons buttons) const [virtual]

Returns the state of the mouse buttons (ouside the message queue).

Parameters:
buttonsThe state of the buttons.
Returns:
Indication of success.

Implements GHOST_System.

Definition at line 850 of file GHOST_SystemCocoa.mm.

References GHOST_Buttons::clear(), GHOST_kButtonMaskButton4, GHOST_kButtonMaskButton5, GHOST_kButtonMaskLeft, GHOST_kButtonMaskMiddle, GHOST_kButtonMaskRight, GHOST_kSuccess, m_pressedMouseButtons, and GHOST_Buttons::set().

GHOST_TUns8 * GHOST_SystemCocoa::getClipboard ( bool  selection) const [virtual]

Returns Clipboard data

Parameters:
selectionIndicate which buffer to return
Returns:
Returns the selected buffer

Implements GHOST_System.

Definition at line 1737 of file GHOST_SystemCocoa.mm.

References NULL.

GHOST_TSuccess GHOST_SystemCocoa::getCursorPosition ( GHOST_TInt32 x,
GHOST_TInt32 y 
) const [virtual]

Returns the current location of the cursor (location in screen coordinates)

Parameters:
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
Returns:
Indication of success.
Note:
: returns coordinates in Cocoa screen coordinates

Implements GHOST_ISystem.

Definition at line 785 of file GHOST_SystemCocoa.mm.

References GHOST_kSuccess.

void GHOST_SystemCocoa::getMainDisplayDimensions ( GHOST_TUns32 width,
GHOST_TUns32 height 
) const [virtual]

Returns the dimensions of the main display on this system.

Returns:
The dimension of the main display.

Implements GHOST_ISystem.

Definition at line 712 of file GHOST_SystemCocoa.mm.

GHOST_TUns64 GHOST_SystemCocoa::getMilliSeconds ( ) const [virtual]

Returns the system time. Returns the number of milliseconds since the start of the system process. Based on ANSI clock() routine.

Returns:
The number of milliseconds.

Reimplemented from GHOST_System.

Definition at line 686 of file GHOST_SystemCocoa.mm.

References m_start_time, and NULL.

Referenced by createWindow(), handleApplicationBecomeActiveEvent(), handleDraggingEvent(), handleOpenDocumentRequest(), handleQuitRequest(), handleWindowEvent(), and setCursorPosition().

GHOST_TSuccess GHOST_SystemCocoa::getModifierKeys ( GHOST_ModifierKeys keys) const [virtual]

Returns the state of all modifier keys.

Parameters:
keysThe state of all modifier keys (true == pressed).
Returns:
Indication of success.

Implements GHOST_System.

Definition at line 840 of file GHOST_SystemCocoa.mm.

References GHOST_kModifierKeyLeftAlt, GHOST_kModifierKeyLeftControl, GHOST_kModifierKeyLeftShift, GHOST_kModifierKeyOS, GHOST_kSuccess, m_modifierMask, and GHOST_ModifierKeys::set().

GHOST_TUns8 GHOST_SystemCocoa::getNumDisplays ( ) const [virtual]

Returns the number of displays on this system.

Returns:
The number of displays.

Implements GHOST_ISystem.

Definition at line 699 of file GHOST_SystemCocoa.mm.

GHOST_TSuccess GHOST_SystemCocoa::handleApplicationBecomeActiveEvent ( )
GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent ( GHOST_TEventType  eventType,
GHOST_TDragnDropTypes  draggedObjectType,
GHOST_WindowCocoa *  window,
int  mouseX,
int  mouseY,
void *  data 
)

Handles a drag'n'drop destination event. Called by GHOST_WindowCocoa window subclass

Parameters:
eventTypeThe type of drag'n'drop event
draggedObjectTypeThe type object concerned (currently array of file names, string, TIFF image)
mouseXx mouse coordinate (in cocoa base window coordinates)
mouseYy mouse coordinate
windowThe window on which the event occurred
Returns:
Indication whether the event was handled.

Definition at line 1069 of file GHOST_SystemCocoa.mm.

References GHOST_TStringArray::count, getMilliSeconds(), GHOST_kDragnDropTypeBitmap, GHOST_kDragnDropTypeFilenames, GHOST_kDragnDropTypeString, GHOST_kEventDraggingDropDone, GHOST_kEventDraggingEntered, GHOST_kEventDraggingExited, GHOST_kEventDraggingUpdated, GHOST_kFailure, GHOST_kSuccess, i, IB_rect, IMB_allocImBuf(), m_outsideLoopEventProcessed, NULL, GHOST_System::pushEvent(), ImBuf::rect, GHOST_TStringArray::strings, and GHOST_System::validWindow().

GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent ( void *  eventPtr) [protected]

Handles a key event.

Parameters:
eventPtrAn NSEvent pointer (casted to void* to enable compilation in standard C++)
Returns:
Indication whether the event was handled.

Definition at line 1642 of file GHOST_SystemCocoa.mm.

References convertKey(), GHOST_WindowManager::getWindowAssociatedWithOSWindow(), GHOST_kEventKeyDown, GHOST_kEventKeyUp, GHOST_kFailure, GHOST_kKeyLeftAlt, GHOST_kKeyLeftControl, GHOST_kKeyLeftShift, GHOST_kKeyOS, GHOST_kKeyQ, GHOST_kSuccess, length(), m_modifierMask, GHOST_System::m_windowManager, and GHOST_System::pushEvent().

Referenced by processEvents().

GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent ( void *  eventPtr) [protected]
bool GHOST_SystemCocoa::handleOpenDocumentRequest ( void *  filepathStr)
GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest ( )
GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent ( void *  eventPtr,
short  eventType 
) [protected]

Handles a tablet event.

Parameters:
eventPtrAn NSEvent pointer (casted to void* to enable compilation in standard C++)
eventTypeThe type of the event. It needs to be passed separately as it can be either directly in the event type, or as a subtype if combined with a mouse button event.
Returns:
Indication whether the event was handled.

Definition at line 1370 of file GHOST_SystemCocoa.mm.

References GHOST_TabletData::Active, FALSE, GHOST_WindowManager::getWindowAssociatedWithOSWindow(), GHOST_ASSERT, GHOST_kFailure, GHOST_kSuccess, GHOST_kTabletModeEraser, GHOST_kTabletModeNone, GHOST_kTabletModeStylus, GHOST_System::m_windowManager, GHOST_TabletData::Pressure, GHOST_TabletData::Xtilt, and GHOST_TabletData::Ytilt.

Referenced by handleMouseEvent(), and processEvents().

GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent ( GHOST_TEventType  eventType,
GHOST_WindowCocoa *  window 
)
GHOST_TSuccess GHOST_SystemCocoa::init ( ) [protected, virtual]

Initializes the system. For now, it justs registers the window class (WNDCLASS).

Returns:
A success value.

Reimplemented from GHOST_System.

Definition at line 595 of file GHOST_SystemCocoa.mm.

References CocoaAppDelegate::setSystemCocoa:.

void GHOST_SystemCocoa::notifyExternalEventProcessed ( )

External objects should call this when they send an event outside processEvents.

Definition at line 1017 of file GHOST_SystemCocoa.mm.

References m_outsideLoopEventProcessed.

bool GHOST_SystemCocoa::processEvents ( bool  waitForEvent) [virtual]

Gets events from the system and stores them in the queue.

Parameters:
waitForEventFlag to wait for an event (or return immediately).
Returns:
Indication of the presence of events.

The event queue polling function

Implements GHOST_ISystem.

Definition at line 868 of file GHOST_SystemCocoa.mm.

References handleApplicationBecomeActiveEvent(), handleKeyEvent(), handleMouseEvent(), handleTabletEvent(), m_ignoreWindowSizedMessages, m_needDelayedApplicationBecomeActiveEventProcessing, m_outsideLoopEventProcessed, NSEventTypeBeginGesture, NSEventTypeEndGesture, NSEventTypeMagnify, and NSEventTypeRotate.

void GHOST_SystemCocoa::putClipboard ( GHOST_TInt8 buffer,
bool  selection 
) const [virtual]

Puts buffer to system clipboard

Parameters:
bufferThe buffer to be copied
selectionIndicates which buffer to copy too, only used on X11

Implements GHOST_System.

Definition at line 1791 of file GHOST_SystemCocoa.mm.

GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition ( GHOST_TInt32  x,
GHOST_TInt32  y 
) [virtual]

Updates the location of the cursor (location in screen coordinates).

Parameters:
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
Returns:
Indication of success.
Note:
: expect Cocoa screen coordinates

Implements GHOST_ISystem.

Definition at line 798 of file GHOST_SystemCocoa.mm.

References GHOST_WindowManager::getActiveWindow(), getMilliSeconds(), GHOST_kEventCursorMove, GHOST_kFailure, GHOST_kSuccess, m_outsideLoopEventProcessed, GHOST_System::m_windowManager, GHOST_System::pushEvent(), and setMouseCursorPosition().

GHOST_TSuccess GHOST_SystemCocoa::setMouseCursorPosition ( GHOST_TInt32  x,
GHOST_TInt32  y 
) [protected]

Performs the actual cursor position update (location in screen coordinates).

Parameters:
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
Returns:
Indication of success.

Definition at line 816 of file GHOST_SystemCocoa.mm.

References GHOST_WindowManager::getActiveWindow(), GHOST_kFailure, GHOST_kSuccess, and GHOST_System::m_windowManager.

Referenced by handleMouseEvent(), and setCursorPosition().

int GHOST_SystemCocoa::toggleConsole ( int  action) [inline, virtual]
See also:
GHOST_ISystem

Implements GHOST_ISystem.

Definition at line 230 of file GHOST_SystemCocoa.h.


Member Data Documentation

Stores the mouse cursor delta due to setting a new cursor position Needed because cocoa event delta cursor move takes setCursorPosition changes too.

Definition at line 294 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), and handleMouseEvent().

Definition at line 294 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), and handleMouseEvent().

Multitouch trackpad availability

Definition at line 297 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), and handleMouseEvent().

Ignores window size messages (when window is dragged).

Definition at line 289 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), handleWindowEvent(), and processEvents().

Multitouch gesture in progress, useful to distinguish trackpad from mouse scroll events

Definition at line 300 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), and handleMouseEvent().

State of the modifiers.

Definition at line 286 of file GHOST_SystemCocoa.h.

Referenced by getModifierKeys(), GHOST_SystemCocoa(), handleApplicationBecomeActiveEvent(), and handleKeyEvent().

Raised window is not yet known by the window manager, so delay application become active event handling

Definition at line 280 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), handleApplicationBecomeActiveEvent(), and processEvents().

Event has been processed directly by Cocoa (or NDOF manager) and has sent a ghost event to be dispatched

Definition at line 277 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), handleApplicationBecomeActiveEvent(), handleDraggingEvent(), handleQuitRequest(), handleWindowEvent(), notifyExternalEventProcessed(), processEvents(), and setCursorPosition().

Mouse buttons state

Definition at line 283 of file GHOST_SystemCocoa.h.

Referenced by getButtons(), and GHOST_SystemCocoa().

Start time at initialization.

Definition at line 274 of file GHOST_SystemCocoa.h.

Referenced by getMilliSeconds(), and GHOST_SystemCocoa().


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