diff --git a/checkin_notes b/checkin_notes index 83dd3d3b77..f1263adfa8 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5008,3 +5008,17 @@ David 9 Jul 2010 client_state.cpp,h work_fetch.cpp pers_file_xfer.h + Charlie 9 Jul 2010 + - MGR: Fix accessibility code bug in Attach Wizard's ProjectListCtrl, + consolidate and clean up Mac accessibility code. + +Charlie 10 Jul 2010 + - MGR: More code cleanup, optimization and bug fixes. + + clientgui/ + BOINCListCtrl.h + DlgEventLogListCtrl.h + NoticeListCtrl.cpp, .h + ProjectListCtrl.cpp, .h + mac/ + MacAccessiblity.cpp, .h diff --git a/clientgui/BOINCListCtrl.h b/clientgui/BOINCListCtrl.h index ba9d8bd4d6..68f543c3c9 100644 --- a/clientgui/BOINCListCtrl.h +++ b/clientgui/BOINCListCtrl.h @@ -104,7 +104,7 @@ private: void SetupMacAccessibilitySupport(); void RemoveMacAccessibilitySupport(); - struct ListAccessData accessibilityHandlerData; + ListAccessData accessibilityHandlerData; EventHandlerRef m_pHeaderAccessibilityEventHandlerRef; EventHandlerRef m_pBodyAccessibilityEventHandlerRef; diff --git a/clientgui/DlgEventLogListCtrl.h b/clientgui/DlgEventLogListCtrl.h index aaa2e4c968..25fa4d40d1 100644 --- a/clientgui/DlgEventLogListCtrl.h +++ b/clientgui/DlgEventLogListCtrl.h @@ -61,7 +61,7 @@ private: void SetupMacAccessibilitySupport(); void RemoveMacAccessibilitySupport(); - struct ListAccessData accessibilityHandlerData; + ListAccessData accessibilityHandlerData; EventHandlerRef m_pHeaderAccessibilityEventHandlerRef; EventHandlerRef m_pBodyAccessibilityEventHandlerRef; diff --git a/clientgui/NoticeListCtrl.cpp b/clientgui/NoticeListCtrl.cpp index 272fb01540..3d215e8dc6 100644 --- a/clientgui/NoticeListCtrl.cpp +++ b/clientgui/NoticeListCtrl.cpp @@ -32,8 +32,6 @@ #ifdef __WXMAC__ -IMPLEMENT_CLASS( CNoticeListCtrlAccessible, wxObject ) - CNoticeListCtrlAccessible::CNoticeListCtrlAccessible(wxWindow* win) { mp_win = win; SetupMacAccessibilitySupport(); @@ -464,7 +462,7 @@ bool CNoticeListCtrl::Create( wxWindow* parent ) SetAccessible(new CNoticeListCtrlAccessible(this)); #endif #ifdef __WXMAC__ - m_accessible = new CNoticeListCtrlAccessible(this); + m_accessible = NULL; #endif ////@end CNoticeListCtrl creation @@ -595,5 +593,11 @@ bool CNoticeListCtrl::UpdateUI() SetItemCount(pDoc->GetNoticeCount()); pDoc->notices.complete = false; } +#ifdef __WXMAC__ + if (m_accessible == NULL) { + m_accessible = new CNoticeListCtrlAccessible(this); + } +#endif + return true; } diff --git a/clientgui/NoticeListCtrl.h b/clientgui/NoticeListCtrl.h index bb57920ef3..e095c69b74 100644 --- a/clientgui/NoticeListCtrl.h +++ b/clientgui/NoticeListCtrl.h @@ -46,8 +46,6 @@ public: #ifndef __WXMAC__ CNoticeListCtrlAccessible(wxWindow* win): wxWindowAccessible(win) {} #else - DECLARE_CLASS( CNoticeListCtrlAccessible ) - CNoticeListCtrlAccessible(wxWindow* win); virtual ~CNoticeListCtrlAccessible(); #endif diff --git a/clientgui/ProjectListCtrl.cpp b/clientgui/ProjectListCtrl.cpp index 1706d98374..b2cbd9ae2d 100644 --- a/clientgui/ProjectListCtrl.cpp +++ b/clientgui/ProjectListCtrl.cpp @@ -36,8 +36,6 @@ #ifdef __WXMAC__ -IMPLEMENT_CLASS( CProjectListCtrlAccessible, wxObject ) - CProjectListCtrlAccessible::CProjectListCtrlAccessible(wxWindow* win) { mp_win = win; SetupMacAccessibilitySupport(); diff --git a/clientgui/ProjectListCtrl.h b/clientgui/ProjectListCtrl.h index 36e902c479..e6a5fcd41a 100644 --- a/clientgui/ProjectListCtrl.h +++ b/clientgui/ProjectListCtrl.h @@ -94,8 +94,6 @@ class CProjectListCtrlAccessible: public wxWindowAccessible public: #ifdef __WXMAC__ - DECLARE_CLASS( CProjectListCtrlAccessible ) - CProjectListCtrlAccessible(wxWindow* win); virtual ~CProjectListCtrlAccessible(); #else diff --git a/clientgui/mac/MacAccessiblity.cpp b/clientgui/mac/MacAccessiblity.cpp index 0a2ddbdf99..fca045f484 100755 --- a/clientgui/mac/MacAccessiblity.cpp +++ b/clientgui/mac/MacAccessiblity.cpp @@ -184,7 +184,14 @@ void CDlgEventLogListCtrl::RemoveMacAccessibilitySupport() { } +typedef struct { + CProjectListCtrlAccessible* pProjectListCtrlAccessible; + CNoticeListCtrlAccessible* pNoticeListCtrlAccessible; +} HTMLListAccessibilityHandlerData; + + void CProjectListCtrlAccessible::SetupMacAccessibilitySupport() { + static HTMLListAccessibilityHandlerData userData; OSErr err; CProjectListCtrl* pCtrl = wxDynamicCast(mp_win, CProjectListCtrl); @@ -194,10 +201,12 @@ void CProjectListCtrlAccessible::SetupMacAccessibilitySupport() { { m_listView = (HIViewRef)pCtrl->GetHandle(); err = HIViewSetEnabled(m_listView, true); + userData.pProjectListCtrlAccessible = this; + userData.pNoticeListCtrlAccessible = NULL; err = InstallHIObjectEventHandler((HIObjectRef)m_listView, NewEventHandlerUPP(HTMLListAccessibilityEventHandler), sizeof(myAccessibilityEvents) / sizeof(EventTypeSpec), myAccessibilityEvents, - this, &m_plistAccessibilityEventHandlerRef); + &userData, &m_plistAccessibilityEventHandlerRef); } else { m_plistAccessibilityEventHandlerRef = NULL; } @@ -213,6 +222,7 @@ void CProjectListCtrlAccessible::RemoveMacAccessibilitySupport() { void CNoticeListCtrlAccessible::SetupMacAccessibilitySupport() { + static HTMLListAccessibilityHandlerData userData; OSErr err; CNoticeListCtrl* pCtrl = wxDynamicCast(mp_win, CNoticeListCtrl); @@ -222,10 +232,12 @@ void CNoticeListCtrlAccessible::SetupMacAccessibilitySupport() { { m_listView = (HIViewRef)pCtrl->GetHandle(); err = HIViewSetEnabled(m_listView, true); + userData.pProjectListCtrlAccessible = NULL; + userData.pNoticeListCtrlAccessible = this; err = InstallHIObjectEventHandler((HIObjectRef)m_listView, NewEventHandlerUPP(HTMLListAccessibilityEventHandler), sizeof(myAccessibilityEvents) / sizeof(EventTypeSpec), myAccessibilityEvents, - this, &m_plistAccessibilityEventHandlerRef); + &userData, &m_plistAccessibilityEventHandlerRef); } else { m_plistAccessibilityEventHandlerRef = NULL; } @@ -330,12 +342,12 @@ pascal OSStatus BOINCListAccessibilityEventHandler( EventHandlerCallRef inHandle const UInt32 eventClass = GetEventClass(inEvent); const UInt32 eventKind = GetEventKind(inEvent); OSStatus err; - wxGenericListCtrl* pList = ((struct ListAccessData*)pData)->pList; - CBOINCBaseView* pView = ((struct ListAccessData*)pData)->pView; - HIViewRef headerView = ((struct ListAccessData*)pData)->headerView; - HIViewRef bodyView = ((struct ListAccessData*)pData)->bodyView; - CDlgEventLog* pEventLog = ((struct ListAccessData*)pData)->pEventLog; - Boolean snowLeopard = ((struct ListAccessData*)pData)->snowLeopard; + wxGenericListCtrl* pList = ((ListAccessData*)pData)->pList; + CBOINCBaseView* pView = ((ListAccessData*)pData)->pView; + HIViewRef headerView = ((ListAccessData*)pData)->headerView; + HIViewRef bodyView = ((ListAccessData*)pData)->bodyView; + CDlgEventLog* pEventLog = ((ListAccessData*)pData)->pEventLog; + Boolean snowLeopard = ((ListAccessData*)pData)->snowLeopard; if (eventClass != kEventClassAccessibility) { return eventNotHandledErr; @@ -370,6 +382,7 @@ pascal OSStatus BOINCListAccessibilityEventHandler( EventHandlerCallRef inHandle long theRow = wxNOT_FOUND; long ignored; int hitflags; + int x = 0; // Only the whole view or rows can be tested since the cells don't have sub-parts. if (col >= 0) { @@ -383,8 +396,16 @@ pascal OSStatus BOINCListAccessibilityEventHandler( EventHandlerCallRef inHandle wxPoint p((int)where.x, (int)where.y); pList->ScreenToClient(&p.x, &p.y); + int xoff = pList->GetScrollPos(wxHORIZONTAL); + if (xoff) { + int ppux, ppuy; + wxScrolledWindow * win = ((CBOINCListCtrl*)pList)->GetMainWin(); + win->GetScrollPixelsPerUnit(&ppux, &ppuy); + x -= (xoff * ppux); + } + // HitTest returns the column only on wxMSW - int x = 0, n = pList->GetColumnCount(); + int n = pList->GetColumnCount(); for (col=0; colGetColumnWidth(col); if (p.x < x) break; @@ -1001,7 +1022,7 @@ pascal OSStatus BOINCListAccessibilityEventHandler( EventHandlerCallRef inHandle } else if ( CFStringCompare( attribute, kAXPositionAttribute, 0 ) == kCFCompareEqualTo ) { HIPoint pt; wxRect r; - int i, x = 0, y = 0; + int i, x = 0, y = 0, xoff = 0, ppux, ppuy; // Return the position of this part as an HIPoint. // First get the position relative to the ListCtrl @@ -1016,6 +1037,12 @@ pascal OSStatus BOINCListAccessibilityEventHandler( EventHandlerCallRef inHandle x = r.x; } } + xoff = pList->GetScrollPos(wxHORIZONTAL); + if (xoff) { + wxScrolledWindow * win = ((CBOINCListCtrl*)pList)->GetMainWin(); + win->GetScrollPixelsPerUnit(&ppux, &ppuy); + x -= (xoff * ppux); + } // Now convert to global coordinates pList->ClientToScreen(&x, &y); pt.x = x; @@ -1257,14 +1284,14 @@ pascal OSStatus HTMLListAccessibilityEventHandler( EventHandlerCallRef inHandler CNoticeListCtrl* pNoticeListCtrl = NULL; OSStatus err; - pProjectListCtrlAccessible = wxDynamicCast(pData, CProjectListCtrlAccessible); + pProjectListCtrlAccessible = ((HTMLListAccessibilityHandlerData*)pData)->pProjectListCtrlAccessible; + pNoticeListCtrlAccessible = ((HTMLListAccessibilityHandlerData*)pData)->pNoticeListCtrlAccessible; if (pProjectListCtrlAccessible != NULL) { pProjectListCtrl = wxDynamicCast(pProjectListCtrlAccessible->GetWindow(), CProjectListCtrl); if (pProjectListCtrl == NULL) { return eventNotHandledErr; } } else { - pNoticeListCtrlAccessible = wxDynamicCast(pData, CNoticeListCtrlAccessible); if (pNoticeListCtrlAccessible == NULL) { return eventNotHandledErr; } diff --git a/clientgui/mac/MacAccessiblity.h b/clientgui/mac/MacAccessiblity.h index fa745cf387..d835d49f7d 100644 --- a/clientgui/mac/MacAccessiblity.h +++ b/clientgui/mac/MacAccessiblity.h @@ -24,14 +24,14 @@ #include "DlgEventLog.h" #include "wx/generic/listctrl.h" -struct ListAccessData { +typedef struct { wxGenericListCtrl* pList; CBOINCBaseView* pView; CDlgEventLog* pEventLog; HIViewRef headerView; HIViewRef bodyView; Boolean snowLeopard; -}; +} ListAccessData; void AccessibilityIgnoreAllChildren(HIViewRef parent, int recursionLevel);