3030using System . Linq ;
3131using System . Collections . Generic ;
3232
33+ using Foundation ;
34+ using GLib ;
3335using Gtk ;
3436
3537using Mono . Debugging . Client ;
3638
3739using MonoDevelop . Ide ;
3840using MonoDevelop . Core ;
3941using MonoDevelop . Components ;
42+ using MonoDevelop . Components . AtkCocoaHelper ;
4043using MonoDevelop . Ide . TextEditing ;
4144using MonoDevelop . Ide . Editor . Extension ;
4245
@@ -56,7 +59,7 @@ class ExceptionCaughtDialog : Gtk.Window
5659 VBox vboxAroundInnerExceptionMessage , rightVBox , container ;
5760 Button close , helpLinkButton , innerExceptionHelpLinkButton ;
5861 TreeView exceptionValueTreeView , stackTraceTreeView ;
59- Expander expanderProperties , expanderStacktrace ;
62+ MacObjectValueTreeView macExceptionValueTreeView ;
6063 InnerExceptionsTree innerExceptionsTreeView ;
6164 ObjectValueTreeViewController controller ;
6265 CheckButton onlyShowMyCodeCheckbox ;
@@ -96,6 +99,8 @@ Widget CreateExceptionHeader ()
9699 icon . Yalign = 0 ;
97100
98101 exceptionTypeLabel = new Label { Xalign = 0.0f , Selectable = true , CanFocus = false } ;
102+ icon . SetCommonAccessibilityAttributes ( "ExceptionCaughtDialog.WarningIcon" , exceptionTypeLabel , null ) ;
103+
99104 exceptionMessageLabel = new Label { Wrap = true , Xalign = 0.0f , Selectable = true , CanFocus = false } ;
100105 helpLinkButton = new Button { HasFocus = true , Xalign = 0 , Relief = ReliefStyle . None , BorderWidth = 0 } ;
101106 helpLinkButton . Name = "exception_help_link_label" ;
@@ -181,12 +186,17 @@ protected override void OnSizeAllocated (Gdk.Rectangle allocation)
181186
182187 Widget CreateExceptionValueTreeView ( )
183188 {
189+ Widget scrolledWidget = null ;
184190 if ( useNewTreeView ) {
185191 controller = new ObjectValueTreeViewController ( ) ;
186192 controller . SetStackFrame ( DebuggingService . CurrentFrame ) ;
187193 controller . AllowExpanding = true ;
188194
189- exceptionValueTreeView = controller . GetGtkControl ( ObjectValueTreeViewFlags . ExceptionCaughtFlags ) ;
195+ if ( Platform . IsMac ) {
196+ macExceptionValueTreeView = controller . GetMacControl ( ObjectValueTreeViewFlags . ObjectValuePadFlags ) ;
197+ } else {
198+ exceptionValueTreeView = controller . GetGtkControl ( ObjectValueTreeViewFlags . ExceptionCaughtFlags ) ;
199+ }
190200 } else {
191201 var objValueTreeView = new ObjectValueTreeView ( ) ;
192202 objValueTreeView . Frame = DebuggingService . CurrentFrame ;
@@ -199,77 +209,70 @@ Widget CreateExceptionValueTreeView ()
199209 exceptionValueTreeView = objValueTreeView ;
200210 }
201211
202- exceptionValueTreeView . ModifyBase ( StateType . Normal , Styles . ExceptionCaughtDialog . ValueTreeBackgroundColor . ToGdkColor ( ) ) ;
203- exceptionValueTreeView . ModifyBase ( StateType . Active , Styles . ObjectValueTreeActiveBackgroundColor . ToGdkColor ( ) ) ;
204- exceptionValueTreeView . ModifyFont ( Pango . FontDescription . FromString ( Platform . IsWindows ? "9" : "11" ) ) ;
205- exceptionValueTreeView . RulesHint = false ;
206- exceptionValueTreeView . CanFocus = true ;
207- exceptionValueTreeView . Show ( ) ;
212+ if ( useNewTreeView && Platform . IsMac ) {
213+ var scrolled = new AppKit . NSScrollView {
214+ DocumentView = macExceptionValueTreeView ,
215+ AutohidesScrollers = true ,
216+ HasVerticalScroller = true ,
217+ HasHorizontalScroller = true ,
218+ } ;
219+
220+ // disable implicit animations
221+ scrolled . WantsLayer = true ;
222+ scrolled . Layer . Actions = new NSDictionary (
223+ "actions" , NSNull . Null ,
224+ "contents" , NSNull . Null ,
225+ "hidden" , NSNull . Null ,
226+ "onLayout" , NSNull . Null ,
227+ "onOrderIn" , NSNull . Null ,
228+ "onOrderOut" , NSNull . Null ,
229+ "position" , NSNull . Null ,
230+ "sublayers" , NSNull . Null ,
231+ "transform" , NSNull . Null ,
232+ "bounds" , NSNull . Null ) ;
233+
234+ var host = new GtkNSViewHost ( scrolled ) ;
235+ host . ShowAll ( ) ;
236+ scrolledWidget = host ;
237+ } else {
238+ exceptionValueTreeView . ModifyBase ( StateType . Normal , Styles . ExceptionCaughtDialog . ValueTreeBackgroundColor . ToGdkColor ( ) ) ;
239+ exceptionValueTreeView . ModifyBase ( StateType . Active , Styles . ObjectValueTreeActiveBackgroundColor . ToGdkColor ( ) ) ;
240+ exceptionValueTreeView . ModifyFont ( Pango . FontDescription . FromString ( Platform . IsWindows ? "9" : "11" ) ) ;
241+ exceptionValueTreeView . RulesHint = false ;
242+ exceptionValueTreeView . CanFocus = true ;
243+ exceptionValueTreeView . Show ( ) ;
244+
245+ var scrolled = new ScrolledWindow {
246+ CanFocus = true ,
247+ HscrollbarPolicy = PolicyType . Automatic ,
248+ VscrollbarPolicy = PolicyType . Automatic
249+ } ;
250+
251+ scrolled . ShadowType = ShadowType . None ;
252+ scrolled . Add ( exceptionValueTreeView ) ;
253+ scrolled . Show ( ) ;
254+ scrolledWidget = scrolled ;
255+ }
208256
209- var scrolled = new ScrolledWindow {
210- HeightRequest = 180 ,
211- CanFocus = true ,
212- HscrollbarPolicy = PolicyType . Automatic ,
213- VscrollbarPolicy = PolicyType . Automatic
214- } ;
257+ var label = new Label ( ) ;
258+ label . Markup = "<b>" + GettextCatalog . GetString ( "Properties" ) + "</b>" ;
259+ label . Xalign = 0 ;
260+ label . Xpad = 10 ;
215261
216- scrolled . ShadowType = ShadowType . None ;
217- scrolled . Add ( exceptionValueTreeView ) ;
218- scrolled . Show ( ) ;
262+ if ( exceptionValueTreeView != null ) {
263+ exceptionValueTreeView . SetCommonAccessibilityAttributes ( "ExceptionCaughtDialog.ExceptionValueTreeView" , label , null ) ;
264+ } else {
265+ macExceptionValueTreeView . AccessibilityTitle = new NSString ( label . Text ) ;
266+ }
219267
220268 var vbox = new VBox ( ) ;
221- expanderProperties = WrapInExpander ( GettextCatalog . GetString ( "Properties" ) , scrolled ) ;
222- vbox . PackStart ( new VBox ( ) , false , false , 5 ) ;
223- vbox . PackStart ( expanderProperties , true , true , 0 ) ;
269+ vbox . PackStart ( label , false , false , 12 ) ;
270+ vbox . PackStart ( scrolledWidget , true , true , 0 ) ;
224271 vbox . ShowAll ( ) ;
225272
226273 return vbox ;
227274 }
228275
229- class ExpanderWithMinSize : Expander
230- {
231- public ExpanderWithMinSize ( string label ) : base ( label )
232- {
233- }
234-
235- protected override void OnSizeRequested ( ref Requisition requisition )
236- {
237- base . OnSizeRequested ( ref requisition ) ;
238- requisition . Height = 28 ;
239- }
240- }
241-
242- Expander WrapInExpander ( string title , Widget widget )
243- {
244- var expander = new ExpanderWithMinSize ( $ "<b>{ GLib . Markup . EscapeText ( title ) } </b>") ;
245- expander . Name = "exception_dialog_expander" ;
246- Gtk . Rc . ParseString ( @"style ""exception-dialog-expander""
247- {
248- GtkExpander::expander-spacing = 10
249- }
250- widget ""*.exception_dialog_expander"" style ""exception-dialog-expander""
251- " ) ;
252- expander . Child = widget ;
253- expander . Spacing = 0 ;
254- expander . Show ( ) ;
255- expander . CanFocus = true ;
256- expander . UseMarkup = true ;
257- expander . Expanded = true ;
258- expander . Activated += Expander_Activated ;
259- expander . ModifyBg ( StateType . Prelight , Ide . Gui . Styles . PrimaryBackgroundColor . ToGdkColor ( ) ) ;
260- return expander ;
261- }
262-
263- void Expander_Activated ( object sender , EventArgs e )
264- {
265- if ( expanderProperties . Expanded && expanderStacktrace . Expanded )
266- paned . PositionSet = false ;
267- else if ( expanderStacktrace . Expanded )
268- paned . Position = paned . MaxPosition ;
269- else
270- paned . Position = paned . MinPosition ;
271- }
272-
273276 static void StackFrameLayout ( CellLayout layout , CellRenderer cr , TreeModel model , TreeIter iter )
274277 {
275278 var frame = ( ExceptionStackFrame ) model . GetValue ( iter , ( int ) ModelColumn . StackFrame ) ;
@@ -304,7 +307,6 @@ Widget CreateStackTraceTreeView ()
304307 stackTraceTreeView . RowActivated += StackFrameActivated ;
305308
306309 var scrolled = new ScrolledWindow {
307- HeightRequest = 180 ,
308310 HscrollbarPolicy = PolicyType . Never ,
309311 VscrollbarPolicy = PolicyType . Automatic
310312 } ;
@@ -316,10 +318,16 @@ Widget CreateStackTraceTreeView ()
316318 vbox . PackStart ( scrolled , true , true , 0 ) ;
317319 vbox . Show ( ) ;
318320
321+ var label = new Label ( ) ;
322+ label . Markup = "<b>" + GettextCatalog . GetString ( "Stacktrace" ) + "</b>" ;
323+ label . Xalign = 0 ;
324+ label . Xpad = 10 ;
325+
326+ stackTraceTreeView . SetCommonAccessibilityAttributes ( "ExceptionCaughtDialog.StackTraceTreeView" , label , null ) ;
327+
319328 var vbox2 = new VBox ( ) ;
320- expanderStacktrace = WrapInExpander ( GettextCatalog . GetString ( "Stacktrace" ) , vbox ) ;
321- vbox2 . PackStart ( new VBox ( ) , false , false , 5 ) ;
322- vbox2 . PackStart ( expanderStacktrace , true , true , 0 ) ;
329+ vbox2 . PackStart ( label , false , false , 12 ) ;
330+ vbox2 . PackStart ( vbox , true , true , 0 ) ;
323331 vbox2 . ShowAll ( ) ;
324332 return vbox2 ;
325333 }
@@ -371,6 +379,7 @@ void Build ()
371379 paned . GrabAreaSize = 10 ;
372380 paned . Pack1 ( CreateStackTraceTreeView ( ) , true , false ) ;
373381 paned . Pack2 ( CreateExceptionValueTreeView ( ) , true , false ) ;
382+ paned . Position = 160 ;
374383 paned . Show ( ) ;
375384 var vbox = new VBox ( false , 0 ) ;
376385 var whiteBackground = new EventBox ( ) ;
@@ -432,6 +441,7 @@ Widget CreateInnerExceptionMessage ()
432441 innerExceptionTypeLabel . Xalign = 0 ;
433442 innerExceptionTypeLabel . Selectable = true ;
434443 innerExceptionTypeLabel . CanFocus = false ;
444+ icon . SetCommonAccessibilityAttributes ( "ExceptionCaughtDialog.InnerExceptionWarningIcon" , innerExceptionTypeLabel , null ) ;
435445 hbox . PackStart ( innerExceptionTypeLabel , false , true , 4 ) ;
436446
437447 innerExceptionMessageLabel = new Label ( ) ;
@@ -515,6 +525,10 @@ Widget CreateInnerExceptionsTree ()
515525 UpdateSelectedException ( ( ExceptionInfo ) innerExceptionsTreeView . Model . GetValue ( selectedIter , 0 ) ) ;
516526 }
517527 } ;
528+ innerExceptionsTreeView . SetCommonAccessibilityAttributes (
529+ "ExceptionCaughtDialog.InnerExceptionsTreeView" ,
530+ GettextCatalog . GetString ( "Inner Exceptions" ) ,
531+ null ) ;
518532 var eventBox = new EventBox ( ) ;
519533 eventBox . ModifyBg ( StateType . Normal , Styles . ExceptionCaughtDialog . TreeBackgroundColor . ToGdkColor ( ) ) ; // top and bottom padders
520534 var vbox = new VBox ( ) ;
@@ -717,6 +731,7 @@ protected override void OnDestroyed ()
717731
718732 class CellRendererInnerException : CellRenderer
719733 {
734+ [ Property ( "text" ) ] // Enables Voice Over support.
720735 public string Text { get ; set ; }
721736
722737 Pango . FontDescription font = Pango . FontDescription . FromString ( Platform . IsWindows ? "9" : "11" ) ;
0 commit comments