This commit is contained in:
Zihan Chen
2018-07-05 05:37:10 -07:00
parent 230de0e1a0
commit 189ab6ff06
19 changed files with 85 additions and 109 deletions
+2 -2
View File
@@ -6864,7 +6864,7 @@ GuiControlHost
{ {
if(host->GetNativeWindow()) if(host->GetNativeWindow())
{ {
host->GetNativeWindow()->Hide(); host->GetNativeWindow()->Hide(false);
} }
} }
@@ -6875,7 +6875,7 @@ GuiControlHost
{ {
if(GetCurrentController()->WindowService()->GetMainWindow()!=window) if(GetCurrentController()->WindowService()->GetMainWindow()!=window)
{ {
window->Hide(); window->Hide(false);
} }
else else
{ {
+2 -1
View File
@@ -1559,7 +1559,8 @@ Native Window
/// <summary> /// <summary>
/// Hide the window. /// Hide the window.
/// </summary> /// </summary>
virtual void Hide()=0; /// <param name="closeWindow">Set to true to really close the window. Or the window will just be hidden. This parameter only affect the main window.</param>
virtual void Hide(bool closeWindow)=0;
/// <summary> /// <summary>
/// Test is the window visible. /// Test is the window visible.
/// </summary> /// </summary>
+60 -69
View File
@@ -3558,7 +3558,7 @@ WorkflowGenerateBindingVisitor
FOREACH(Ptr<GuiInstanceLocalized>, localized, resolvingResult.context->localizeds) FOREACH(Ptr<GuiInstanceLocalized>, localized, resolvingResult.context->localizeds)
{ {
auto code = L"bind(" + localized->className + L"::Get(presentation::controls::GuiApplication::GetApplication().Locale) of (" + localized->interfaceName + L"^))"; auto code = L"bind(" + localized->className.ToString() + L"::Get(presentation::controls::GuiApplication::GetApplication().Locale))";
if (auto bindExpr = Workflow_ParseExpression(precompileContext, { resolvingResult.resource }, code, localized->tagPosition, errors)) if (auto bindExpr = Workflow_ParseExpression(precompileContext, { resolvingResult.resource }, code, localized->tagPosition, errors))
{ {
auto instancePropertyInfo = resolvingResult.rootTypeInfo.typeInfo->GetTypeDescriptor()->GetPropertyByName(localized->name.ToString(), true); auto instancePropertyInfo = resolvingResult.rootTypeInfo.typeInfo->GetTypeDescriptor()->GetPropertyByName(localized->name.ToString(), true);
@@ -5764,16 +5764,16 @@ GuiInstanceContext
else if (element->name.value == L"ref.LocalizedStrings") else if (element->name.value == L"ref.LocalizedStrings")
{ {
auto attName = XmlGetAttribute(element, L"Name"); auto attName = XmlGetAttribute(element, L"Name");
auto attUri = XmlGetAttribute(element, L"Uri"); auto attClass = XmlGetAttribute(element, L"Class");
auto attDefault = XmlGetAttribute(element, L"Default"); auto attDefault = XmlGetAttribute(element, L"Default");
if (attName && attUri) if (attName && attClass)
{ {
auto localized = MakePtr<GuiInstanceLocalized>(); auto localized = MakePtr<GuiInstanceLocalized>();
localized->name = GlobalStringKey::Get(attName->value.value); localized->name = GlobalStringKey::Get(attName->value.value);
localized->uri = GlobalStringKey::Get(attUri->value.value); localized->className = GlobalStringKey::Get(attClass->value.value);
localized->tagPosition = { { resource },element->codeRange.start }; localized->tagPosition = { { resource },element->codeRange.start };
localized->uriPosition = { { resource },attUri->value.codeRange.start }; localized->classPosition = { { resource },attClass->value.codeRange.start };
localized->uriPosition.column += 1; localized->classPosition.column += 1;
if (attDefault) if (attDefault)
{ {
@@ -5783,7 +5783,7 @@ GuiInstanceContext
} }
else else
{ {
errors.Add(GuiResourceError({ { resource },element->codeRange.start }, L"ref.LocalizedStrings requires the following attributes existing at the same time: Name, Uri.")); errors.Add(GuiResourceError({ { resource },element->codeRange.start }, L"ref.LocalizedStrings requires the following attributes existing at the same time: Name, Class."));
} }
} }
@@ -5892,9 +5892,9 @@ GuiInstanceContext
attName->value.value = localized->name.ToString(); attName->value.value = localized->name.ToString();
xmlParameter->attributes.Add(attName); xmlParameter->attributes.Add(attName);
auto attUri = MakePtr<XmlAttribute>(); auto attClass = MakePtr<XmlAttribute>();
attUri->name.value = L"Class"; attClass->name.value = L"Class";
attUri->value.value = localized->uri.ToString(); attClass->value.value = localized->className.ToString();
xmlParameter->attributes.Add(attClass); xmlParameter->attributes.Add(attClass);
auto attDefault = MakePtr<XmlAttribute>(); auto attDefault = MakePtr<XmlAttribute>();
@@ -7989,31 +7989,6 @@ Instance Type Resolver (Instance)
} }
} }
FOREACH(Ptr<GuiInstanceLocalized>, localized, obj->localizeds)
{
WString protocol, path;
if (IsResourceUrl(localized->uri.ToString(), protocol, path))
{
if (auto ls = context.resolver->ResolveResource(protocol, path).Cast<GuiInstanceLocalizedStrings>())
{
localized->className = ls->className;
localized->interfaceName = ls->GetInterfaceTypeName(true);
}
else
{
errors.Add(GuiResourceError({ resource }, localized->tagPosition,
L"Failed to find the localized string referred in attribute \"Uri\": \"" + localized->uri.ToString() + L"\".")
);
}
}
else
{
errors.Add(GuiResourceError({ resource }, localized->tagPosition,
L"Invalid path in attribute \"Uri\": \"" + localized->uri.ToString() + L"\".")
);
}
}
obj->ApplyStyles(resource, context.resolver, errors); obj->ApplyStyles(resource, context.resolver, errors);
types::ResolvingResult resolvingResult; types::ResolvingResult resolvingResult;
@@ -9942,19 +9917,59 @@ Workflow_GenerateInstanceClass
FOREACH(Ptr<GuiInstanceLocalized>, localized, context->localizeds) FOREACH(Ptr<GuiInstanceLocalized>, localized, context->localizeds)
{ {
if (auto type = GetTypeDescriptor(localized->interfaceName)) if (auto lsTd = GetTypeDescriptor(localized->className.ToString()))
{ {
auto prop = MakePtr<WfAutoPropertyDeclaration>(); ITypeDescriptor* lsiTd = nullptr;
addDecl(prop); if (auto group = lsTd->GetMethodGroupByName(L"Get", false))
{
vint count = group->GetMethodCount();
for (vint i = 0; i < count; i++)
{
auto method = group->GetMethod(i);
if (method->GetParameterCount() == 1)
{
auto paramTd = method->GetParameter(0)->GetType()->GetTypeDescriptor();
if (paramTd == description::GetTypeDescriptor<Locale>())
{
lsiTd = method->GetReturn()->GetTypeDescriptor();
break;
}
}
}
}
prop->name.value = localized->name.ToString(); if (lsiTd)
prop->type = GetTypeFromTypeInfo(Workflow_GetSuggestedParameterType(type).Obj()); {
prop->configConst = WfAPConst::Writable; auto prop = MakePtr<WfAutoPropertyDeclaration>();
prop->configObserve = WfAPObserve::Observable; addDecl(prop);
auto nullExpr = MakePtr<WfLiteralExpression>(); prop->name.value = localized->name.ToString();
nullExpr->value = WfLiteralValue::Null; prop->type = GetTypeFromTypeInfo(Workflow_GetSuggestedParameterType(lsiTd).Obj());
prop->expression = nullExpr; prop->configConst = WfAPConst::Writable;
prop->configObserve = WfAPObserve::Observable;
auto nullExpr = MakePtr<WfLiteralExpression>();
nullExpr->value = WfLiteralValue::Null;
prop->expression = nullExpr;
}
else
{
errors.Add(GuiResourceError({ resolvingResult.resource }, localized->classPosition,
L"Precompile: Class \"" +
localized->className.ToString() +
L"\" of localized strings \"" +
localized->name.ToString() +
L"\" is not a correct localized strings class."));
}
}
else
{
errors.Add(GuiResourceError({ resolvingResult.resource }, localized->classPosition,
L"Precompile: Class \"" +
localized->className.ToString() +
L"\" of localized strings \"" +
localized->name.ToString() +
L"\" cannot be found."));
} }
} }
@@ -11131,30 +11146,6 @@ WorkflowReferenceNamesVisitor
resolvingResult.typeInfos.Add(parameter->name, { GlobalStringKey::Get(type->GetTypeName()),referenceType }); resolvingResult.typeInfos.Add(parameter->name, { GlobalStringKey::Get(type->GetTypeName()),referenceType });
} }
} }
FOREACH(Ptr<GuiInstanceLocalized>, localized, resolvingResult.context->localizeds)
{
auto type = GetTypeDescriptor(localized->interfaceName);
if (!type)
{
errors.Add(GuiResourceError({ resolvingResult.resource }, localized->tagPosition,
L"Precompile: Cannot find type \"" +
localized->interfaceName +
L"\"."));
}
else if (resolvingResult.typeInfos.Keys().Contains(localized->name))
{
errors.Add(GuiResourceError({ resolvingResult.resource }, localized->tagPosition,
L"[INTERNAL-ERROR] Precompile: Parameter \"" +
localized->name.ToString() +
L"\" conflict with an existing named object."));
}
else
{
auto referenceType = Workflow_GetSuggestedParameterType(type);
resolvingResult.typeInfos.Add(localized->name, { GlobalStringKey::Get(type->GetTypeName()),referenceType });
}
}
List<types::PropertyResolving> infos; List<types::PropertyResolving> infos;
vint generatedNameCount = 0; vint generatedNameCount = 0;
+2 -4
View File
@@ -415,12 +415,10 @@ Instance Namespace
{ {
public: public:
GlobalStringKey name; GlobalStringKey name;
GlobalStringKey uri; GlobalStringKey className;
GuiResourceTextPos tagPosition; GuiResourceTextPos tagPosition;
GuiResourceTextPos uriPosition; GuiResourceTextPos classPosition;
bool defaultStrings = false; bool defaultStrings = false;
WString className;
WString interfaceName;
}; };
/*********************************************************************** /***********************************************************************
+11 -4
View File
@@ -13264,7 +13264,7 @@ WindowsForm
} }
return false; return false;
case INativeWindowListener::ButtonClose: case INativeWindowListener::ButtonClose:
Hide(); Hide(true);
return false; return false;
} }
} }
@@ -13568,9 +13568,16 @@ WindowsForm
ShowWindow(handle, SW_SHOWMINIMIZED); ShowWindow(handle, SW_SHOWMINIMIZED);
} }
void Hide() void Hide(bool closeWindow)
{ {
PostMessage(handle, WM_CLOSE, NULL, NULL); if (closeWindow)
{
PostMessage(handle, WM_CLOSE, NULL, NULL);
}
else
{
ShowWindow(handle, SW_HIDE);
}
} }
bool IsVisible() bool IsVisible()
@@ -13866,7 +13873,7 @@ WindowsController
{ {
if(windows.Values().Get(i)->IsVisible()) if(windows.Values().Get(i)->IsVisible())
{ {
windows.Values().Get(i)->Hide(); windows.Values().Get(i)->Hide(true);
} }
} }
while(windows.Count()) while(windows.Count())
Binary file not shown.
+4 -19
View File
@@ -29,24 +29,9 @@ you should add the following metadata in GacGenConfig like this:
</Dependencies> </Dependencies>
</ResourceMetadata> </ResourceMetadata>
</Xml> </Xml>
<Folder name="Cpp"> <Folder name="Cpp">...</Folder>
<Text name="Resource">The output path for unscripted binary resource. Use GetResourceManager()->LoadResourceOrPending to load the resource.</Text> <Folder name="ResX86">...</Folder>
<Text name="Compressed">The output path for unscripted compressed binary resource. Call DecompressStream before loading the resource.</Text> <Folder name="ResX64">...</Folder>
<Text name="CppResource">The output path for unscripted binary resource embedded in C++ code. Just add this cpp file to your project and it just works.</Text>
<Text name="CppCompressed">The output path for unscripted binary resource embedded in C++ code. Just add this cpp file to your project and it just works.</Text>
<Text name="NormalInclude">#include targets in generated C++ files, seperated by semicolon.</Text>
<Text name="ReflectionInclude">#include targets in generated C++ files when you turn on reflection, seperated by semicolon.</Text>
<Text name="Name">General file name for generated C++ files without extension.</Text>
<Text name="SourceFolder">The output folder for all generated C++ files.</Text>
</Folder>
<Folder name="ResX86">
<Text name="Resource">The output path for scripted binary resource. Use GetResourceManager()->LoadResourceOrPending with GuiResourceUsage::InstanceClass to load the resource.</Text>
<Text name="Compressed">The output path for scripted compressed binary resource. Use GetResourceManager()->LoadResourceOrPending to load the resource.</Text>
<Text name="Assembly">Generated Workflow script, which is equivalent to generated C++ code. All assemblies are included in scripted binary resources, but if you want to load unscripted binary resources and assemblies separately, you will need this file.</Text>
</Folder>
<Folder name="ResX64">
<!-- just like RexX86 but they are for x64. x86 and x64 generates different Workflow script. -->
</Folder>
</Folder> </Folder>
</Folder> </Folder>
... ...
@@ -73,8 +58,8 @@ try {
$FileName = (Resolve-Path -Path $FileName).Path $FileName = (Resolve-Path -Path $FileName).Path
if (Test-Path -Path "$($FileName).log") { if (Test-Path -Path "$($FileName).log") {
Remove-Item -Path "$($FileName).log" -Recurse | Out-Null Remove-Item -Path "$($FileName).log" -Recurse | Out-Null
New-Item -ItemType Directory "$($FileName).log" | Out-Null
} }
New-Item -ItemType Directory "$($FileName).log" | Out-Null
EnumerateResourceFiles $FileName EnumerateResourceFiles $FileName
if (-not (Test-Path -Path "$($FileName).log\ResourceFiles.txt")) { if (-not (Test-Path -Path "$($FileName).log\ResourceFiles.txt")) {
+1 -1
View File
@@ -22,8 +22,8 @@ try {
$FileName = (Resolve-Path -Path $FileName).Path $FileName = (Resolve-Path -Path $FileName).Path
if (Test-Path -Path "$($FileName).log") { if (Test-Path -Path "$($FileName).log") {
Remove-Item -Path "$($FileName).log" -Recurse | Out-Null Remove-Item -Path "$($FileName).log" -Recurse | Out-Null
New-Item -ItemType Directory "$($FileName).log" | Out-Null
} }
New-Item -ItemType Directory "$($FileName).log" | Out-Null
EnumerateResourceFiles $FileName EnumerateResourceFiles $FileName
if (-not (Test-Path -Path "$($FileName).log\ResourceFiles.txt")) { if (-not (Test-Path -Path "$($FileName).log\ResourceFiles.txt")) {
Binary file not shown.
Binary file not shown.
@@ -33,7 +33,7 @@
</LocalizedStrings> </LocalizedStrings>
</LocalizedStrings> </LocalizedStrings>
<Instance name="MainWindowResource"> <Instance name="LocalizedStringsTabPageResource">
<Instance ref.CodeBehind="false" ref.Class="demo::LocalizedStringsTabPage"> <Instance ref.CodeBehind="false" ref.Class="demo::LocalizedStringsTabPage">
<ref.Members> <ref.Members>
<![CDATA[ <![CDATA[
@@ -54,7 +54,7 @@
var currency: double = 1342177.28; var currency: double = 1342177.28;
]]> ]]>
</ref.Members> </ref.Members>
<ref.LocalizedStrings Name="Strings" Uri="res://LocalizedStringsTabPage/StringResource" Default="true"/> <ref.LocalizedStrings Name="Strings" Class="demo::StringResource" Default="true"/>
<TabPage ref.Name="self" Text-str="Title()"> <TabPage ref.Name="self" Text-str="Title()">
<Table AlignmentToParent="left:0 top:0 right:0 bottom:0" CellPadding="5"> <Table AlignmentToParent="left:0 top:0 right:0 bottom:0" CellPadding="5">
<att.Rows> <att.Rows>
@@ -16051,7 +16051,6 @@ Class (::demo::LocalizedStringsTabPageConstructor)
LocalizedStringsTabPageConstructor::LocalizedStringsTabPageConstructor() LocalizedStringsTabPageConstructor::LocalizedStringsTabPageConstructor()
: self(static_cast<::demo::LocalizedStringsTabPage*>(nullptr)) : self(static_cast<::demo::LocalizedStringsTabPage*>(nullptr))
, Strings(::vl::Ptr<::demo::IStringResourceStrings>())
, comboLocales(static_cast<::vl::presentation::controls::GuiComboBoxListControl*>(nullptr)) , comboLocales(static_cast<::vl::presentation::controls::GuiComboBoxListControl*>(nullptr))
, listLocales(static_cast<::vl::presentation::controls::GuiTextList*>(nullptr)) , listLocales(static_cast<::vl::presentation::controls::GuiTextList*>(nullptr))
, __vwsn_precompile_0(static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr)) , __vwsn_precompile_0(static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr))
@@ -1382,7 +1382,6 @@ namespace demo
#endif #endif
protected: protected:
::demo::LocalizedStringsTabPage* self; ::demo::LocalizedStringsTabPage* self;
::vl::Ptr<::demo::IStringResourceStrings> Strings;
::vl::presentation::controls::GuiComboBoxListControl* comboLocales; ::vl::presentation::controls::GuiComboBoxListControl* comboLocales;
::vl::presentation::controls::GuiTextList* listLocales; ::vl::presentation::controls::GuiTextList* listLocales;
::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0; ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0;
@@ -926,7 +926,6 @@ namespace vl
CLASS_MEMBER_FIELD(__vwsn_precompile_7) CLASS_MEMBER_FIELD(__vwsn_precompile_7)
CLASS_MEMBER_FIELD(__vwsn_precompile_8) CLASS_MEMBER_FIELD(__vwsn_precompile_8)
CLASS_MEMBER_FIELD(__vwsn_precompile_9) CLASS_MEMBER_FIELD(__vwsn_precompile_9)
CLASS_MEMBER_FIELD(Strings)
CLASS_MEMBER_FIELD(comboLocales) CLASS_MEMBER_FIELD(comboLocales)
CLASS_MEMBER_FIELD(listLocales) CLASS_MEMBER_FIELD(listLocales)
CLASS_MEMBER_FIELD(self) CLASS_MEMBER_FIELD(self)
@@ -1853,8 +1853,7 @@ Class (::demo::MainWindowConstructor)
} }
MainWindowConstructor::MainWindowConstructor() MainWindowConstructor::MainWindowConstructor()
: Strings(::vl::Ptr<::demo::IStringResourceStrings>()) : self(static_cast<::demo::MainWindow*>(nullptr))
, self(static_cast<::demo::MainWindow*>(nullptr))
, comboLocales(static_cast<::vl::presentation::controls::GuiComboBoxListControl*>(nullptr)) , comboLocales(static_cast<::vl::presentation::controls::GuiComboBoxListControl*>(nullptr))
, listLocales(static_cast<::vl::presentation::controls::GuiTextList*>(nullptr)) , listLocales(static_cast<::vl::presentation::controls::GuiTextList*>(nullptr))
, __vwsn_precompile_0(static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr)) , __vwsn_precompile_0(static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr))
@@ -132,7 +132,6 @@ namespace demo
friend struct ::vl::reflection::description::CustomTypeDescriptorSelector<MainWindowConstructor>; friend struct ::vl::reflection::description::CustomTypeDescriptorSelector<MainWindowConstructor>;
#endif #endif
protected: protected:
::vl::Ptr<::demo::IStringResourceStrings> Strings;
::demo::MainWindow* self; ::demo::MainWindow* self;
::vl::presentation::controls::GuiComboBoxListControl* comboLocales; ::vl::presentation::controls::GuiComboBoxListControl* comboLocales;
::vl::presentation::controls::GuiTextList* listLocales; ::vl::presentation::controls::GuiTextList* listLocales;
@@ -94,7 +94,6 @@ namespace vl
CLASS_MEMBER_FIELD(__vwsn_precompile_7) CLASS_MEMBER_FIELD(__vwsn_precompile_7)
CLASS_MEMBER_FIELD(__vwsn_precompile_8) CLASS_MEMBER_FIELD(__vwsn_precompile_8)
CLASS_MEMBER_FIELD(__vwsn_precompile_9) CLASS_MEMBER_FIELD(__vwsn_precompile_9)
CLASS_MEMBER_FIELD(Strings)
CLASS_MEMBER_FIELD(comboLocales) CLASS_MEMBER_FIELD(comboLocales)
CLASS_MEMBER_FIELD(listLocales) CLASS_MEMBER_FIELD(listLocales)
CLASS_MEMBER_FIELD(self) CLASS_MEMBER_FIELD(self)
Binary file not shown.
Binary file not shown.