Use XwtComponent as base class for Widget and WindowFrame

This commit is contained in:
Lluis Sanchez 2012-04-04 01:44:45 +02:00
Родитель c6da836444
Коммит dff0a2b16f
34 изменённых файлов: 117 добавлений и 234 удалений

Просмотреть файл

@ -37,6 +37,8 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets> <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules> <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath> <OutputPath>bin\x86\Release\</OutputPath>
@ -45,6 +47,9 @@
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets> <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules> <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
<DebugType>none</DebugType>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

Просмотреть файл

@ -2,7 +2,7 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion> <ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E41F4448-15C3-4E95-B310-FD333FDF5D2F}</ProjectGuid> <ProjectGuid>{E41F4448-15C3-4E95-B310-FD333FDF5D2F}</ProjectGuid>
@ -10,7 +10,6 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WpfTest</RootNamespace> <RootNamespace>WpfTest</RootNamespace>
<AssemblyName>WpfTest</AssemblyName> <AssemblyName>WpfTest</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
@ -24,6 +23,8 @@
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets> <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules> <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
@ -33,6 +34,7 @@
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisFailOnMissingRules>true</CodeAnalysisFailOnMissingRules> <CodeAnalysisFailOnMissingRules>true</CodeAnalysisFailOnMissingRules>
<WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -44,6 +46,8 @@
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets> <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules> <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath> <OutputPath>bin\x86\Release\</OutputPath>
@ -55,6 +59,7 @@
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets> <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules> <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>true</CodeAnalysisFailOnMissingRules> <CodeAnalysisFailOnMissingRules>true</CodeAnalysisFailOnMissingRules>
<WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Samples\Samples.csproj"> <ProjectReference Include="..\Samples\Samples.csproj">

53
Xwt.sln
Просмотреть файл

