// Purpose: implementation of wxNonOwnedWindow
// Author: Stefan Csomor
// Created: 2008-03-24
-// RCS-ID: $Id: nonownedwnd.cpp 50329 2007-11-29 17:00:58Z VS $
+// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor 2008
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
set ? kWindowNoAttributes : kWindowUnifiedTitleAndToolbarAttribute) ;
// For some reason, Tiger uses white as the background color for this appearance,
- // while most apps using it use the typical striped background. Restore that behavior
+ // while most apps using it use the typical striped background. Restore that behaviour
// for wx.
// TODO: Determine if we need this on Leopard as well. (should be harmless either way,
// though)
// since when creating the peering is not yet completely set-up we call both setters
- // explicitely
+ // explicitly
m_wxPeer->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) ) ;
SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) ) ;
}
static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param);
+WXDLLEXPORT void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent );
// ---------------------------------------------------------------------------
// Carbon Events
UInt32 keyCode ;
UInt32 modifiers ;
- Point point ;
UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
#if wxUSE_UNICODE
GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
charBuf[ numChars - 1 ] = 0;
-#if SIZEOF_WCHAR_T == 2
- uniChar = charBuf[0] ;
-#else
wxMBConvUTF16 converter ;
converter.MB2WC( uniChar , (const char*)charBuf , 2 ) ;
-#endif
if ( numChars * 2 > 4 )
delete[] charBuf ;
}
-#endif
+#endif // wxUSE_UNICODE
GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode );
GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
- GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &point );
UInt32 message = (keyCode << 8) + charCode;
switch ( GetEventKind( event ) )
WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
wxTheApp->MacSetCurrentEvent( event , handler ) ;
if ( /* focus && */ wxTheApp->MacSendKeyDownEvent(
- focus , message , modifiers , when , point.h , point.v , uniChar[0] ) )
+ focus , message , modifiers , when , uniChar[0] ) )
{
result = noErr ;
}
case kEventRawKeyUp :
if ( /* focus && */ wxTheApp->MacSendKeyUpEvent(
- focus , message , modifiers , when , point.h , point.v , uniChar[0] ) )
+ focus , message , modifiers , when , uniChar[0] ) )
{
result = noErr ;
}
wxKeyEvent event(wxEVT_KEY_DOWN);
event.m_shiftDown = modifiers & shiftKey;
- event.m_controlDown = modifiers & controlKey;
+ event.m_rawControlDown = modifiers & controlKey;
event.m_altDown = modifiers & optionKey;
- event.m_metaDown = modifiers & cmdKey;
- event.m_x = point.h;
- event.m_y = point.v;
+ event.m_controlDown = event.m_metaDown = modifiers & cmdKey;
#if wxUSE_UNICODE
event.m_uniChar = uniChar[0] ;
if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & controlKey )
{
- event.m_keyCode = WXK_CONTROL ;
+ event.m_keyCode = WXK_RAW_CONTROL ;
event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
focus->HandleWindowEvent( event ) ;
}
}
if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & cmdKey )
{
- event.m_keyCode = WXK_COMMAND ;
+ event.m_keyCode = WXK_CONTROL;
event.SetEventType( ( modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
focus->HandleWindowEvent( event ) ;
}
EventMouseButton g_lastButton = 0 ;
bool g_lastButtonWasFakeRight = false ;
-void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent )
+WXDLLEXPORT void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent )
{
UInt32 modifiers = cEvent.GetParameter<UInt32>(kEventParamKeyModifiers, typeUInt32) ;
Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
wxevent.m_x = screenMouseLocation.h;
wxevent.m_y = screenMouseLocation.v;
wxevent.m_shiftDown = modifiers & shiftKey;
- wxevent.m_controlDown = modifiers & controlKey;
+ wxevent.m_rawControlDown = modifiers & controlKey;
wxevent.m_altDown = modifiers & optionKey;
- wxevent.m_metaDown = modifiers & cmdKey;
+ wxevent.m_controlDown = wxevent.m_metaDown = modifiers & cmdKey;
wxevent.m_clickCount = clickCount;
wxevent.SetTimestamp( cEvent.GetTicks() ) ;
wxevent.m_wheelDelta = 1;
wxevent.m_linesPerAction = 1;
if ( axis == kEventMouseWheelAxisX )
- wxevent.m_wheelAxis = 1;
+ wxevent.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL;
}
break ;
if ( currentMouseWindow->HandleWindowEvent(wxevent) )
{
- if ((currentMouseWindowParent != NULL) &&
- (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
+ if ( currentMouseWindowParent &&
+ !currentMouseWindowParent->GetChildren().Member(currentMouseWindow) )
currentMouseWindow = NULL;
result = noErr;
// mix this in from window.cpp
pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
-pascal OSStatus wxNonOwnedEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
+static pascal OSStatus wxNonOwnedEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
OSStatus result = eventNotHandledErr ;
}
}
-void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
+static void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
{
InstallWindowEventHandler(window, GetwxNonOwnedEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, ref, handler );
}
void wxNonOwnedWindowCarbonImpl::Create(
- wxWindow* parent,
+ wxWindow* WXUNUSED(parent),
WXWindow nativeWindow )
{
m_macWindow = nativeWindow;
long style, long extraStyle,
const wxString& WXUNUSED(name) )
{
-
+
OSStatus err = noErr ;
Rect theBoundsRect;
-
+
int x = (int)pos.x;
int y = (int)pos.y;
-
+
int w = size.x;
int h = size.y;
-
+
::SetRect(&theBoundsRect, x, y , x + w, y + h);
-
+
// translate the window attributes in the appropriate window class and attributes
WindowClass wclass = 0;
WindowAttributes attr = kWindowNoAttributes ;
WindowGroupRef group = NULL ;
bool activationScopeSet = false;
WindowActivationScope activationScope = kWindowActivationScopeNone;
-
+
if ( style & wxFRAME_TOOL_WINDOW )
{
if (
( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
( style & wxSYSTEM_MENU ) || ( style & wxCAPTION ) ||
- ( style &wxTINY_CAPTION_HORIZ) || ( style &wxTINY_CAPTION_VERT)
+ ( style & wxTINY_CAPTION)
)
{
if ( ( style & wxSTAY_ON_TOP ) )
wclass = kUtilityWindowClass;
else
wclass = kFloatingWindowClass ;
-
- if ( ( style &wxTINY_CAPTION_VERT) )
+
+ if ( ( style & wxTINY_CAPTION) )
attr |= kWindowSideTitlebarAttribute ;
}
else
wclass = kPlainWindowClass ;
}
}
-
+
if ( wclass != kPlainWindowClass )
{
if ( ( style & wxMINIMIZE_BOX ) )
attr |= kWindowCollapseBoxAttribute ;
-
+
if ( ( style & wxMAXIMIZE_BOX ) )
attr |= kWindowFullZoomAttribute ;
-
+
if ( ( style & wxRESIZE_BORDER ) )
attr |= kWindowResizableAttribute ;
-
+
if ( ( style & wxCLOSE_BOX) )
attr |= kWindowCloseBoxAttribute ;
}
attr |= kWindowLiveResizeAttribute;
-
+
if ( ( style &wxSTAY_ON_TOP) )
group = GetWindowGroupOfClass(kUtilityWindowClass) ;
-
+
if ( ( style & wxFRAME_FLOAT_ON_PARENT ) )
group = GetWindowGroupOfClass(kFloatingWindowClass) ;
-
+
if ( group == NULL && parent != NULL )
{
WindowRef parenttlw = (WindowRef) parent->MacGetTopLevelWindowRef();
if( parenttlw )
group = GetWindowGroupParent( GetWindowGroup( parenttlw ) );
}
-
+
attr |= kWindowCompositingAttribute;
#if 0 // TODO : decide on overall handling of high dpi screens (pixel vs userscale)
attr |= kWindowFrameworkScaledAttribute;
#endif
-
+
if ( ( style &wxFRAME_SHAPED) )
{
WindowDefSpec customWindowDefSpec;
{
err = ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ;
}
-
+
if ( err == noErr && m_macWindow != NULL && group != NULL )
SetWindowGroup( (WindowRef) m_macWindow , group ) ;
-
+
wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") );
-
+
// setup a separate group for each window, so that overlays can be handled easily
-
+
WindowGroupRef overlaygroup = NULL;
verify_noerr( CreateWindowGroup( kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse, &overlaygroup ));
verify_noerr( SetWindowGroupParent( overlaygroup, GetWindowGroup( (WindowRef) m_macWindow )));
verify_noerr( SetWindowGroup( (WindowRef) m_macWindow , overlaygroup ));
-
+
if ( activationScopeSet )
{
verify_noerr( SetWindowActivationScope( (WindowRef) m_macWindow , activationScope ));
}
-
+
// the create commands are only for content rect,
// so we have to set the size again as structure bounds
SetWindowBounds( m_macWindow , kWindowStructureRgn , &theBoundsRect ) ;
-
+
// Causes the inner part of the window not to be metal
// if the style is used before window creation.
#if 0 // TARGET_API_MAC_OSX
MacSetMetalAppearance( true ) ;
}
#endif
-
+
if ( m_macWindow != NULL )
{
MacSetUnifiedAppearance( true ) ;
}
-
+
HIViewRef growBoxRef = 0 ;
err = HIViewFindByID( HIViewGetRoot( m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef );
if ( err == noErr && growBoxRef != 0 )
HIGrowBoxViewSetTransparent( growBoxRef, true ) ;
-
+
// the frame window event handler
InstallStandardEventHandler( GetWindowEventTarget(m_macWindow) ) ;
MacInstallTopLevelWindowEventHandler() ;
-
+
if ( extraStyle & wxFRAME_EX_METAL)
MacSetMetalAppearance(true);
-
+
if ( ( style &wxFRAME_SHAPED) )
{
// default shape matches the window size