Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Xwt.XamMac/Xwt.Mac.CellViews/CanvasTableCell.cs')
-rw-r--r--Xwt.XamMac/Xwt.Mac.CellViews/CanvasTableCell.cs150
1 files changed, 118 insertions, 32 deletions
diff --git a/Xwt.XamMac/Xwt.Mac.CellViews/CanvasTableCell.cs b/Xwt.XamMac/Xwt.Mac.CellViews/CanvasTableCell.cs
index c3703f17..573a3342 100644
--- a/Xwt.XamMac/Xwt.Mac.CellViews/CanvasTableCell.cs
+++ b/Xwt.XamMac/Xwt.Mac.CellViews/CanvasTableCell.cs
@@ -30,19 +30,19 @@ using Xwt.Backends;
namespace Xwt.Mac
{
- class CanvasTableCell: NSCell, ICellRenderer
+ class CanvasTableCell: NSView, ICanvasCellRenderer
{
- bool visible = true;
+ NSTrackingArea trackingArea;
- public CanvasTableCell (IntPtr p): base (p)
- {
- }
+ public CompositeCell CellContainer { get; set; }
- public CanvasTableCell ()
- {
- }
+ public CellViewBackend Backend { get; set; }
- public CompositeCell CellContainer { get; set; }
+ public NSView CellView { get { return this; } }
+
+ // Since 10.12 or 10.13 views inside tables flip on data reload.
+ // IsFlipped enforces the correct orientation of the layer.
+ public override bool IsFlipped { get { return true; } }
public void CopyFrom (object other)
{
@@ -52,46 +52,132 @@ namespace Xwt.Mac
public void Fill ()
{
- visible = Frontend.Visible;
+ Hidden = !Frontend.Visible;
}
ICanvasCellViewFrontend Frontend {
get { return (ICanvasCellViewFrontend) Backend.Frontend; }
}
- public CellViewBackend Backend { get; set; }
-
+ public override CGSize FittingSize {
+ get {
+ var size = CGSize.Empty;
+ Frontend.ApplicationContext.InvokeUserCode (delegate {
+ var s = Frontend.GetRequiredSize (SizeConstraint.Unconstrained);
+ size = new CGSize ((nfloat)s.Width, (nfloat)s.Height);
+ });
+ return size;
+ }
+ }
- public override CGSize CellSizeForBounds (CGRect bounds)
+ public Size GetRequiredSize(SizeConstraint widthConstraint)
{
- if (!visible)
- return CGSize.Empty;
- var size = new CGSize ();
+ var size = Size.Zero;
Frontend.ApplicationContext.InvokeUserCode (delegate {
- var s = Frontend.GetRequiredSize ();
- size = new CGSize ((nfloat)s.Width, (nfloat)s.Height);
+ size = Frontend.GetRequiredSize (widthConstraint);
});
- if (size.Width > bounds.Width)
- size.Width = bounds.Width;
- if (size.Height > bounds.Height)
- size.Height = bounds.Height;
return size;
}
- public override void DrawInteriorWithFrame (CGRect cellFrame, NSView inView)
+ public override void DrawRect (CGRect dirtyRect)
{
- if (!visible)
- return;
- CGContext ctx = NSGraphicsContext.CurrentContext.GraphicsPort;
-
- var backend = new CGContextBackend {
- Context = ctx,
- InverseViewTransform = ctx.GetCTM ().Invert ()
- };
+ Backend.Load (this);
Frontend.ApplicationContext.InvokeUserCode (delegate {
- Frontend.Draw (backend, new Rectangle (cellFrame.X, cellFrame.Y, cellFrame.Width, cellFrame.Height));
+ CGContext ctx = NSGraphicsContext.CurrentContext.GraphicsPort;
+
+ var backend = new CGContextBackend {
+ Context = ctx,
+ InverseViewTransform = ctx.GetCTM ().Invert ()
+ };
+ var bounds = Backend.CellBounds;
+ backend.Context.ClipToRect (dirtyRect);
+ backend.Context.TranslateCTM ((nfloat)(-bounds.X), (nfloat)(-bounds.Y));
+ Frontend.Draw (backend, new Rectangle (bounds.X, bounds.Y, bounds.Width, bounds.Height));
});
}
+
+ public override void UpdateTrackingAreas ()
+ {
+ if (trackingArea != null) {
+ RemoveTrackingArea (trackingArea);
+ trackingArea.Dispose ();
+ }
+ var options = NSTrackingAreaOptions.MouseMoved | NSTrackingAreaOptions.ActiveInKeyWindow | NSTrackingAreaOptions.MouseEnteredAndExited;
+ trackingArea = new NSTrackingArea (Bounds, options, this, null);
+ AddTrackingArea (trackingArea);
+ }
+
+ public override void RightMouseDown (NSEvent theEvent)
+ {
+ if (!this.HandleMouseDown (theEvent))
+ base.RightMouseDown (theEvent);
+ }
+
+ public override void RightMouseUp (NSEvent theEvent)
+ {
+ if (!this.HandleMouseUp (theEvent))
+ base.RightMouseUp (theEvent);
+ }
+
+ public override void MouseDown (NSEvent theEvent)
+ {
+ if (!this.HandleMouseDown (theEvent))
+ base.MouseDown (theEvent);
+ }
+
+ public override void MouseUp (NSEvent theEvent)
+ {
+ if (!this.HandleMouseUp (theEvent))
+ base.MouseUp (theEvent);
+ }
+
+ public override void OtherMouseDown (NSEvent theEvent)
+ {
+ if (!this.HandleMouseDown (theEvent))
+ base.OtherMouseDown (theEvent);
+ }
+
+ public override void OtherMouseUp (NSEvent theEvent)
+ {
+ if (!this.HandleMouseUp (theEvent))
+ base.OtherMouseUp (theEvent);
+ }
+
+ public override void MouseEntered (NSEvent theEvent)
+ {
+ this.HandleMouseEntered (theEvent);
+ base.MouseEntered (theEvent);
+ }
+
+ public override void MouseExited (NSEvent theEvent)
+ {
+ this.HandleMouseExited (theEvent);
+ base.MouseExited (theEvent);
+ }
+
+ public override void MouseMoved (NSEvent theEvent)
+ {
+ if (!this.HandleMouseMoved (theEvent))
+ base.MouseMoved (theEvent);
+ }
+
+ public override void MouseDragged (NSEvent theEvent)
+ {
+ if (!this.HandleMouseMoved (theEvent))
+ base.MouseDragged (theEvent);
+ }
+
+ public override void KeyDown (NSEvent theEvent)
+ {
+ if (!this.HandleKeyDown (theEvent))
+ base.KeyDown (theEvent);
+ }
+
+ public override void KeyUp (NSEvent theEvent)
+ {
+ if (!this.HandleKeyUp (theEvent))
+ base.KeyUp (theEvent);
+ }
}
}