MMGR: Implement accessibility on Mac for Statistics and Disk (Resources) tabs

- CPaintStatistics class
 - wxPieCtrl class
 - Remove obsolete accessibility code
This commit is contained in:
Charlie Fenton 2013-10-24 05:49:59 -07:00
parent d823657a6e
commit 06dff8df7b
13 changed files with 242 additions and 75 deletions

View File

@ -68,15 +68,8 @@ public:
CTaskItemGroup( wxString strName ) :
m_strName(strName), m_pStaticBox(NULL), m_pStaticBoxSizer(NULL) {
m_Tasks.clear();
#ifdef __WXMAC__
m_pTaskGroupAccessibilityEventHandlerRef = NULL;
#endif
};
~CTaskItemGroup() {
#ifdef __WXMAC__
RemoveMacAccessibilitySupport();
#endif
};
~CTaskItemGroup() {};
wxButton* button(int i) {return m_Tasks[i]->m_pButton;}
wxString m_strName;
@ -85,14 +78,6 @@ public:
wxStaticBoxSizer* m_pStaticBoxSizer;
std::vector<CTaskItem*> m_Tasks;
#ifdef __WXMAC__
void SetupMacAccessibilitySupport();
void RemoveMacAccessibilitySupport();
private:
EventHandlerRef m_pTaskGroupAccessibilityEventHandlerRef;
#endif
};
typedef bool (*ListSortCompareFunc)(int, int);

View File

@ -42,10 +42,6 @@
#include "wx/generic/listctrl.h"
#endif
#ifdef __WXMAC__
#include "macAccessiblity.h"
#endif
#include "BOINCBaseView.h"
@ -103,13 +99,7 @@ private:
#ifdef __WXMAC__
void SetupMacAccessibilitySupport();
void RemoveMacAccessibilitySupport();
ListAccessData accessibilityHandlerData;
EventHandlerRef m_pHeaderAccessibilityEventHandlerRef;
EventHandlerRef m_pBodyAccessibilityEventHandlerRef;
void OnSize( wxSizeEvent &event );
void OnSize( wxSizeEvent &event );
void* m_fauxHeaderView;
void* m_fauxBodyView;

View File

@ -176,9 +176,6 @@ wxInt32 CBOINCTaskCtrl::UpdateControls() {
pGroup->m_pStaticBox = new wxStaticBox(this, wxID_ANY, pGroup->m_strName);
pGroup->m_pStaticBoxSizer = new wxStaticBoxSizer(pGroup->m_pStaticBox, wxVERTICAL);
m_pSizer->Add(pGroup->m_pStaticBoxSizer, 0, wxEXPAND|wxALL, 5);
#ifdef __WXMAC__
pGroup->SetupMacAccessibilitySupport();
#endif
layoutChanged = 1;
}
}

View File

@ -23,7 +23,6 @@
#endif
#ifdef __WXMAC__
#include "macAccessiblity.h"
#define DLG_LISTCTRL_BASE wxGenericListCtrl
#else
#define DLG_LISTCTRL_BASE wxListView
@ -62,16 +61,10 @@ private:
#ifdef __WXMAC__
void SetupMacAccessibilitySupport();
void RemoveMacAccessibilitySupport();
void OnSize( wxSizeEvent &event );
void OnSize( wxSizeEvent &event );
void* m_fauxHeaderView;
void* m_fauxBodyView;
ListAccessData accessibilityHandlerData;
EventHandlerRef m_pHeaderAccessibilityEventHandlerRef;
EventHandlerRef m_pBodyAccessibilityEventHandlerRef;
#endif
};

View File

@ -45,12 +45,12 @@
CNoticeListCtrlAccessible::CNoticeListCtrlAccessible(wxWindow* win) {
mp_win = win;
SetupMacAccessibilitySupport();
// SetupMacAccessibilitySupport();
}
CNoticeListCtrlAccessible::~CNoticeListCtrlAccessible() {
RemoveMacAccessibilitySupport();
// RemoveMacAccessibilitySupport();
}
#endif

View File

@ -69,13 +69,8 @@ public:
#endif
#ifdef __WXMAC__
wxWindow *mp_win;
HIViewRef m_listView;
EventHandlerRef m_plistAccessibilityEventHandlerRef;
wxWindow *mp_win;
wxWindow *GetWindow() { return mp_win; }
void SetupMacAccessibilitySupport();
void RemoveMacAccessibilitySupport();
#endif
};

View File

@ -199,12 +199,20 @@ CPaintStatistics::CPaintStatistics(wxWindow* parent, wxWindowID id, const wxPoin
m_dc_bmp.Create(1, 1);
m_full_repaint = true;
m_bmp_OK = false;
#ifdef __WXMAC__
m_fauxStatisticsView = NULL;
SetupMacAccessibilitySupport();
#endif
}
CPaintStatistics::~CPaintStatistics() {
if (m_scrollBar) {
delete m_scrollBar;
}
#ifdef __WXMAC__
RemoveMacAccessibilitySupport();
#endif
}
@ -1910,6 +1918,9 @@ void CPaintStatistics::OnLegendScroll(wxScrollEvent& event) {
void CPaintStatistics::OnSize(wxSizeEvent& event) {
m_full_repaint = true;
Refresh(false);
#ifdef __WXMAC__
ResizeMacAccessibilitySupport();
#endif
event.Skip();
}
@ -2051,17 +2062,10 @@ CViewStatistics::CViewStatistics(wxNotebook* pNotebook) :
m_pTaskPane->UpdateControls();
UpdateSelection();
#ifdef __WXMAC__
SetupMacAccessibilitySupport();
#endif
}
CViewStatistics::~CViewStatistics() {
EmptyTasks();
#ifdef __WXMAC__
RemoveMacAccessibilitySupport();
#endif
}
wxString& CViewStatistics::GetViewName() {

View File

@ -207,6 +207,14 @@ protected:
void OnMouseLeaveWindows(wxMouseEvent& event);
void OnLegendScroll(wxScrollEvent& event);
#ifdef __WXMAC__
void SetupMacAccessibilitySupport();
void ResizeMacAccessibilitySupport();
void RemoveMacAccessibilitySupport();
void* m_fauxStatisticsView;
#endif
DECLARE_EVENT_TABLE()
};
@ -244,13 +252,6 @@ protected:
CPaintStatistics* m_PaintStatistics;
#ifdef __WXMAC__
void SetupMacAccessibilitySupport();
void RemoveMacAccessibilitySupport();
EventHandlerRef m_pStatisticsAccessibilityEventHandlerRef;
#endif
virtual bool OnSaveState( wxConfigBase* pConfig );
virtual bool OnRestoreState( wxConfigBase* pConfig );

View File

@ -74,6 +74,7 @@ wxPieCtrl::wxPieCtrl(wxWindow * parent, wxWindowID id, wxPoint pos,
wxPieCtrl::~wxPieCtrl() {
#ifdef __WXMAC__
m_fauxResourcesView = NULL;
RemoveMacAccessibilitySupport();
#endif
}
@ -136,6 +137,9 @@ void wxPieCtrl::OnSize(wxSizeEvent & /*event*/)
{
RecreateCanvas();
Refresh();
#ifdef __WXMAC__
ResizeMacAccessibilitySupport();
#endif
}
void wxPieCtrl::OnEraseBackground(wxEraseEvent & /*event*/)

View File

@ -150,9 +150,10 @@ public:
#ifdef __WXMAC__
private:
void SetupMacAccessibilitySupport();
void ResizeMacAccessibilitySupport();
void RemoveMacAccessibilitySupport();
EventHandlerRef m_pPieCtrlAccessibilityEventHandlerRef;
void* m_fauxResourcesView;
#endif
};

View File

