diff --git a/GtkTest/GtkTest.csproj b/GtkTest/GtkTest.csproj index fccb509e..c03009c2 100644 --- a/GtkTest/GtkTest.csproj +++ b/GtkTest/GtkTest.csproj @@ -37,6 +37,8 @@ prompt true false + 4 + false bin\x86\Release\ @@ -45,6 +47,9 @@ false false false + none + 4 + false diff --git a/WpfTest/WpfTest.csproj b/WpfTest/WpfTest.csproj index b7825a0e..ee89f8f2 100644 --- a/WpfTest/WpfTest.csproj +++ b/WpfTest/WpfTest.csproj @@ -2,7 +2,7 @@ Debug - x86 + AnyCPU 8.0.30703 2.0 {E41F4448-15C3-4E95-B310-FD333FDF5D2F} @@ -10,7 +10,6 @@ Properties WpfTest WpfTest - v4.0 Client 512 @@ -24,6 +23,8 @@ false false false + 4 + false bin\Release\ @@ -33,6 +34,7 @@ AnyCPU prompt true + 4 true @@ -44,6 +46,8 @@ false false false + 4 + false bin\x86\Release\ @@ -55,6 +59,7 @@ true true true + 4 diff --git a/Xwt.sln b/Xwt.sln index 377b478a..41c88cc4 100644 --- a/Xwt.sln +++ b/Xwt.sln @@ -24,23 +24,12 @@ Global Win-Debug|Any CPU = Win-Debug|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU - {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU - {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Release|Any CPU.Build.0 = Release|Any CPU - {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU - {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Win-Debug|Any CPU.Build.0 = Debug|Any CPU - {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU - {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Release|Any CPU.Build.0 = Release|Any CPU - {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Win-Debug|Any CPU.Build.0 = Debug|Any CPU - {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU - {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Release|Any CPU.Build.0 = Release|Any CPU - {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU + {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Release|Any CPU.Build.0 = Release|Any CPU + {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Win-Debug|Any CPU.ActiveCfg = Debug|x86 + {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Win-Debug|Any CPU.Build.0 = Debug|x86 {2B7FF081-FE53-42F7-9D5D-D4B38E548F94}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU {2B7FF081-FE53-42F7-9D5D-D4B38E548F94}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU {2B7FF081-FE53-42F7-9D5D-D4B38E548F94}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -53,14 +42,26 @@ Global {88C04B85-B69B-47B4-AB9F-64F6DD4E0897}.Release|Any CPU.Build.0 = Release|Any CPU {88C04B85-B69B-47B4-AB9F-64F6DD4E0897}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU {88C04B85-B69B-47B4-AB9F-64F6DD4E0897}.Win-Debug|Any CPU.Build.0 = Debug|Any CPU - {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU - {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Release|Any CPU.Build.0 = Release|Any CPU - {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Win-Debug|Any CPU.ActiveCfg = Debug|x86 - {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Win-Debug|Any CPU.Build.0 = Debug|x86 + {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU + {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Release|Any CPU.Build.0 = Release|Any CPU + {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Win-Debug|Any CPU.Build.0 = Debug|Any CPU + {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU + {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Release|Any CPU.Build.0 = Release|Any CPU + {B7C1673E-5124-4BE5-8D21-EC8B12F85B6B}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU + {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Release|Any CPU.Build.0 = Release|Any CPU + {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.Win-Debug|Any CPU.Build.0 = Debug|Any CPU {C93D746E-1586-4D4F-B411-BF5A966E6A08}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU {C93D746E-1586-4D4F-B411-BF5A966E6A08}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C93D746E-1586-4D4F-B411-BF5A966E6A08}.Release|Any CPU.Build.0 = Release|Any CPU {C93D746E-1586-4D4F-B411-BF5A966E6A08}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU {C93D746E-1586-4D4F-B411-BF5A966E6A08}.Win-Debug|Any CPU.Build.0 = Debug|Any CPU {E41F4448-15C3-4E95-B310-FD333FDF5D2F}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -69,9 +70,6 @@ Global {E41F4448-15C3-4E95-B310-FD333FDF5D2F}.Win-Debug|Any CPU.ActiveCfg = Debug|x86 {E41F4448-15C3-4E95-B310-FD333FDF5D2F}.Win-Debug|Any CPU.Build.0 = Debug|x86 EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = GtkTest\GtkTest.csproj Policies = $0 @@ -84,4 +82,7 @@ Global $3.Text = @\n${FileName}\n \nAuthor:\n ${AuthorName} <${AuthorEmail}>\n\nCopyright (c) ${Year} ${CopyrightHolder}\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE. $3.IncludeInNewFiles = True EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection EndGlobal diff --git a/Xwt/Xwt.Backends/BackendHost.cs b/Xwt/Xwt.Backends/BackendHost.cs index 4b6e9de0..ae50489e 100644 --- a/Xwt/Xwt.Backends/BackendHost.cs +++ b/Xwt/Xwt.Backends/BackendHost.cs @@ -29,20 +29,20 @@ using Xwt.Engine; namespace Xwt.Backends { - public class BackendHost: BackendHost + public class BackendHost: BackendHost where B:IBackend { public BackendHost () { } - protected BackendHost (IBackend backend): base (backend) - { - } - public new T Parent { get { return (T)base.Parent; } set { base.Parent = value; } } + + public new B Backend { + get { return (B)base.Backend; } + } } public class BackendHost @@ -56,7 +56,7 @@ namespace Xwt.Backends { } - protected BackendHost (IBackend backend) + public void SetCustomBackend (IBackend backend) { this.backend = backend; usingCustomBackend = true; @@ -115,11 +115,6 @@ namespace Xwt.Backends } } - protected static void MapEvent (object eventId, Type type, string methodName) - { - EventUtil.MapEvent (eventId, type, methodName); - } - public void OnBeforeEventAdd (object eventId, Delegate eventDelegate) { if (eventDelegate == null && !DefaultEnabledEvents.Contains (eventId)) diff --git a/Xwt/Xwt.Engine/WidgetRegistry.cs b/Xwt/Xwt.Engine/WidgetRegistry.cs index d97cbece..42431710 100755 --- a/Xwt/Xwt.Engine/WidgetRegistry.cs +++ b/Xwt/Xwt.Engine/WidgetRegistry.cs @@ -93,16 +93,9 @@ namespace Xwt.Backends class NativeWindowFrame: WindowFrame { - IWindowFrameBackend backend; - public NativeWindowFrame (IWindowFrameBackend backend) { - this.backend = backend; - } - - protected override WindowBackendHost CreateBackendHost () - { - return new WindowBackendHost (backend); + BackendHost.SetCustomBackend (backend); } } diff --git a/Xwt/Xwt/Box.cs b/Xwt/Xwt/Box.cs index ae8f386d..edcc0640 100755 --- a/Xwt/Xwt/Box.cs +++ b/Xwt/Xwt/Box.cs @@ -63,7 +63,7 @@ namespace Xwt } } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/Button.cs b/Xwt/Xwt/Button.cs index 1d689fdd..cecd21a7 100755 --- a/Xwt/Xwt/Button.cs +++ b/Xwt/Xwt/Button.cs @@ -78,7 +78,7 @@ namespace Xwt Image = img; } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/Canvas.cs b/Xwt/Xwt/Canvas.cs index fe056e19..80adb019 100644 --- a/Xwt/Xwt/Canvas.cs +++ b/Xwt/Xwt/Canvas.cs @@ -213,7 +213,7 @@ namespace Xwt return Rectangle.Zero; } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/CheckBox.cs b/Xwt/Xwt/CheckBox.cs index 38aa1ee3..3df0d50e 100644 --- a/Xwt/Xwt/CheckBox.cs +++ b/Xwt/Xwt/CheckBox.cs @@ -62,7 +62,7 @@ namespace Xwt Label = label; } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/ComboBox.cs b/Xwt/Xwt/ComboBox.cs index 87465b1a..82dd245b 100644 --- a/Xwt/Xwt/ComboBox.cs +++ b/Xwt/Xwt/ComboBox.cs @@ -66,7 +66,7 @@ namespace Xwt views = new CellViewCollection ((ICellContainer)BackendHost); } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/ComboBoxEntry.cs b/Xwt/Xwt/ComboBoxEntry.cs index fb56ed0a..6a3ffa54 100644 --- a/Xwt/Xwt/ComboBoxEntry.cs +++ b/Xwt/Xwt/ComboBoxEntry.cs @@ -47,7 +47,7 @@ namespace Xwt entry = new CustomComboTextEntry (Backend.TextEntryBackend); } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/Dialog.cs b/Xwt/Xwt/Dialog.cs index 5702ae97..91b9b4b7 100644 --- a/Xwt/Xwt/Dialog.cs +++ b/Xwt/Xwt/Dialog.cs @@ -69,7 +69,7 @@ namespace Xwt } } - protected override WindowFrame.WindowBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WindowBackendHost (); } diff --git a/Xwt/Xwt/FileDialog.cs b/Xwt/Xwt/FileDialog.cs index ec53bdc3..068ade85 100644 --- a/Xwt/Xwt/FileDialog.cs +++ b/Xwt/Xwt/FileDialog.cs @@ -41,11 +41,12 @@ namespace Xwt string fileName; string[] fileNames = new string[0]; - BackendHost backendHost = new BackendHost (); + BackendHost backendHost; internal FileDialog () { filters = new FileDialogFilterCollection (AddRemoveItem); + backendHost = new BackendHost (); backendHost.Parent = this; } @@ -55,7 +56,7 @@ namespace Xwt } IFileDialogBackend Backend { - get { return (IFileDialogBackend) backendHost.Backend; } + get { return backendHost.Backend; } } void AddRemoveItem (FileDialogFilter filter, bool added) diff --git a/Xwt/Xwt/Frame.cs b/Xwt/Xwt/Frame.cs index 50f757cf..18f747aa 100644 --- a/Xwt/Xwt/Frame.cs +++ b/Xwt/Xwt/Frame.cs @@ -55,7 +55,7 @@ namespace Xwt } } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/ListBox.cs b/Xwt/Xwt/ListBox.cs index ebeee48f..eae2b4e8 100644 --- a/Xwt/Xwt/ListBox.cs +++ b/Xwt/Xwt/ListBox.cs @@ -67,7 +67,7 @@ namespace Xwt views = new CellViewCollection ((ICellContainer)BackendHost); } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/ListStore.cs b/Xwt/Xwt/ListStore.cs index f32f702d..0070cb58 100644 --- a/Xwt/Xwt/ListStore.cs +++ b/Xwt/Xwt/ListStore.cs @@ -35,15 +35,12 @@ namespace Xwt { DataField[] fields; - class ListStoreBackendHost: BackendHost + class ListStoreBackendHost: BackendHost { - protected override IBackend OnCreateBackend () + protected override void OnBackendCreated () { - IBackend b = base.OnCreateBackend (); - if (b == null) - b = new DefaultListStoreBackend (); - ((IListStoreBackend)b).Initialize (Parent.fields.Select (f => f.FieldType).ToArray ()); - return b; + Backend.Initialize (Parent.fields.Select (f => f.FieldType).ToArray ()); + base.OnBackendCreated (); } } diff --git a/Xwt/Xwt/ListView.cs b/Xwt/Xwt/ListView.cs index 0d4a8768..26063de9 100644 --- a/Xwt/Xwt/ListView.cs +++ b/Xwt/Xwt/ListView.cs @@ -71,7 +71,7 @@ namespace Xwt VerticalScrollPolicy = HorizontalScrollPolicy = ScrollPolicy.Automatic; } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/MenuButton.cs b/Xwt/Xwt/MenuButton.cs index 73951dbe..9d887bcc 100644 --- a/Xwt/Xwt/MenuButton.cs +++ b/Xwt/Xwt/MenuButton.cs @@ -65,7 +65,7 @@ namespace Xwt Image = img; } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/MenuItem.cs b/Xwt/Xwt/MenuItem.cs index 224fa8fb..7a6ef47a 100644 --- a/Xwt/Xwt/MenuItem.cs +++ b/Xwt/Xwt/MenuItem.cs @@ -38,12 +38,12 @@ namespace Xwt EventHandler clicked; Image image; - protected class MenuItemBackendHost: BackendHost, IMenuItemEventSink + protected class MenuItemBackendHost: BackendHost, IMenuItemEventSink { protected override void OnBackendCreated () { base.OnBackendCreated (); - ((IMenuItemBackend)Backend).Initialize (this); + Backend.Initialize (this); } public void OnClicked () diff --git a/Xwt/Xwt/Notebook.cs b/Xwt/Xwt/Notebook.cs index f768713d..b53f40fe 100755 --- a/Xwt/Xwt/Notebook.cs +++ b/Xwt/Xwt/Notebook.cs @@ -74,7 +74,7 @@ namespace Xwt tabs = new ChildrenCollection ((WidgetBackendHost) BackendHost); } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/Paned.cs b/Xwt/Xwt/Paned.cs index df913ed4..3993da0a 100755 --- a/Xwt/Xwt/Paned.cs +++ b/Xwt/Xwt/Paned.cs @@ -85,7 +85,7 @@ namespace Xwt panel2 = new Panel ((WidgetBackendHost)BackendHost, 2); } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/ScrollAdjustment.cs b/Xwt/Xwt/ScrollAdjustment.cs index 2362ebb1..d7ac9127 100644 --- a/Xwt/Xwt/ScrollAdjustment.cs +++ b/Xwt/Xwt/ScrollAdjustment.cs @@ -32,23 +32,23 @@ namespace Xwt { EventHandler valueChanged; - class BackendHost: BackendHost, IScrollAdjustmentEventSink + class ScrollAdjustmentBackendHost: BackendHost, IScrollAdjustmentEventSink { protected override void OnBackendCreated () { base.OnBackendCreated (); - Backend.Initialize (new EventSink () { Parent = this }); + Backend.Initialize (this); } public void OnValueChanged () { - ((IScrollAdjustmentBackend)Parent).OnValueChanged (EventArgs.Empty); + Parent.OnValueChanged (EventArgs.Empty); } } protected override Xwt.Backends.BackendHost CreateBackendHost () { - return new ScrollAdjustment.BackendHost (); + return new ScrollAdjustmentBackendHost (); } static ScrollAdjustment () @@ -66,11 +66,12 @@ namespace Xwt PageIncrement = 10; } - internal ScrollAdjustment (IBackend backend): base (backend) + internal ScrollAdjustment (IBackend backend) { + BackendHost.SetCustomBackend (backend); } - new IScrollAdjustmentBackend Backend { + IScrollAdjustmentBackend Backend { get { return (IScrollAdjustmentBackend) BackendHost.Backend; } } @@ -140,12 +141,12 @@ namespace Xwt public event EventHandler ValueChanged { add { - OnBeforeEventAdd (ScrollAdjustmentEvent.ValueChanged, valueChanged); + BackendHost.OnBeforeEventAdd (ScrollAdjustmentEvent.ValueChanged, valueChanged); valueChanged += value; } remove { valueChanged -= value; - OnAfterEventRemove (ScrollAdjustmentEvent.ValueChanged, valueChanged); + BackendHost.OnAfterEventRemove (ScrollAdjustmentEvent.ValueChanged, valueChanged); } } } diff --git a/Xwt/Xwt/ScrollView.cs b/Xwt/Xwt/ScrollView.cs index b49ebbe9..614a3cea 100644 --- a/Xwt/Xwt/ScrollView.cs +++ b/Xwt/Xwt/ScrollView.cs @@ -46,7 +46,7 @@ namespace Xwt } } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/SelectFolderDialog.cs b/Xwt/Xwt/SelectFolderDialog.cs index f89a2360..b00a5ed2 100644 --- a/Xwt/Xwt/SelectFolderDialog.cs +++ b/Xwt/Xwt/SelectFolderDialog.cs @@ -46,8 +46,8 @@ namespace Xwt this.title = title; } - new ISelectFolderDialogBackend Backend { - get { return (ISelectFolderDialogBackend) base.Backend; } + ISelectFolderDialogBackend Backend { + get { return (ISelectFolderDialogBackend) BackendHost.Backend; } } public string Title { diff --git a/Xwt/Xwt/Separator.cs b/Xwt/Xwt/Separator.cs index 3756babf..1d9de79d 100644 --- a/Xwt/Xwt/Separator.cs +++ b/Xwt/Xwt/Separator.cs @@ -42,7 +42,7 @@ namespace Xwt } } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/Table.cs b/Xwt/Xwt/Table.cs index ddbacd3d..b0fed40d 100755 --- a/Xwt/Xwt/Table.cs +++ b/Xwt/Xwt/Table.cs @@ -65,7 +65,7 @@ namespace Xwt } } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/TextEntry.cs b/Xwt/Xwt/TextEntry.cs index 61c5ad5a..67b45543 100644 --- a/Xwt/Xwt/TextEntry.cs +++ b/Xwt/Xwt/TextEntry.cs @@ -55,7 +55,7 @@ namespace Xwt { } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/ToggleButton.cs b/Xwt/Xwt/ToggleButton.cs index 8a4f78fd..7e74c087 100644 --- a/Xwt/Xwt/ToggleButton.cs +++ b/Xwt/Xwt/ToggleButton.cs @@ -62,7 +62,7 @@ namespace Xwt { } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/TreeStore.cs b/Xwt/Xwt/TreeStore.cs index 2c7e403e..fc68dd40 100644 --- a/Xwt/Xwt/TreeStore.cs +++ b/Xwt/Xwt/TreeStore.cs @@ -37,15 +37,12 @@ namespace Xwt { DataField[] fields; - class TreeStoreBackendHost: BackendHost + class TreeStoreBackendHost: BackendHost { - protected override IBackend OnCreateBackend () + protected override void OnBackendCreated () { - IBackend b = base.OnCreateBackend (); - if (b == null) - b = new DefaultTreeStoreBackend (); - ((ITreeStoreBackend)b).Initialize (Parent.fields.Select (f => f.FieldType).ToArray ()); - return b; + Backend.Initialize (Parent.fields.Select (f => f.FieldType).ToArray ()); + base.OnBackendCreated (); } } diff --git a/Xwt/Xwt/TreeView.cs b/Xwt/Xwt/TreeView.cs index 1da01ce0..afeac3d9 100755 --- a/Xwt/Xwt/TreeView.cs +++ b/Xwt/Xwt/TreeView.cs @@ -84,7 +84,7 @@ namespace Xwt DataSource = source; } - protected override Widget.WidgetBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WidgetBackendHost (); } diff --git a/Xwt/Xwt/Widget.cs b/Xwt/Xwt/Widget.cs index fcaa34d5..3047ee4a 100755 --- a/Xwt/Xwt/Widget.cs +++ b/Xwt/Xwt/Widget.cs @@ -36,7 +36,7 @@ using System.Linq; namespace Xwt { - public abstract class Widget: Component, IWidgetSurface, IFrontend + public abstract class Widget: XwtComponent, IWidgetSurface { static Widget[] emptyList = new Widget[0]; List children; @@ -45,7 +45,6 @@ namespace Xwt WidgetSize height; bool widthCached; bool heightCached; - WidgetBackendHost backendHost; DragOperation currentDragOperation; Widget contentWidget; WindowFrame parentWindow; @@ -82,16 +81,12 @@ namespace Xwt } } - protected class WidgetBackendHost: BackendHost, IWidgetEventSink, ISpacingListener + protected class WidgetBackendHost: BackendHost, IWidgetEventSink, ISpacingListener { public WidgetBackendHost () { } - public WidgetBackendHost (IBackend backend): base (backend) - { - } - protected override IBackend OnCreateBackend () { var backend = base.OnCreateBackend (); @@ -263,9 +258,9 @@ namespace Xwt public Widget () { - backendHost = CreateBackendHost (); - backendHost.Parent = this; - margin = new Xwt.WidgetSpacing (backendHost); + if (!(base.BackendHost is WidgetBackendHost)) + throw new InvalidOperationException ("CreateBackendHost for Widget did not return a WidgetBackendHost instance"); + margin = new Xwt.WidgetSpacing (BackendHost); } static Widget () @@ -292,16 +287,20 @@ namespace Xwt MapEvent (WidgetEvent.PreferredWidthForHeightCheck, typeof (Widget), "OnGetPreferredWidthForHeight"); } - protected static void MapEvent (object eventId, Type type, string methodName) - { - EventUtil.MapEvent (eventId, type, methodName); - } - internal protected static IBackend GetBackend (Widget w) { return w != null ? w.Backend : null; } + protected new WidgetBackendHost BackendHost { + get { return (WidgetBackendHost) base.BackendHost; } + } + + protected override Xwt.Backends.BackendHost CreateBackendHost () + { + return new WidgetBackendHost (); + } + protected override void Dispose (bool disposing) { base.Dispose (disposing); @@ -330,21 +329,17 @@ namespace Xwt parentWindow = win; } - protected virtual WidgetBackendHost CreateBackendHost () +/* protected virtual WidgetBackendHost CreateBackendHost () { return new WidgetBackendHost (); } protected WidgetBackendHost BackendHost { get { return backendHost; } - } + }*/ IWidgetBackend Backend { - get { return (IWidgetBackend) backendHost.Backend; } - } - - object IFrontend.Backend { - get { return Backend; } + get { return (IWidgetBackend) BackendHost.Backend; } } public WidgetSpacing Margin { diff --git a/Xwt/Xwt/Window.cs b/Xwt/Xwt/Window.cs index 5c7c1029..956d2329 100755 --- a/Xwt/Xwt/Window.cs +++ b/Xwt/Xwt/Window.cs @@ -45,7 +45,7 @@ namespace Xwt } } - protected override WindowFrame.WindowBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WindowBackendHost (); } diff --git a/Xwt/Xwt/WindowFrame.cs b/Xwt/Xwt/WindowFrame.cs index bb09d561..49049f4d 100644 --- a/Xwt/Xwt/WindowFrame.cs +++ b/Xwt/Xwt/WindowFrame.cs @@ -56,30 +56,20 @@ using System.ComponentModel; namespace Xwt { - public class WindowFrame: Component + public class WindowFrame: XwtComponent { EventHandler boundsChanged; Rectangle bounds; - WindowBackendHost backendHost; bool pendingReallocation; - protected class WindowBackendHost: BackendHost, IWindowFrameEventSink + protected class WindowBackendHost: BackendHost, IWindowFrameEventSink { - public WindowBackendHost () - { - } - - public WindowBackendHost (IBackend backend): base (backend) - { - } - protected override void OnBackendCreated () { base.OnBackendCreated (); - var b = (IWindowFrameBackend)Backend; - b.Initialize (this); - Parent.bounds = b.Bounds; - b.EnableEvent (WindowFrameEvent.BoundsChanged); + Backend.Initialize (this); + Parent.bounds = Backend.Bounds; + Backend.EnableEvent (WindowFrameEvent.BoundsChanged); } public void OnBoundsChanged (Rectangle bounds) @@ -90,8 +80,8 @@ namespace Xwt public WindowFrame () { - backendHost = CreateBackendHost (); - backendHost.Parent = this; + if (!(base.BackendHost is WindowBackendHost)) + throw new InvalidOperationException ("CreateBackendHost for WindowFrame did not return a WindowBackendHost instance"); } public WindowFrame (string title): this () @@ -113,13 +103,13 @@ namespace Xwt get { return (IWindowFrameBackend) BackendHost.Backend; } } - protected virtual WindowBackendHost CreateBackendHost () + protected override BackendHost CreateBackendHost () { return new WindowBackendHost (); } - protected WindowBackendHost BackendHost { - get { return backendHost; } + protected new WindowBackendHost BackendHost { + get { return (WindowBackendHost) base.BackendHost; } } public Rectangle ScreenBounds { diff --git a/Xwt/Xwt/XwtComponent.cs b/Xwt/Xwt/XwtComponent.cs index 7da511f2..c9ce05af 100755 --- a/Xwt/Xwt/XwtComponent.cs +++ b/Xwt/Xwt/XwtComponent.cs @@ -33,103 +33,6 @@ using Xwt.Backends; namespace Xwt { -/* public abstract class XwtComponent: Component, IFrontend - { - IBackend backend; - bool usingCustomBackend; - - HashSet defaultEnabledEvents; - - public XwtComponent () - { - } - - protected XwtComponent (IBackend backend) - { - this.backend = backend; - usingCustomBackend = true; - } - - protected IBackend Backend { - get { - LoadBackend (); - return backend; - } - } - - object IFrontend.Backend { - get { return Backend; } - } - - internal bool BackendCreated { - get { return backend != null; } - } - - protected virtual void OnBackendCreated () - { - foreach (var ev in DefaultEnabledEvents) - Backend.EnableEvent (ev); - } - - protected virtual IBackend OnCreateBackend () - { - Type t = GetType (); - while (t != typeof(XwtComponent)) { - IBackend b = WidgetRegistry.CreateBackend (t); - if (b != null) - return b; - t = t.BaseType; - } - return null; - } - - protected void LoadBackend () - { - if (usingCustomBackend) { - usingCustomBackend = false; - backend.InitializeBackend (this); - OnBackendCreated (); - } - else if (backend == null) { - backend = OnCreateBackend (); - if (backend == null) - throw new InvalidOperationException ("No backend found for widget: " + GetType ()); - backend.InitializeBackend (this); - OnBackendCreated (); - } - } - - internal static IBackend GetBackend (XwtComponent w) - { - return w != null ? w.Backend : null; - } - - protected static void MapEvent (object eventId, Type type, string methodName) - { - EventUtil.MapEvent (eventId, type, methodName); - } - - protected void OnBeforeEventAdd (object eventId, Delegate eventDelegate) - { - if (eventDelegate == null && !DefaultEnabledEvents.Contains (eventId)) - Backend.EnableEvent (eventId); - } - - protected void OnAfterEventRemove (object eventId, Delegate eventDelegate) - { - if (eventDelegate != null && !DefaultEnabledEvents.Contains (eventId)) - Backend.DisableEvent (eventId); - } - - internal HashSet DefaultEnabledEvents { - get { - if (defaultEnabledEvents == null) - defaultEnabledEvents = EventUtil.GetDefaultEnabledEvents (GetType ()); - return defaultEnabledEvents; - } - } - } - */ public abstract class XwtComponent: Component, IFrontend { BackendHost backendHost;