@ -24,23 +24,12 @@ Global
Win-Debug|Any CPU = Win-Debug|Any CPU Win-Debug|Any CPU = Win-Debug|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU
{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Release|Any CPU.Build.0 = Release|Any CPU {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Release|Any CPU.Build.0 = Release|Any CPU
{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Win-Debug|Any CPU.ActiveCfg = Debug|x86
{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Win-Debug|Any CPU.Build.0 = Debug|Any CPU {0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Win-Debug|Any CPU.Build.0 = Debug|x86
{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
{2B7FF081-FE53-42F7-9D5D-D4B38E548F94}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU {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}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU
{2B7FF081-FE53-42F7-9D5D-D4B38E548F94}.Release|Any CPU.ActiveCfg = Release|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}.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.ActiveCfg = Debug|Any CPU
{88C04B85-B69B-47B4-AB9F-64F6DD4E0897}.Win-Debug|Any CPU.Build.0 = 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 {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Mac-Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Mac-Debug|Any CPU.Build.0 = Debug|Any CPU
{0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Release|Any CPU.ActiveCfg = Release|Any CPU {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Release|Any CPU.Build.0 = Release|Any CPU {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Release|Any CPU.Build.0 = Release|Any CPU
{0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Win-Debug|Any CPU.ActiveCfg = Debug|x86 {92494904-35FA-4DC9-BDE9-3A3E87AC49D3}.Win-Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0AF50CE4-E455-4A9D-92AD-711CBD068A55}.Win-Debug|Any CPU.Build.0 = Debug|x86 {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}.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.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.ActiveCfg = Debug|Any CPU
{C93D746E-1586-4D4F-B411-BF5A966E6A08}.Win-Debug|Any CPU.Build.0 = 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 {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.ActiveCfg = Debug|x86
{E41F4448-15C3-4E95-B310-FD333FDF5D2F}.Win-Debug|Any CPU.Build.0 = Debug|x86 {E41F4448-15C3-4E95-B310-FD333FDF5D2F}.Win-Debug|Any CPU.Build.0 = Debug|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = GtkTest\GtkTest.csproj StartupItem = GtkTest\GtkTest.csproj
Policies = $0 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.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 $3.IncludeInNewFiles = True
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal EndGlobal

Просмотреть файл

@ -29,20 +29,20 @@ using Xwt.Engine;
namespace Xwt.Backends namespace Xwt.Backends
{ {
public class BackendHost<T>: BackendHost public class BackendHost<T,B>: BackendHost where B:IBackend
{ {
public BackendHost () public BackendHost ()
{ {
} }
protected BackendHost (IBackend backend): base (backend)
{
}
public new T Parent { public new T Parent {
get { return (T)base.Parent; } get { return (T)base.Parent; }
set { base.Parent = value; } set { base.Parent = value; }
} }
public new B Backend {
get { return (B)base.Backend; }
}
} }
public class BackendHost public class BackendHost
@ -56,7 +56,7 @@ namespace Xwt.Backends
{ {
} }
protected BackendHost (IBackend backend) public void SetCustomBackend (IBackend backend)
{ {
this.backend = backend; this.backend = backend;
usingCustomBackend = true; 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) public void OnBeforeEventAdd (object eventId, Delegate eventDelegate)
{ {
if (eventDelegate == null && !DefaultEnabledEvents.Contains (eventId)) if (eventDelegate == null && !DefaultEnabledEvents.Contains (eventId))

Просмотреть файл

@ -93,16 +93,9 @@ namespace Xwt.Backends
class NativeWindowFrame: WindowFrame class NativeWindowFrame: WindowFrame
{ {
IWindowFrameBackend backend;
public NativeWindowFrame (IWindowFrameBackend backend) public NativeWindowFrame (IWindowFrameBackend backend)
{ {
this.backend = backend; BackendHost.SetCustomBackend (backend);
}
protected override WindowBackendHost CreateBackendHost ()
{
return new WindowBackendHost (backend);
} }
} }

Просмотреть файл

@ -63,7 +63,7 @@ namespace Xwt
} }
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -78,7 +78,7 @@ namespace Xwt
Image = img; Image = img;
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -213,7 +213,7 @@ namespace Xwt
return Rectangle.Zero; return Rectangle.Zero;
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -62,7 +62,7 @@ namespace Xwt
Label = label; Label = label;
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -66,7 +66,7 @@ namespace Xwt
views = new CellViewCollection ((ICellContainer)BackendHost); views = new CellViewCollection ((ICellContainer)BackendHost);
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -47,7 +47,7 @@ namespace Xwt
entry = new CustomComboTextEntry (Backend.TextEntryBackend); entry = new CustomComboTextEntry (Backend.TextEntryBackend);
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -69,7 +69,7 @@ namespace Xwt
} }
} }
protected override WindowFrame.WindowBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WindowBackendHost (); return new WindowBackendHost ();
} }

Просмотреть файл

@ -41,11 +41,12 @@ namespace Xwt
string fileName; string fileName;
string[] fileNames = new string[0]; string[] fileNames = new string[0];
BackendHost<FileDialog> backendHost = new BackendHost<FileDialog> (); BackendHost<FileDialog,IFileDialogBackend> backendHost;
internal FileDialog () internal FileDialog ()
{ {
filters = new FileDialogFilterCollection (AddRemoveItem); filters = new FileDialogFilterCollection (AddRemoveItem);
backendHost = new BackendHost<FileDialog,IFileDialogBackend> ();
backendHost.Parent = this; backendHost.Parent = this;
} }
@ -55,7 +56,7 @@ namespace Xwt
} }
IFileDialogBackend Backend { IFileDialogBackend Backend {
get { return (IFileDialogBackend) backendHost.Backend; } get { return backendHost.Backend; }
} }
void AddRemoveItem (FileDialogFilter filter, bool added) void AddRemoveItem (FileDialogFilter filter, bool added)

Просмотреть файл

@ -55,7 +55,7 @@ namespace Xwt
} }
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -67,7 +67,7 @@ namespace Xwt
views = new CellViewCollection ((ICellContainer)BackendHost); views = new CellViewCollection ((ICellContainer)BackendHost);
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -35,15 +35,12 @@ namespace Xwt
{ {
DataField[] fields; DataField[] fields;
class ListStoreBackendHost: BackendHost<ListStore> class ListStoreBackendHost: BackendHost<ListStore,IListStoreBackend>
{ {
protected override IBackend OnCreateBackend () protected override void OnBackendCreated ()
{ {
IBackend b = base.OnCreateBackend (); Backend.Initialize (Parent.fields.Select (f => f.FieldType).ToArray ());
if (b == null) base.OnBackendCreated ();
b = new DefaultListStoreBackend ();
((IListStoreBackend)b).Initialize (Parent.fields.Select (f => f.FieldType).ToArray ());
return b;
} }
} }

Просмотреть файл

@ -71,7 +71,7 @@ namespace Xwt
VerticalScrollPolicy = HorizontalScrollPolicy = ScrollPolicy.Automatic; VerticalScrollPolicy = HorizontalScrollPolicy = ScrollPolicy.Automatic;
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -65,7 +65,7 @@ namespace Xwt
Image = img; Image = img;
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -38,12 +38,12 @@ namespace Xwt
EventHandler clicked; EventHandler clicked;
Image image; Image image;
protected class MenuItemBackendHost: BackendHost<MenuItem>, IMenuItemEventSink protected class MenuItemBackendHost: BackendHost<MenuItem,IMenuItemBackend>, IMenuItemEventSink
{ {
protected override void OnBackendCreated () protected override void OnBackendCreated ()
{ {
base.OnBackendCreated (); base.OnBackendCreated ();
((IMenuItemBackend)Backend).Initialize (this); Backend.Initialize (this);
} }
public void OnClicked () public void OnClicked ()

Просмотреть файл

@ -74,7 +74,7 @@ namespace Xwt
tabs = new ChildrenCollection <NotebookTab> ((WidgetBackendHost) BackendHost); tabs = new ChildrenCollection <NotebookTab> ((WidgetBackendHost) BackendHost);
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -85,7 +85,7 @@ namespace Xwt
panel2 = new Panel ((WidgetBackendHost)BackendHost, 2); panel2 = new Panel ((WidgetBackendHost)BackendHost, 2);
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -32,23 +32,23 @@ namespace Xwt
{ {
EventHandler valueChanged; EventHandler valueChanged;
class BackendHost: BackendHost<ScrollAdjustment>, IScrollAdjustmentEventSink class ScrollAdjustmentBackendHost: BackendHost<ScrollAdjustment,IScrollAdjustmentBackend>, IScrollAdjustmentEventSink
{ {
protected override void OnBackendCreated () protected override void OnBackendCreated ()
{ {
base.OnBackendCreated (); base.OnBackendCreated ();
Backend.Initialize (new EventSink () { Parent = this }); Backend.Initialize (this);
} }
public void OnValueChanged () public void OnValueChanged ()
{ {
((IScrollAdjustmentBackend)Parent).OnValueChanged (EventArgs.Empty); Parent.OnValueChanged (EventArgs.Empty);
} }
} }
protected override Xwt.Backends.BackendHost CreateBackendHost () protected override Xwt.Backends.BackendHost CreateBackendHost ()
{ {
return new ScrollAdjustment.BackendHost (); return new ScrollAdjustmentBackendHost ();
} }
static ScrollAdjustment () static ScrollAdjustment ()
@ -66,11 +66,12 @@ namespace Xwt
PageIncrement = 10; 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; } get { return (IScrollAdjustmentBackend) BackendHost.Backend; }
} }
@ -140,12 +141,12 @@ namespace Xwt
public event EventHandler ValueChanged { public event EventHandler ValueChanged {
add { add {
OnBeforeEventAdd (ScrollAdjustmentEvent.ValueChanged, valueChanged); BackendHost.OnBeforeEventAdd (ScrollAdjustmentEvent.ValueChanged, valueChanged);
valueChanged += value; valueChanged += value;
} }
remove { remove {
valueChanged -= value; valueChanged -= value;
OnAfterEventRemove (ScrollAdjustmentEvent.ValueChanged, valueChanged); BackendHost.OnAfterEventRemove (ScrollAdjustmentEvent.ValueChanged, valueChanged);
} }
} }
} }

Просмотреть файл

@ -46,7 +46,7 @@ namespace Xwt
} }
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -46,8 +46,8 @@ namespace Xwt
this.title = title; this.title = title;
} }
new ISelectFolderDialogBackend Backend { ISelectFolderDialogBackend Backend {
get { return (ISelectFolderDialogBackend) base.Backend; } get { return (ISelectFolderDialogBackend) BackendHost.Backend; }
} }
public string Title { public string Title {

Просмотреть файл

@ -42,7 +42,7 @@ namespace Xwt
} }
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -65,7 +65,7 @@ namespace Xwt
} }
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -55,7 +55,7 @@ namespace Xwt
{ {
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -62,7 +62,7 @@ namespace Xwt
{ {
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -37,15 +37,12 @@ namespace Xwt
{ {
DataField[] fields; DataField[] fields;
class TreeStoreBackendHost: BackendHost<TreeStore> class TreeStoreBackendHost: BackendHost<TreeStore,ITreeStoreBackend>
{ {
protected override IBackend OnCreateBackend () protected override void OnBackendCreated ()
{ {
IBackend b = base.OnCreateBackend (); Backend.Initialize (Parent.fields.Select (f => f.FieldType).ToArray ());
if (b == null) base.OnBackendCreated ();
b = new DefaultTreeStoreBackend ();
((ITreeStoreBackend)b).Initialize (Parent.fields.Select (f => f.FieldType).ToArray ());
return b;
} }
} }

Просмотреть файл

@ -84,7 +84,7 @@ namespace Xwt
DataSource = source; DataSource = source;
} }
protected override Widget.WidgetBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }

Просмотреть файл

@ -36,7 +36,7 @@ using System.Linq;
namespace Xwt namespace Xwt
{ {
public abstract class Widget: Component, IWidgetSurface, IFrontend public abstract class Widget: XwtComponent, IWidgetSurface
{ {
static Widget[] emptyList = new Widget[0]; static Widget[] emptyList = new Widget[0];
List<Widget> children; List<Widget> children;
@ -45,7 +45,6 @@ namespace Xwt
WidgetSize height; WidgetSize height;
bool widthCached; bool widthCached;
bool heightCached; bool heightCached;
WidgetBackendHost backendHost;
DragOperation currentDragOperation; DragOperation currentDragOperation;
Widget contentWidget; Widget contentWidget;
WindowFrame parentWindow; WindowFrame parentWindow;
@ -82,16 +81,12 @@ namespace Xwt
} }
} }
protected class WidgetBackendHost: BackendHost<Widget>, IWidgetEventSink, ISpacingListener protected class WidgetBackendHost: BackendHost<Widget, IWidgetBackend>, IWidgetEventSink, ISpacingListener
{ {
public WidgetBackendHost () public WidgetBackendHost ()
{ {
} }
public WidgetBackendHost (IBackend backend): base (backend)
{
}
protected override IBackend OnCreateBackend () protected override IBackend OnCreateBackend ()
{ {
var backend = base.OnCreateBackend (); var backend = base.OnCreateBackend ();
@ -263,9 +258,9 @@ namespace Xwt
public Widget () public Widget ()
{ {
backendHost = CreateBackendHost (); if (!(base.BackendHost is WidgetBackendHost))
backendHost.Parent = this; throw new InvalidOperationException ("CreateBackendHost for Widget did not return a WidgetBackendHost instance");
margin = new Xwt.WidgetSpacing (backendHost); margin = new Xwt.WidgetSpacing (BackendHost);
} }
static Widget () static Widget ()
@ -292,16 +287,20 @@ namespace Xwt
MapEvent (WidgetEvent.PreferredWidthForHeightCheck, typeof (Widget), "OnGetPreferredWidthForHeight"); 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) internal protected static IBackend GetBackend (Widget w)
{ {
return w != null ? w.Backend : null; 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) protected override void Dispose (bool disposing)
{ {
base.Dispose (disposing); base.Dispose (disposing);
@ -330,21 +329,17 @@ namespace Xwt
parentWindow = win; parentWindow = win;
} }
protected virtual WidgetBackendHost CreateBackendHost () /* protected virtual WidgetBackendHost CreateBackendHost ()
{ {
return new WidgetBackendHost (); return new WidgetBackendHost ();
} }
protected WidgetBackendHost BackendHost { protected WidgetBackendHost BackendHost {
get { return backendHost; } get { return backendHost; }
} }*/
IWidgetBackend Backend { IWidgetBackend Backend {
get { return (IWidgetBackend) backendHost.Backend; } get { return (IWidgetBackend) BackendHost.Backend; }
}
object IFrontend.Backend {
get { return Backend; }
} }
public WidgetSpacing Margin { public WidgetSpacing Margin {

Просмотреть файл

@ -45,7 +45,7 @@ namespace Xwt
} }
} }
protected override WindowFrame.WindowBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WindowBackendHost (); return new WindowBackendHost ();
} }

Просмотреть файл

@ -56,30 +56,20 @@ using System.ComponentModel;
namespace Xwt namespace Xwt
{ {
public class WindowFrame: Component public class WindowFrame: XwtComponent
{ {
EventHandler boundsChanged; EventHandler boundsChanged;
Rectangle bounds; Rectangle bounds;
WindowBackendHost backendHost;
bool pendingReallocation; bool pendingReallocation;
protected class WindowBackendHost: BackendHost<WindowFrame>, IWindowFrameEventSink protected class WindowBackendHost: BackendHost<WindowFrame,IWindowFrameBackend>, IWindowFrameEventSink
{ {
public WindowBackendHost ()
{
}
public WindowBackendHost (IBackend backend): base (backend)
{
}
protected override void OnBackendCreated () protected override void OnBackendCreated ()
{ {
base.OnBackendCreated (); base.OnBackendCreated ();
var b = (IWindowFrameBackend)Backend; Backend.Initialize (this);
b.Initialize (this); Parent.bounds = Backend.Bounds;
Parent.bounds = b.Bounds; Backend.EnableEvent (WindowFrameEvent.BoundsChanged);
b.EnableEvent (WindowFrameEvent.BoundsChanged);
} }
public void OnBoundsChanged (Rectangle bounds) public void OnBoundsChanged (Rectangle bounds)
@ -90,8 +80,8 @@ namespace Xwt
public WindowFrame () public WindowFrame ()
{ {
backendHost = CreateBackendHost (); if (!(base.BackendHost is WindowBackendHost))
backendHost.Parent = this; throw new InvalidOperationException ("CreateBackendHost for WindowFrame did not return a WindowBackendHost instance");
} }
public WindowFrame (string title): this () public WindowFrame (string title): this ()
@ -113,13 +103,13 @@ namespace Xwt
get { return (IWindowFrameBackend) BackendHost.Backend; } get { return (IWindowFrameBackend) BackendHost.Backend; }
} }
protected virtual WindowBackendHost CreateBackendHost () protected override BackendHost CreateBackendHost ()
{ {
return new WindowBackendHost (); return new WindowBackendHost ();
} }
protected WindowBackendHost BackendHost { protected new WindowBackendHost BackendHost {
get { return backendHost; } get { return (WindowBackendHost) base.BackendHost; }
} }
public Rectangle ScreenBounds { public Rectangle ScreenBounds {

Просмотреть файл

@ -33,103 +33,6 @@ using Xwt.Backends;
namespace Xwt namespace Xwt
{ {
/* public abstract class XwtComponent: Component, IFrontend
{
IBackend backend;
bool usingCustomBackend;
HashSet<object> 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<IBackend> (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<object> DefaultEnabledEvents {
get {
if (defaultEnabledEvents == null)
defaultEnabledEvents = EventUtil.GetDefaultEnabledEvents (GetType ());
return defaultEnabledEvents;
}
}
}
*/
public abstract class XwtComponent: Component, IFrontend public abstract class XwtComponent: Component, IFrontend
{ {
BackendHost backendHost; BackendHost backendHost;