Create wxAccessible object on demand in wxDVC
Create wxAccessible objects only in response to calls to GetOrCreateAccessible() to save resources.
This commit is contained in:
		| @@ -1386,6 +1386,10 @@ public: | |||||||
|     void OnCollapsed( wxDataViewEvent &event ); |     void OnCollapsed( wxDataViewEvent &event ); | ||||||
|     void OnSize( wxSizeEvent &event ); |     void OnSize( wxSizeEvent &event ); | ||||||
|  |  | ||||||
|  | #if wxUSE_ACCESSIBILITY | ||||||
|  |     virtual wxAccessible* CreateAccessible() wxOVERRIDE; | ||||||
|  | #endif // wxUSE_ACCESSIBILITY | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     wxDECLARE_EVENT_TABLE(); |     wxDECLARE_EVENT_TABLE(); | ||||||
|     wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl); |     wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl); | ||||||
|   | |||||||
| @@ -329,6 +329,10 @@ public:     // utility functions not part of the API | |||||||
|  |  | ||||||
|     virtual void OnInternalIdle() wxOVERRIDE; |     virtual void OnInternalIdle() wxOVERRIDE; | ||||||
|  |  | ||||||
|  | #if wxUSE_ACCESSIBILITY | ||||||
|  |     virtual wxAccessible* CreateAccessible() wxOVERRIDE; | ||||||
|  | #endif // wxUSE_ACCESSIBILITY | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     virtual wxDataViewItem DoGetCurrentItem() const wxOVERRIDE; |     virtual wxDataViewItem DoGetCurrentItem() const wxOVERRIDE; | ||||||
|     virtual void DoSetCurrentItem(const wxDataViewItem& item) wxOVERRIDE; |     virtual void DoSetCurrentItem(const wxDataViewItem& item) wxOVERRIDE; | ||||||
|   | |||||||
| @@ -2570,10 +2570,6 @@ bool wxDataViewTreeCtrl::Create( wxWindow *parent, wxWindowID id, | |||||||
|         0                           // not resizable |         0                           // not resizable | ||||||
|     ); |     ); | ||||||
|  |  | ||||||
| #if wxUSE_ACCESSIBILITY |  | ||||||
|     SetAccessible(new wxDataViewTreeCtrlAccessible(this)); |  | ||||||
| #endif // wxUSE_ACCESSIBILITY |  | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -2743,6 +2739,13 @@ void wxDataViewTreeCtrl::OnSize( wxSizeEvent &event ) | |||||||
|     event.Skip( true ); |     event.Skip( true ); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #if wxUSE_ACCESSIBILITY | ||||||
|  | wxAccessible* wxDataViewTreeCtrl::CreateAccessible() | ||||||
|  | { | ||||||
|  |     return new wxDataViewTreeCtrlAccessible(this); | ||||||
|  | } | ||||||
|  | #endif // wxUSE_ACCESSIBILITY | ||||||
|  |  | ||||||
| #if wxUSE_ACCESSIBILITY | #if wxUSE_ACCESSIBILITY | ||||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||||
| // wxDataViewTreeCtrlAccessible | // wxDataViewTreeCtrlAccessible | ||||||
|   | |||||||
| @@ -241,12 +241,6 @@ public: | |||||||
|     wxDataViewHeaderWindow(wxDataViewCtrl *parent) |     wxDataViewHeaderWindow(wxDataViewCtrl *parent) | ||||||
|         : wxHeaderCtrl(parent) |         : wxHeaderCtrl(parent) | ||||||
|     { |     { | ||||||
| #if wxUSE_ACCESSIBILITY |  | ||||||
|         // Under MSW wxHeadrCtrl is a native control |  | ||||||
|         // so we just need to pass all requests |  | ||||||
|         // to the accessibility framework. |  | ||||||
|         SetAccessible(new wxAccessible(this)); |  | ||||||
| #endif // wxUSE_ACCESSIBILITY |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     wxDataViewCtrl *GetOwner() const |     wxDataViewCtrl *GetOwner() const | ||||||
| @@ -276,6 +270,16 @@ public: | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | #if wxUSE_ACCESSIBILITY | ||||||
|  |     virtual wxAccessible* CreateAccessible() wxOVERRIDE | ||||||
|  |     { | ||||||
|  |         // Under MSW wxHeadrCtrl is a native control | ||||||
|  |         // so we just need to pass all requests | ||||||
|  |         // to the accessibility framework. | ||||||
|  |         return new wxAccessible(this); | ||||||
|  |     } | ||||||
|  | #endif // wxUSE_ACCESSIBILITY | ||||||
|  |  | ||||||
| protected: | protected: | ||||||
|     // implement/override wxHeaderCtrl functions by forwarding them to the main |     // implement/override wxHeaderCtrl functions by forwarding them to the main | ||||||
|     // control |     // control | ||||||
| @@ -4668,10 +4672,6 @@ bool wxDataViewCtrl::Create(wxWindow *parent, | |||||||
|  |  | ||||||
|     m_clientArea = new wxDataViewMainWindow( this, wxID_ANY ); |     m_clientArea = new wxDataViewMainWindow( this, wxID_ANY ); | ||||||
|  |  | ||||||
| #if wxUSE_ACCESSIBILITY |  | ||||||
|     SetAccessible(new wxDataViewCtrlAccessible(this)); |  | ||||||
| #endif // wxUSE_ACCESSIBILITY |  | ||||||
|  |  | ||||||
|     // We use the cursor keys for moving the selection, not scrolling, so call |     // We use the cursor keys for moving the selection, not scrolling, so call | ||||||
|     // this method to ensure wxScrollHelperEvtHandler doesn't catch all |     // this method to ensure wxScrollHelperEvtHandler doesn't catch all | ||||||
|     // keyboard events forwarded to us from wxListMainWindow. |     // keyboard events forwarded to us from wxListMainWindow. | ||||||
| @@ -5495,7 +5495,12 @@ void wxDataViewCtrl::DoEnableSystemTheme(bool enable, wxWindow* window) | |||||||
|         Base::DoEnableSystemTheme(enable, m_headerArea); |         Base::DoEnableSystemTheme(enable, m_headerArea); | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif // !wxUSE_GENERICDATAVIEWCTRL | #if wxUSE_ACCESSIBILITY | ||||||
|  | wxAccessible* wxDataViewCtrl::CreateAccessible() | ||||||
|  | { | ||||||
|  |     return new wxDataViewCtrlAccessible(this); | ||||||
|  | } | ||||||
|  | #endif // wxUSE_ACCESSIBILITY | ||||||
|  |  | ||||||
| #if wxUSE_ACCESSIBILITY | #if wxUSE_ACCESSIBILITY | ||||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||||
| @@ -6236,15 +6241,31 @@ wxAccStatus wxDataViewCtrlAccessible::GetFocus(int* childId, wxAccessible** chil | |||||||
|         *childId = row+1; |         *childId = row+1; | ||||||
|         *child = NULL; |         *child = NULL; | ||||||
|     } |     } | ||||||
|     else if ( dvWnd->HasFocus() ) |  | ||||||
|     { |  | ||||||
|         *childId = wxACC_SELF; |  | ||||||
|         *child = this; |  | ||||||
|     } |  | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         *childId = 0; |         // First check if header is focused because header control | ||||||
|         *child = NULL; |         // handles accesibility requestes on its own. | ||||||
|  |         wxHeaderCtrl* dvHdr = dvCtrl->GenericGetHeader(); | ||||||
|  |         if ( dvHdr ) | ||||||
|  |         { | ||||||
|  |             if ( dvHdr->HasFocus() ) | ||||||
|  |             { | ||||||
|  |                 *childId = wxACC_SELF; | ||||||
|  |                 *child = dvHdr->GetOrCreateAccessible(); | ||||||
|  |                 return wxACC_OK; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if ( dvWnd->HasFocus() ) | ||||||
|  |         { | ||||||
|  |             *childId = wxACC_SELF; | ||||||
|  |             *child = this; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             *childId = 0; | ||||||
|  |             *child = NULL; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return wxACC_OK; |     return wxACC_OK; | ||||||
| @@ -6289,7 +6310,8 @@ wxAccStatus wxDataViewCtrlAccessible::GetSelections(wxVariant* selections) | |||||||
|  |  | ||||||
|     return wxACC_OK; |     return wxACC_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif // wxUSE_ACCESSIBILITY | #endif // wxUSE_ACCESSIBILITY | ||||||
|  |  | ||||||
|  | #endif // !wxUSE_GENERICDATAVIEWCTRL | ||||||
|  |  | ||||||
| #endif // wxUSE_DATAVIEWCTRL | #endif // wxUSE_DATAVIEWCTRL | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user