@ -1,6 +1,6 @@
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2013 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
@ -20,9 +20,12 @@
#include "MacGUI.pch"
#include <Cocoa/Cocoa.h>
#include "BOINCBaseFrame.h"
#include "MainDocument.h"
#include "BOINCListCtrl.h"
#import "DlgEventLogListCtrl.h"
#include "DlgEventLogListCtrl.h"
#include "ViewStatistics.h"
#include "wxPieCtrl.h"
#import <AppKit/NSAccessibility.h>
@ -33,6 +36,8 @@
#error: must convert to Quartz coordinates in accessibilityHitTest and NSAccessibilityPositionAttribute
#endif
#pragma mark === CBOINCListCtrl & CDlgEventLogListCtrl Accessibility Support ===
#if USE_NATIVE_LISTCONTROL
#error: This code assumes wxGenericListCtrl
#endif
@ -1192,7 +1197,6 @@ void CDlgEventLogListCtrl::SetupMacAccessibilitySupport() {
NSRect rh = r;
rh.size.height = ((wxWindow *)m_headerWin)->GetSize().y;
//TODO: combine next 2 lines
[fauxHeaderView initWithFrame:rh listCtrl:this listFlags:(isHeaderFlag | isEventLogFlag) parent:listControlView BOINCView:nil];
[listControlView addSubview:fauxHeaderView ];
@ -1249,7 +1253,6 @@ void CBOINCListCtrl::SetupMacAccessibilitySupport() {
NSRect rh = r;
rh.size.height = ((wxWindow *)m_headerWin)->GetSize().y;
//TODO: combine next 2 lines
[fauxHeaderView initWithFrame:rh listCtrl:this listFlags:isHeaderFlag parent:listControlView BOINCView:m_pParentView ];
[listControlView addSubview:fauxHeaderView ];
@ -1294,3 +1297,206 @@ void CBOINCListCtrl::RemoveMacAccessibilitySupport() {
[(FauxListBodyView *)m_fauxBodyView release];
m_fauxBodyView = nil;
}
#pragma mark === CViewStatistics Accessibility Support ===
#define statisticsPage 1
#define resourcesPage 2
@interface FauxGeneralView : NSView {
id parent;
NSInteger viewPage;
void* theClass;
}
- (id)initWithFrame:(NSRect)frame whichViewPage:(NSInteger)aViewPage callingClass:(void*)aClass parent:aParent;
- (NSString*) getValue;
@end
@implementation FauxGeneralView
- (id)initWithFrame:(NSRect)frame whichViewPage:(NSInteger)aViewPage callingClass:(void*)aClass parent:aParent
{
[super initWithFrame:frame];
parent = aParent;
viewPage = aViewPage;
theClass = aClass;
return self;
}
- (BOOL)isFlipped {
return YES;
}
- (BOOL)accessibilityIsIgnored {
return NO;
}
- (NSString*) getValue {
wxString s;
switch (viewPage) {
case statisticsPage:
s = _("This panel contains graphs showing user totals for projects");
break;
case resourcesPage:
{
wxPieCtrl* pPieCtrl = (wxPieCtrl*)theClass;
s = pPieCtrl->GetLabel();
unsigned int i;
for(i=0; i<pPieCtrl->m_Series.Count(); i++) {
s += wxT("; ");
s += pPieCtrl->m_Series[i].GetLabel();
}
}
break;
default:
s = wxEmptyString;
break;
}
NSString *desc = [NSString stringWithUTF8String:(char *)(s.utf8_str().data())];
return desc;
}
- (NSArray *)accessibilityAttributeNames {
static NSArray *attributes = nil;
if (attributes == nil) {
attributes = [[NSArray alloc] initWithObjects:
NSAccessibilityEnabledAttribute,
NSAccessibilityFocusedAttribute,
NSAccessibilityNumberOfCharactersAttribute,
NSAccessibilityParentAttribute,
NSAccessibilityPositionAttribute,
NSAccessibilityRoleAttribute,
NSAccessibilityRoleDescriptionAttribute,
NSAccessibilitySelectedTextAttribute,
NSAccessibilitySelectedTextRangeAttribute,
NSAccessibilityValueAttribute,
NSAccessibilityVisibleCharacterRangeAttribute,
NSAccessibilitySizeAttribute,
NSAccessibilityTopLevelUIElementAttribute,
NSAccessibilityWindowAttribute,
nil];
}
return attributes;
}
- (id)accessibilityAttributeValue:(NSString *)attribute {
if ([attribute isEqualToString:NSAccessibilityEnabledAttribute]) {
return [NSNumber numberWithBool:YES];
} else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
return NO;
} else if ([attribute isEqualToString:NSAccessibilityNumberOfCharactersAttribute]) {
NSString *s = [self getValue];
NSUInteger n = [s lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
return [NSNumber numberWithUnsignedInt:n];
} else if ([attribute isEqualToString:NSAccessibilityParentAttribute]) {
return NSAccessibilityUnignoredAncestor(parent);
} else if ([attribute isEqualToString:NSAccessibilityPositionAttribute]) {
NSPoint pt = [self bounds].origin;
pt.y += [self bounds].size.height; // We need the bottom left corner
//Convert the point to global (screen) coordinates
// NSPoint windowPoint = [self convertPoint:pt toView: nil];
NSPoint windowPoint = [parent convertPoint:pt toView: nil];
pt = [[parent window] convertBaseToScreen:windowPoint];
return [NSValue valueWithPoint:pt];
} else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
return NSAccessibilityStaticTextRole;
} else if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
return NSAccessibilityRoleDescription(NSAccessibilityStaticTextRole, nil);
} else if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute]) {
NSString *s = [NSString init];
return s;
} else if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) {
NSRange range = NSMakeRange(0, 0);
return [NSValue valueWithRange:range];
} else if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
return [self getValue];
} else if ([attribute isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute]) {
NSString *s = [self getValue];
NSRange range = NSMakeRange(0, [s length]);
return [NSValue valueWithRange:range];
} else if ([attribute isEqualToString:NSAccessibilitySizeAttribute]) {
return [NSValue valueWithSize:[self frame].size];
} else if ([attribute isEqualToString:NSAccessibilityTopLevelUIElementAttribute]) {
return [parent window];
} else if ([attribute isEqualToString:NSAccessibilityWindowAttribute]) {
// We're in the same window as our parent.
return [parent window];
} else {
return [super accessibilityAttributeValue:attribute];
}
}
- (void)dealloc {
[super dealloc];
}
@end
void CPaintStatistics::SetupMacAccessibilitySupport() {
NSView *statisticsView = GetHandle();
NSRect r = [ statisticsView bounds ];
FauxGeneralView *fauxStatisticsView = [FauxGeneralView alloc ];
[fauxStatisticsView initWithFrame:r whichViewPage:statisticsPage callingClass:this parent:statisticsView];
[ statisticsView addSubview:fauxStatisticsView ];
m_fauxStatisticsView = fauxStatisticsView;
}
void CPaintStatistics::ResizeMacAccessibilitySupport() {
NSView *statisticsView = GetHandle();
NSRect r = [ statisticsView bounds ];
FauxGeneralView *fauxStatisticsView = (FauxGeneralView *)m_fauxStatisticsView;
if (fauxStatisticsView) {
[ fauxStatisticsView setFrame:r ];
}
}
void CPaintStatistics::RemoveMacAccessibilitySupport() {
[(FauxGeneralView *)m_fauxStatisticsView release];
m_fauxStatisticsView = nil;
}
void wxPieCtrl::SetupMacAccessibilitySupport() {
NSView *resourcesView = GetHandle();
NSRect r = [ resourcesView bounds ];
FauxGeneralView *fauxResourcesView = [FauxGeneralView alloc ];
[fauxResourcesView initWithFrame:r whichViewPage:resourcesPage callingClass:this parent:resourcesView];
[ resourcesView addSubview:fauxResourcesView ];
m_fauxResourcesView = fauxResourcesView;
}
void wxPieCtrl::ResizeMacAccessibilitySupport() {
NSView *resourcesView = GetHandle();
NSRect r = [ resourcesView bounds ];
FauxGeneralView *fauxResourcesView = (FauxGeneralView *)m_fauxResourcesView;
if (fauxResourcesView) {
[ fauxResourcesView setFrame:r ];
}
}
void wxPieCtrl::RemoveMacAccessibilitySupport() {
[(FauxGeneralView *)m_fauxResourcesView release];
m_fauxResourcesView = nil;
}

