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:
authorJérémie Laval <jeremie.laval@gmail.com>2013-08-19 20:58:40 +0400
committerJérémie Laval <jeremie.laval@gmail.com>2013-08-19 20:59:24 +0400
commit1fac93749a26a0fa904ad20c88b36093b149df5a (patch)
tree7fc7543bdc87b0584504237838e7e0eb5d84c561 /Xwt.Mac
parentac711c69e325cf2ebc91349c218e86754077ed7f (diff)
[Xwt.Mac] Add embed backend for NSView
Diffstat (limited to 'Xwt.Mac')
-rw-r--r--Xwt.Mac/Xwt.Mac.csproj1
-rw-r--r--Xwt.Mac/Xwt.Mac/EmbedNativeWidgetBackend.cs50
-rw-r--r--Xwt.Mac/Xwt.Mac/MacEngine.cs1
3 files changed, 52 insertions, 0 deletions
diff --git a/Xwt.Mac/Xwt.Mac.csproj b/Xwt.Mac/Xwt.Mac.csproj
index 0c250b49..7847cce8 100644
--- a/Xwt.Mac/Xwt.Mac.csproj
+++ b/Xwt.Mac/Xwt.Mac.csproj
@@ -121,6 +121,7 @@
<Compile Include="Xwt.Mac\DatePickerBackend.cs" />
<Compile Include="Xwt.Mac\SliderBackend.cs" />
<Compile Include="Xwt.Mac.CellViews\CheckBoxTableCell.cs" />
+ <Compile Include="Xwt.Mac\EmbedNativeWidgetBackend.cs" />
</ItemGroup>
<Import Project="..\BuildHelpers.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
diff --git a/Xwt.Mac/Xwt.Mac/EmbedNativeWidgetBackend.cs b/Xwt.Mac/Xwt.Mac/EmbedNativeWidgetBackend.cs
new file mode 100644
index 00000000..ba291fdc
--- /dev/null
+++ b/Xwt.Mac/Xwt.Mac/EmbedNativeWidgetBackend.cs
@@ -0,0 +1,50 @@
+using System;
+using Xwt.Backends;
+using MonoMac.AppKit;
+using MonoMac.Foundation;
+
+using MonoMac.ObjCRuntime;
+using Xwt.Drawing;
+
+namespace Xwt.Mac
+{
+ public class EmbedNativeWidgetBackend : ViewBackend, IEmbeddedWidgetBackend
+ {
+ NSView innerView;
+
+ public EmbedNativeWidgetBackend ()
+ {
+
+ }
+
+ public override void Initialize ()
+ {
+ ViewObject = new WidgetView (EventSink, ApplicationContext);
+ if (innerView != null) {
+ var aView = innerView;
+ innerView = null;
+ SetNativeView (aView);
+ }
+ }
+
+ public void SetContent (object nativeWidget)
+ {
+ if (nativeWidget is NSView) {
+ if (ViewObject == null)
+ innerView = (NSView)nativeWidget;
+ else
+ SetNativeView ((NSView)nativeWidget);
+ }
+ }
+
+ void SetNativeView (NSView aView)
+ {
+ if (innerView != null)
+ innerView.RemoveFromSuperview ();
+ innerView = aView;
+ innerView.Frame = Widget.Bounds;
+ Widget.AddSubview (innerView);
+ }
+ }
+}
+
diff --git a/Xwt.Mac/Xwt.Mac/MacEngine.cs b/Xwt.Mac/Xwt.Mac/MacEngine.cs
index 1f0e503f..de6b372b 100644
--- a/Xwt.Mac/Xwt.Mac/MacEngine.cs
+++ b/Xwt.Mac/Xwt.Mac/MacEngine.cs
@@ -119,6 +119,7 @@ namespace Xwt.Mac
RegisterBackend <Xwt.Backends.IScrollbarBackend, ScrollbarBackend> ();
RegisterBackend <Xwt.Backends.IDatePickerBackend, DatePickerBackend> ();
RegisterBackend <Xwt.Backends.ISliderBackend, SliderBackend> ();
+ RegisterBackend <Xwt.Backends.IEmbeddedWidgetBackend, EmbedNativeWidgetBackend> ();
}
public override void RunApplication ()