// constants
// ----------------------------------------------------------------------------
+// unified title and toolbar constant - not in Tiger headers, so we duplicate it here
+#define kWindowUnifiedTitleAndToolbarAttribute (1 << 7)
+
// trace mask for activation tracing messages
static const wxChar *TRACE_ACTIVATE = _T("activation");
wxWindow* g_MacLastWindow = NULL ;
EventMouseButton g_lastButton = 0 ;
+bool g_lastButtonWasFakeRight = false ;
void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent )
{
wxevent.m_metaDown = modifiers & cmdKey;
wxevent.SetTimestamp( cEvent.GetTicks() ) ;
- // a control click is interpreted as a right click
+ // a control click is interpreted as a right click
+ bool thisButtonIsFakeRight = false ;
if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) )
+ {
button = kEventMouseButtonSecondary ;
-
+ thisButtonIsFakeRight = true ;
+ }
// otherwise we report double clicks by connecting a left click with a ctrl-left click
if ( clickCount > 1 && button != g_lastButton )
clickCount = 1 ;
// mouse down, moved and mouse up, and does not deliver a right down and left up
if ( cEvent.GetKind() == kEventMouseDown )
+ {
g_lastButton = button ;
+ g_lastButtonWasFakeRight = thisButtonIsFakeRight ;
+ }
if ( button == 0 )
+ {
g_lastButton = 0 ;
- else if ( g_lastButton )
+ g_lastButtonWasFakeRight = false ;
+ }
+ else if ( g_lastButton == kEventMouseButtonSecondary && g_lastButtonWasFakeRight )
button = g_lastButton ;
// determine the correct down state, wx does not want a 'down' for a mouseUp event,
{
wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ;
- // EventMouseWheelAxis axis = cEvent.GetParameter<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ;
+ EventMouseWheelAxis axis = cEvent.GetParameter<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ;
SInt32 delta = cEvent.GetParameter<SInt32>(kEventParamMouseWheelDelta, typeSInt32) ;
wxevent.m_wheelRotation = delta;
wxevent.m_wheelDelta = 1;
wxevent.m_linesPerAction = 1;
+ if ( axis == kEventMouseWheelAxisX )
+ wxevent.m_wheelAxis = 1;
}
break ;
if ( wxevent.GetEventType() == wxEVT_LEFT_DOWN )
{
// ... that is set focus to this window
- if (currentMouseWindow->AcceptsFocus() && wxWindow::FindFocus()!=currentMouseWindow)
+ if (currentMouseWindow->CanAcceptFocus() && wxWindow::FindFocus()!=currentMouseWindow)
currentMouseWindow->SetFocus();
}
m_windowId = id == -1 ? NewControlId() : id;
wxWindow::SetLabel( title ) ;
- MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
+ MacCreateRealWindow( title, pos , size , style , name ) ;
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
delete data ;
m_macFullScreenData = NULL ;
+
+ // avoid dangling refs
+ if ( s_macDeactivateWindow == this )
+ s_macDeactivateWindow = NULL;
}
return wxPoint(0, 0) ;
}
-void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
-{
- // this sets m_icon
- wxTopLevelWindowBase::SetIcon(icon);
-}
-
void wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
{
wxTopLevelWindowBase::MacSetBackgroundBrush( brush ) ;
wclass = kPlainWindowClass ;
}
}
+ else if ( HasFlag( wxPOPUP_WINDOW ) )
+ {
+ // TEMPORARY HACK!
+ // Until we've got a real wxPopupWindow class on wxMac make it a
+ // little easier for wxFrame to be used to emulate it and workaround
+ // the lack of wxPopupWindow.
+ if ( HasFlag( wxBORDER_NONE ) )
+ wclass = kHelpWindowClass ; // has no border
+ else
+ wclass = kPlainWindowClass ; // has a single line border, it will have to do for now
+ //attr |= kWindowNoShadowAttribute; // turn off the shadow Should we??
+ group = GetWindowGroupOfClass( // float above other windows
+ kFloatingWindowClass) ;
+ }
else if ( HasFlag( wxCAPTION ) )
{
wclass = kDocumentWindowClass ;
if ( HasFlag(wxSTAY_ON_TOP) )
group = GetWindowGroupOfClass(kUtilityWindowClass) ;
+ if ( HasFlag( wxFRAME_FLOAT_ON_PARENT ) )
+ group = GetWindowGroupOfClass(kFloatingWindowClass) ;
+
attr |= kWindowCompositingAttribute;
#if 0 // wxMAC_USE_CORE_GRAPHICS ; TODO : decide on overall handling of high dpi screens (pixel vs userscale)
attr |= kWindowFrameworkScaledAttribute;
}
#endif
+#if TARGET_API_MAC_OSX
+ if ( m_macWindow != NULL )
+ {
+ MacSetUnifiedAppearance( true ) ;
+ }
+#endif
+
// the frame window event handler
InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
MacInstallTopLevelWindowEventHandler() ;
if ( m_macWindow != NULL )
{
bool metal = GetExtraStyle() & wxFRAME_EX_METAL ;
+
if ( MacGetMetalAppearance() != metal )
+ {
+ if ( MacGetUnifiedAppearance() )
+ MacSetUnifiedAppearance( !metal ) ;
+
MacSetMetalAppearance( metal ) ;
+ }
}
#endif
}
void wxTopLevelWindowMac::MacSetMetalAppearance( bool set )
{
#if TARGET_API_MAC_OSX
+ if ( MacGetUnifiedAppearance() )
+ MacSetUnifiedAppearance( false ) ;
+
MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
set ? kWindowNoAttributes : kWindowMetalAttribute ) ;
#endif
#if TARGET_API_MAC_OSX
return MacGetWindowAttributes() & kWindowMetalAttribute ;
#else
- return false ;
+ return false;
+#endif
+}
+
+void wxTopLevelWindowMac::MacSetUnifiedAppearance( bool set )
+{
+#if TARGET_API_MAC_OSX
+ if ( UMAGetSystemVersion() >= 0x1040 )
+ {
+ if ( MacGetMetalAppearance() )
+ MacSetMetalAppearance( false ) ;
+
+ MacChangeWindowAttributes( set ? kWindowUnifiedTitleAndToolbarAttribute : kWindowNoAttributes ,
+ 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
+ // for wx.
+ // TODO: Determine if we need this on Leopard as well. (should be harmless either way,
+ // though)
+ SetBackgroundColour( wxSYS_COLOUR_WINDOW ) ;
+ }
+#endif
+}
+
+bool wxTopLevelWindowMac::MacGetUnifiedAppearance() const
+{
+#if TARGET_API_MAC_OSX
+ if ( UMAGetSystemVersion() >= 0x1040 )
+ return MacGetWindowAttributes() & kWindowUnifiedTitleAndToolbarAttribute ;
+ else
#endif
+ return false;
}
void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear )