From 328f0df87c7c315602ed0a8b39ace1ff8f88eb89 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 25 Mar 2008 21:34:30 +0000 Subject: [PATCH] moving tlw list up, cleanup git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52822 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/dialog.cpp | 4 --- src/mac/carbon/frame.cpp | 4 --- src/mac/carbon/mdi.cpp | 6 ----- src/mac/carbon/nonownedwnd.cpp | 14 ++++------- src/mac/carbon/toplevel.cpp | 1 + src/mac/carbon/window.cpp | 46 +++++++++++++++++++--------------- 6 files changed, 32 insertions(+), 43 deletions(-) diff --git a/src/mac/carbon/dialog.cpp b/src/mac/carbon/dialog.cpp index bb90e3812b..8743e10547 100644 --- a/src/mac/carbon/dialog.cpp +++ b/src/mac/carbon/dialog.cpp @@ -62,15 +62,11 @@ void wxDialog::SetModal( bool flag ) { m_isModalStyle = true; - wxModelessWindows.DeleteObject( this ); - SetWindowModality( (WindowRef)MacGetWindowRef(), kWindowModalityAppModal, NULL ) ; } else { m_isModalStyle = false; - - wxModelessWindows.Append( this ); } } diff --git a/src/mac/carbon/frame.cpp b/src/mac/carbon/frame.cpp index b4da3e565f..d17d5d8147 100644 --- a/src/mac/carbon/frame.cpp +++ b/src/mac/carbon/frame.cpp @@ -26,8 +26,6 @@ #include "wx/mac/uma.h" -extern wxWindowList wxModelessWindows; - BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) EVT_ACTIVATE(wxFrame::OnActivate) // EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) @@ -61,8 +59,6 @@ bool wxFrame::Create(wxWindow *parent, if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) return false; - wxModelessWindows.Append(this); - return true; } diff --git a/src/mac/carbon/mdi.cpp b/src/mac/carbon/mdi.cpp index ff52663afc..6fd6dfae0d 100644 --- a/src/mac/carbon/mdi.cpp +++ b/src/mac/carbon/mdi.cpp @@ -25,8 +25,6 @@ #include "wx/mac/private.h" #include "wx/mac/uma.h" -extern wxWindowList wxModelessWindows; - IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow) @@ -396,8 +394,6 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); - wxModelessWindows.Append(this); - return true; } @@ -500,8 +496,6 @@ bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) if ( !wxWindow::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style) ) return false; - wxModelessWindows.Append(this); - return true; } diff --git a/src/mac/carbon/nonownedwnd.cpp b/src/mac/carbon/nonownedwnd.cpp index c6d9c28841..1a1adedf10 100644 --- a/src/mac/carbon/nonownedwnd.cpp +++ b/src/mac/carbon/nonownedwnd.cpp @@ -42,9 +42,6 @@ // globals // ---------------------------------------------------------------------------- -// list of all frames and modeless dialogs -wxWindowList wxModelessWindows; - static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param); // ============================================================================ @@ -852,8 +849,6 @@ bool wxNonOwnedWindow::Create(wxWindow *parent, if (GetExtraStyle() & wxFRAME_EX_METAL) MacSetMetalAppearance(true); - wxTopLevelWindows.Append(this); - if ( parent ) parent->AddChild(this); @@ -878,9 +873,6 @@ wxNonOwnedWindow::~wxNonOwnedWindow() wxRemoveMacWindowAssociation( this ) ; - if ( wxModelessWindows.Find(this) ) - wxModelessWindows.DeleteObject(this); - // avoid dangling refs if ( s_macDeactivateWindow == this ) s_macDeactivateWindow = NULL; @@ -903,7 +895,7 @@ bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& c ) else if ( col == wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) ) col = wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDialogBackgroundActive)); - if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol ) + if ( !wxWindow::SetBackgroundColour(col) && m_hasBgCol ) return false ; if ( col == wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDocumentWindowBackground)) ) @@ -916,6 +908,10 @@ bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& c ) SetThemeWindowBackground( (WindowRef) m_macWindow, kThemeBrushDialogBackgroundActive, false ) ; SetBackgroundStyle(wxBG_STYLE_CUSTOM); } + else + { + SetBackgroundStyle(wxBG_STYLE_COLOUR); + } return true; } diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index cc75ba34c3..9398f003e1 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -91,6 +91,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent, wxWindow::SetLabel( title ) ; SetWindowTitleWithCFString( (WindowRef) m_macWindow , wxCFStringRef( title , GetFont().GetEncoding() ) ); + wxTopLevelWindows.Append(this); return true; } diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index e4cb57c133..c283e6472f 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -415,28 +415,31 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl { // set back to 0 if problems arise #if 1 - ControlPartCode currentControlPart = cEvent.GetParameter(kEventParamControlPart , typeControlPartCode ); - // synthesize the event focus changed event - EventRef evRef = NULL ; - - OSStatus err = MacCreateEvent( - NULL , kEventClassControl , kEventControlFocusPartChanged , TicksToEventTime( TickCount() ) , - kEventAttributeUserEvent , &evRef ); - verify_noerr( err ); - - wxMacCarbonEvent iEvent( evRef ) ; - iEvent.SetParameter( kEventParamDirectObject , controlRef ); - iEvent.SetParameter( kEventParamPostTarget, typeEventTargetRef, GetControlEventTarget( controlRef ) ); - iEvent.SetParameter( kEventParamControlPreviousPart, typeControlPartCode, previousControlPart ); - iEvent.SetParameter( kEventParamControlCurrentPart, typeControlPartCode, currentControlPart ); - + if ( result == noErr ) + { + ControlPartCode currentControlPart = cEvent.GetParameter(kEventParamControlPart , typeControlPartCode ); + // synthesize the event focus changed event + EventRef evRef = NULL ; + + OSStatus err = MacCreateEvent( + NULL , kEventClassControl , kEventControlFocusPartChanged , TicksToEventTime( TickCount() ) , + kEventAttributeUserEvent , &evRef ); + verify_noerr( err ); + + wxMacCarbonEvent iEvent( evRef ) ; + iEvent.SetParameter( kEventParamDirectObject , controlRef ); + iEvent.SetParameter( kEventParamPostTarget, typeEventTargetRef, GetControlEventTarget( controlRef ) ); + iEvent.SetParameter( kEventParamControlPreviousPart, typeControlPartCode, previousControlPart ); + iEvent.SetParameter( kEventParamControlCurrentPart, typeControlPartCode, currentControlPart ); + #if 1 - // TODO test this first, avoid double posts etc... - PostEventToQueue( GetMainEventQueue(), evRef , kEventPriorityHigh ); + // TODO test this first, avoid double posts etc... + PostEventToQueue( GetMainEventQueue(), evRef , kEventPriorityHigh ); #else - wxMacWindowControlEventHandler( NULL , evRef , data ) ; + wxMacWindowControlEventHandler( NULL , evRef , data ) ; #endif - ReleaseEvent( evRef ) ; + ReleaseEvent( evRef ) ; + } #else // old implementation, to be removed if the new one works if ( controlPart == kControlFocusNoPart ) @@ -1203,10 +1206,13 @@ void wxWindowMac::SetFocus() // as we cannot rely on the control features to find out whether we are in full keyboard mode, // we can only leave in case of an error - wxLogTrace(_T("Focus"), _T("before wxWindow::SetFocus(%p)"), wx_static_cast(void*, this)); + wxLogTrace(_T("Focus"), _T("before wxWindow::SetFocus(%p) %d"), wx_static_cast(void*, this), GetName().c_str()); OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ; if ( err == errCouldntSetFocus ) + { + wxLogTrace(_T("Focus"), _T("in wxWindow::SetFocus(%p) errCouldntSetFocus"), wx_static_cast(void*, this)); return ; + } wxLogTrace(_T("Focus"), _T("after wxWindow::SetFocus(%p)"), wx_static_cast(void*, this)); SetUserFocusWindow( (WindowRef)MacGetTopLevelWindowRef() ); -- 2.45.2