Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
using System.Drawing;
using MonoMac.CoreGraphics;
namespace MoreMacHacking
{
public class MyDel : NSSplitViewDelegate
{
readonly int[] MIN_WIDTH_PANE = {219, 300};
public override bool ShouldAdjustSize (NSSplitView splitView, NSView view)
{
if (view == splitView.Subviews [0])
return false;
else
return (view.Frame.Size.Width > MIN_WIDTH_PANE [1]);
}
public override float SetMinCoordinateOfSubview (NSSplitView splitView, float proposedMinimumPosition, int subviewDividerIndex)
{
if (subviewDividerIndex != 0)
throw new System.NotImplementedException ();
return MIN_WIDTH_PANE [subviewDividerIndex];
}
}
public partial class MainWindow : MonoMac.AppKit.NSWindow
{
#region Constructors
// Called when created from unmanaged code
public MainWindow (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public MainWindow (NSCoder coder) : base (coder)
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
public override void AwakeFromNib ()
{
base.AwakeFromNib ();
NSView lhs = new NSView (new RectangleF (0, 0, 100, 100));
lhs.WantsLayer = true;
lhs.Layer.BackgroundColor = NSColor.Red.CGColor;
NSView rhs = new NSView (new RectangleF (0, 0, 100, 100));
rhs.WantsLayer = true;
rhs.Layer.BackgroundColor = NSColor.Blue.CGColor;
NSView mhs = new NSView (new RectangleF (0, 0, 100, 100));
mhs.WantsLayer = true;
mhs.Layer.BackgroundColor = NSColor.Orange.CGColor;
NSSplitView view = new NSSplitView (this.ContentView.Frame);
view.AddSubview (lhs);
view.AddSubview (mhs);
view.AddSubview (rhs);
view.AdjustSubviews ();
view.Delegate = new MyDel ();
ContentView.AddSubview (view);
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.