View File

@ -21,9 +21,6 @@
#endif
#include "stdwx.h"
#ifdef __WXMAC__
#include "MacAccessiblity.h"
#endif
#include "diagnostics.h"
#include "str_util.h"
#include "mfile.h"

View File

@ -353,7 +353,6 @@
DDA6BD2B0BD4551F008F7921 /* QSymbols.c in Sources */ = {isa = PBXBuildFile; fileRef = DDA6BD0E0BD4551F008F7921 /* QSymbols.c */; };
DDA6BD2D0BD4551F008F7921 /* QTaskMemory.c in Sources */ = {isa = PBXBuildFile; fileRef = DDA6BD100BD4551F008F7921 /* QTaskMemory.c */; };
DDA850A41207EED900B473A6 /* WizardAttach.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DDA850A21207EED900B473A6 /* WizardAttach.cpp */; };
DDA99BF41099AF18002F8E9B /* MacAccessiblity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DDA99BF31099AF18002F8E9B /* MacAccessiblity.cpp */; };
DDAEB54012F8295800EDEDBE /* LogBOINC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD81C41407C5D13E0098A04D /* LogBOINC.cpp */; };
DDAEC9FF07FA5A5C00A7BC36 /* SetVersion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DDAEC9E707FA58A000A7BC36 /* SetVersion.cpp */; };
DDB219B210B3BBA900417AEF /* WaitPermissions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DDB219B110B3BBA900417AEF /* WaitPermissions.cpp */; };
@ -778,7 +777,6 @@
DD25F72515914F8C007845B5 /* gpu_opencl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gpu_opencl.cpp; sourceTree = "<group>"; };
DD25F72615914F8C007845B5 /* gpu_detect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gpu_detect.cpp; sourceTree = "<group>"; };
DD25F72715914F8C007845B5 /* gpu_detect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gpu_detect.h; sourceTree = "<group>"; };
DD29728E10BB657A00DF3C2E /* MacAccessiblity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MacAccessiblity.h; path = ../clientgui/mac/MacAccessiblity.h; sourceTree = SOURCE_ROOT; };
DD2B6C7E13149177005D6F3E /* procinfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = procinfo.cpp; path = ../lib/procinfo.cpp; sourceTree = SOURCE_ROOT; };
DD2B6C7F13149177005D6F3E /* procinfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = procinfo.h; path = ../lib/procinfo.h; sourceTree = SOURCE_ROOT; };
DD2D25CB07FAB41700151141 /* DlgSelectComputer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = DlgSelectComputer.cpp; path = ../clientgui/DlgSelectComputer.cpp; sourceTree = SOURCE_ROOT; };
@ -1078,7 +1076,6 @@
DDA6BD110BD4551F008F7921 /* QTaskMemory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = QTaskMemory.h; path = ../lib/mac/QTaskMemory.h; sourceTree = SOURCE_ROOT; };
DDA850A21207EED900B473A6 /* WizardAttach.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WizardAttach.cpp; path = ../clientgui/WizardAttach.cpp; sourceTree = SOURCE_ROOT; };
DDA850A31207EED900B473A6 /* WizardAttach.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WizardAttach.h; path = ../clientgui/WizardAttach.h; sourceTree = SOURCE_ROOT; };
DDA99BF31099AF18002F8E9B /* MacAccessiblity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MacAccessiblity.cpp; path = ../clientgui/mac/MacAccessiblity.cpp; sourceTree = SOURCE_ROOT; };
DDA9D3BB09189A8C0060E7A7 /* Mac_GUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mac_GUI.cpp; path = ../clientgui/mac/Mac_GUI.cpp; sourceTree = SOURCE_ROOT; };
DDAEC9E107FA583B00A7BC36 /* SetVersion */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SetVersion; sourceTree = BUILT_PRODUCTS_DIR; };
DDAEC9E707FA58A000A7BC36 /* SetVersion.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = SetVersion.cpp; path = ../clientgui/mac/SetVersion.cpp; sourceTree = SOURCE_ROOT; };
@ -1991,8 +1988,6 @@
DD6ABCD00BD4C5CA009AA7A1 /* browser_safari.mm */,
DD30446A0864332D00D73756 /* config.h */,
DD1F0ACD0822069E00AFC5FA /* MacGUI.pch */,
DDA99BF31099AF18002F8E9B /* MacAccessiblity.cpp */,
DD29728E10BB657A00DF3C2E /* MacAccessiblity.h */,
DD1907FA17D1A2F100596F03 /* MacAccessiblity.mm */,
DD77A71612F2D1C9006B82E9 /* MacBitmapComboBox.cpp */,
DD77A71712F2D1C9006B82E9 /* MacBitmapComboBox.h */,
@ -2890,7 +2885,6 @@
DDDE43B10EC04C1800083520 /* DlgExitMessage.cpp in Sources */,
DDC836E60EDEA5DB001C2EF9 /* TermsOfUsePage.cpp in Sources */,
DDA0C8350FE1D704001E02E6 /* procinfo_mac.cpp in Sources */,
DDA99BF41099AF18002F8E9B /* MacAccessiblity.cpp in Sources */,
DDC06ABC10A3E98D00C8D9A5 /* url.cpp in Sources */,
DDD9C5A510CCF61F00A1E4CD /* coproc.cpp in Sources */,
DDE1373D10DC60BB00161D6B /* ViewNotices.cpp in Sources */,