-
-
Save chamons/9d7b43723c78f8747e8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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