コード例 #1
0
 public EtoSplitView(SplitterHandler handler)
 {
     DividerStyle = NSSplitViewDividerStyle.Thin;
     IsVertical   = true;
     AddSubview(new NSView {
         AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable
     });
     AddSubview(new NSView {
         AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable
     });
     Delegate = new EtoSplitViewDelegate {
         Handler = handler
     };
 }
コード例 #2
0
        static void ResizeSubviews(SplitterHandler handler, CGSize oldSize)
        {
            var splitView        = handler.Control;
            var dividerThickness = splitView.DividerThickness;
            var panel1Rect       = splitView.Subviews[0].Frame;
            var panel2Rect       = splitView.Subviews[1].Frame;
            var newFrame         = splitView.Frame;

            if (oldSize.Height == 0 && oldSize.Width == 0)
            {
                oldSize = newFrame.Size;
            }

            if (splitView.IsVertical)
            {
                panel2Rect.Y      = 0;
                panel2Rect.Height = panel1Rect.Height = newFrame.Height;
                panel1Rect        = new CGRect(CGPoint.Empty, panel1Rect.Size);
                if (handler.position == null)
                {
                    panel1Rect.Width = (nfloat)Math.Max(0, newFrame.Width / 2);
                    panel2Rect.Width = (nfloat)Math.Max(0, newFrame.Width - panel1Rect.Width - dividerThickness);
                }
                else
                {
                    var pos = handler.position.Value;
                    switch (handler.fixedPanel)
                    {
                    case SplitterFixedPanel.Panel1:
                        panel1Rect.Width = (nfloat)Math.Max(0, Math.Min(newFrame.Width - dividerThickness, pos));
                        panel2Rect.Width = (nfloat)Math.Max(0, newFrame.Width - panel1Rect.Width - dividerThickness);
                        break;

                    case SplitterFixedPanel.Panel2:
                        panel2Rect.Width = (nfloat)Math.Max(0, Math.Min(newFrame.Width - dividerThickness, oldSize.Width - pos - dividerThickness));
                        panel1Rect.Width = (nfloat)Math.Max(0, newFrame.Width - panel2Rect.Width - dividerThickness);
                        break;

                    case SplitterFixedPanel.None:
                        var oldscale = newFrame.Width / oldSize.Width;
                        panel1Rect.Width = (nfloat)Math.Max(0, Math.Min(newFrame.Width - dividerThickness, pos * oldscale));
                        panel2Rect.Width = (nfloat)Math.Max(0, newFrame.Width - panel1Rect.Width - dividerThickness);
                        break;
                    }
                }
                panel2Rect.X = (nfloat)Math.Min(panel1Rect.Width + dividerThickness, newFrame.Width);
            }
            else
            {
                panel2Rect.X     = 0;
                panel2Rect.Width = panel1Rect.Width = newFrame.Width;
                panel1Rect       = new CGRect(CGPoint.Empty, panel1Rect.Size);
                if (handler.position == null)
                {
                    panel1Rect.Height = (nfloat)Math.Max(0, newFrame.Height / 2);
                    panel2Rect.Height = (nfloat)Math.Max(0, newFrame.Height - panel1Rect.Height - dividerThickness);
                }
                else
                {
                    var pos = handler.position.Value;
                    switch (handler.fixedPanel)
                    {
                    case SplitterFixedPanel.Panel1:
                        panel1Rect.Height = (nfloat)Math.Max(0, Math.Min(newFrame.Height - dividerThickness, pos));
                        panel2Rect.Height = (nfloat)Math.Max(0, newFrame.Height - panel1Rect.Height - dividerThickness);
                        break;

                    case SplitterFixedPanel.Panel2:
                        panel2Rect.Height = (nfloat)Math.Max(0, Math.Min(newFrame.Height - dividerThickness, oldSize.Height - pos - dividerThickness));
                        panel1Rect.Height = (nfloat)Math.Max(0, newFrame.Height - panel2Rect.Height - dividerThickness);
                        break;

                    case SplitterFixedPanel.None:
                        var oldscale = newFrame.Height / oldSize.Height;
                        panel1Rect.Height = (nfloat)Math.Max(0, Math.Min(newFrame.Height - dividerThickness, pos * oldscale));
                        panel2Rect.Height = (nfloat)Math.Max(0, newFrame.Height - panel1Rect.Height - dividerThickness);
                        break;
                    }
                }
                panel2Rect.Y = (nfloat)Math.Min(panel1Rect.Height + dividerThickness, newFrame.Height);
            }

            splitView.Subviews[0].Frame = panel1Rect;
            splitView.Subviews[1].Frame = panel2Rect;
        }
コード例 #3
0
 public override void Resize(NSSplitView splitView, CGSize oldSize)
 {
     SplitterHandler.ResizeSubviews(Handler, oldSize);
 }